diff options
author | Chris Lattner <sabre@nondot.org> | 2009-01-09 18:18:43 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-01-09 18:18:43 +0000 |
commit | 583dd6072eed7a446dad8f0e796fa34aec40aa12 (patch) | |
tree | 494cfaa54785b56b382741b4dc5433ea17998f30 /lib | |
parent | 9b8f542e2746b28721b3ec603c3aaaa10ea708fc (diff) | |
download | external_llvm-583dd6072eed7a446dad8f0e796fa34aec40aa12.tar.gz external_llvm-583dd6072eed7a446dad8f0e796fa34aec40aa12.tar.bz2 external_llvm-583dd6072eed7a446dad8f0e796fa34aec40aa12.zip |
Fix PR3304
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61995 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Transforms/Scalar/ScalarReplAggregates.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/Transforms/Scalar/ScalarReplAggregates.cpp b/lib/Transforms/Scalar/ScalarReplAggregates.cpp index 041fd4917b..d7b8b58ab0 100644 --- a/lib/Transforms/Scalar/ScalarReplAggregates.cpp +++ b/lib/Transforms/Scalar/ScalarReplAggregates.cpp @@ -856,6 +856,10 @@ void SROA::RewriteStoreUserOfWholeAlloca(StoreInst *SI, // Truncate down to an integer of the right size. uint64_t FieldSizeBits = TD->getTypeSizeInBits(FieldTy); + + // Ignore zero sized fields like {}, they obviously contain no data. + if (FieldSizeBits == 0) continue; + if (FieldSizeBits != AllocaSizeBits) EltVal = new TruncInst(EltVal, IntegerType::get(FieldSizeBits), "", SI); Value *DestField = NewElts[i]; @@ -887,6 +891,8 @@ void SROA::RewriteStoreUserOfWholeAlloca(StoreInst *SI, Shift = 0; for (unsigned i = 0, e = NewElts.size(); i != e; ++i) { + // Ignore zero sized fields like {}, they obviously contain no data. + if (ElementSizeBits == 0) continue; Value *EltVal = SrcVal; if (Shift) { @@ -959,8 +965,12 @@ void SROA::RewriteLoadUserOfWholeAlloca(LoadInst *LI, AllocationInst *AI, Value *SrcField = NewElts[i]; const Type *FieldTy = cast<PointerType>(SrcField->getType())->getElementType(); - const IntegerType *FieldIntTy = - IntegerType::get(TD->getTypeSizeInBits(FieldTy)); + uint64_t FieldSizeBits = TD->getTypeSizeInBits(FieldTy); + + // Ignore zero sized fields like {}, they obviously contain no data. + if (FieldSizeBits == 0) continue; + + const IntegerType *FieldIntTy = IntegerType::get(FieldSizeBits); if (!isa<IntegerType>(FieldTy) && !FieldTy->isFloatingPoint() && !isa<VectorType>(FieldTy)) SrcField = new BitCastInst(SrcField, PointerType::getUnqual(FieldIntTy), |