From 6be41eb7f00319f5ffa1a5435dcd1e81b3ce932d Mon Sep 17 00:00:00 2001 From: Cameron Zwarich Date: Sat, 18 Jun 2011 05:47:49 +0000 Subject: Fix an invalid bitcast crash that occurs when doing a partial memset of a vector alloca. Fixes part of . git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133336 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Scalar/ScalarReplAggregates.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/Transforms/Scalar/ScalarReplAggregates.cpp b/lib/Transforms/Scalar/ScalarReplAggregates.cpp index bb4779b912..38942dcb55 100644 --- a/lib/Transforms/Scalar/ScalarReplAggregates.cpp +++ b/lib/Transforms/Scalar/ScalarReplAggregates.cpp @@ -521,10 +521,22 @@ bool ConvertToScalarInfo::CanConvertToScalar(Value *V, uint64_t Offset) { // If this is a constant sized memset of a constant value (e.g. 0) we can // handle it. if (MemSetInst *MSI = dyn_cast(User)) { - // Store of constant value and constant size. - if (!isa(MSI->getValue()) || - !isa(MSI->getLength())) + // Store of constant value. + if (!isa(MSI->getValue())) return false; + + // Store of constant size. + ConstantInt *Len = dyn_cast(MSI->getLength()); + if (!Len) + return false; + + // If the size differs from the alloca, we can only convert the alloca to + // an integer bag-of-bits. + // FIXME: This should handle all of the cases that are currently accepted + // as vector element insertions. + if (Len->getZExtValue() != AllocaSize || Offset != 0) + ScalarKind = Integer; + IsNotTrivial = true; // Can't be mem2reg'd. HadNonMemTransferAccess = true; continue; -- cgit v1.2.3