[llvm-commits] [llvm] r61995 - in /llvm/trunk: lib/Transforms/Scalar/ScalarReplAggregates.cpp test/Transforms/ScalarRepl/2009-01-09-scalarrepl-empty.ll
Chris Lattner
sabre at nondot.org
Fri Jan 9 10:18:43 PST 2009
Author: lattner
Date: Fri Jan 9 12:18:43 2009
New Revision: 61995
URL: http://llvm.org/viewvc/llvm-project?rev=61995&view=rev
Log:
Fix PR3304
Added:
llvm/trunk/test/Transforms/ScalarRepl/2009-01-09-scalarrepl-empty.ll
Modified:
llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp
Modified: llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp?rev=61995&r1=61994&r2=61995&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp Fri Jan 9 12:18:43 2009
@@ -856,6 +856,10 @@
// 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 @@
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 @@
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),
Added: llvm/trunk/test/Transforms/ScalarRepl/2009-01-09-scalarrepl-empty.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/ScalarRepl/2009-01-09-scalarrepl-empty.ll?rev=61995&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/ScalarRepl/2009-01-09-scalarrepl-empty.ll (added)
+++ llvm/trunk/test/Transforms/ScalarRepl/2009-01-09-scalarrepl-empty.ll Fri Jan 9 12:18:43 2009
@@ -0,0 +1,15 @@
+; RUN: llvm-as < %s | opt -scalarrepl | llvm-dis
+; PR3304
+
+ %struct.c37304a__vrec = type { i8, %struct.c37304a__vrec___disc___XVN }
+ %struct.c37304a__vrec___disc___XVN = type {
+%struct.c37304a__vrec___disc___XVN___O }
+ %struct.c37304a__vrec___disc___XVN___O = type { }
+
+define void @_ada_c37304a() {
+entry:
+ %v = alloca %struct.c37304a__vrec ;
+ %0 = getelementptr %struct.c37304a__vrec* %v, i32 0, i32 0
+ store i8 8, i8* %0, align 1
+ unreachable
+}
More information about the llvm-commits
mailing list