aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms
diff options
context:
space:
mode:
authorCameron Zwarich <zwarich@apple.com>2011-06-08 22:08:31 +0000
committerCameron Zwarich <zwarich@apple.com>2011-06-08 22:08:31 +0000
commit0398d6135daef709f80837e457a75dc2e1c2aab7 (patch)
treebc9103f763c7e3acc771c832187030d59ee66f12 /lib/Transforms
parent69b9044c668dfb92038385a96c030778de64edfd (diff)
downloadexternal_llvm-0398d6135daef709f80837e457a75dc2e1c2aab7.zip
external_llvm-0398d6135daef709f80837e457a75dc2e1c2aab7.tar.gz
external_llvm-0398d6135daef709f80837e457a75dc2e1c2aab7.tar.bz2
Fix an assymmetry between ConvertScalar_ExtractValue and ConvertScalar_InsertValue. The
former was using the size of the entire alloca, whereas the latter was correctly using the allocated size of the immediate type being converted (which may differ from the size of the alloca). This fixes PR10082. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132759 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r--lib/Transforms/Scalar/ScalarReplAggregates.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/Transforms/Scalar/ScalarReplAggregates.cpp b/lib/Transforms/Scalar/ScalarReplAggregates.cpp
index 6b3c22b..9f286b5 100644
--- a/lib/Transforms/Scalar/ScalarReplAggregates.cpp
+++ b/lib/Transforms/Scalar/ScalarReplAggregates.cpp
@@ -742,8 +742,9 @@ ConvertScalar_ExtractValue(Value *FromVal, const Type *ToType,
// If the result alloca is a vector type, this is either an element
// access or a bitcast to another vector type of the same size.
if (const VectorType *VTy = dyn_cast<VectorType>(FromType)) {
+ unsigned FromTypeSize = TD.getTypeAllocSize(FromType);
unsigned ToTypeSize = TD.getTypeAllocSize(ToType);
- if (ToTypeSize == AllocaSize) {
+ if (FromTypeSize == ToTypeSize) {
// If the two types have the same primitive size, use a bit cast.
// Otherwise, it is two vectors with the same element type that has
// the same allocation size but different number of elements so use
@@ -755,13 +756,13 @@ ConvertScalar_ExtractValue(Value *FromVal, const Type *ToType,
return CreateShuffleVectorCast(FromVal, ToType, Builder);
}
- if (isPowerOf2_64(AllocaSize / ToTypeSize)) {
+ if (isPowerOf2_64(FromTypeSize / ToTypeSize)) {
assert(!(ToType->isVectorTy() && Offset != 0) && "Can't extract a value "
"of a smaller vector type at a nonzero offset.");
const Type *CastElementTy = getScaledElementType(FromType, ToType,
ToTypeSize * 8);
- unsigned NumCastVectorElements = AllocaSize / ToTypeSize;
+ unsigned NumCastVectorElements = FromTypeSize / ToTypeSize;
LLVMContext &Context = FromVal->getContext();
const Type *CastTy = VectorType::get(CastElementTy,