diff options
author | Chris Lattner <sabre@nondot.org> | 2009-05-08 15:54:41 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-05-08 15:54:41 +0000 |
commit | c48091f1419336649bf2d9774437ba558daa873e (patch) | |
tree | 4beeccf9ec54ad28b5d263cd6c6435dd7c59ad73 /llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp | |
parent | a02cb80f99452a06178b5fd3d5bf64f9e748484f (diff) | |
download | bcm5719-llvm-c48091f1419336649bf2d9774437ba558daa873e.tar.gz bcm5719-llvm-c48091f1419336649bf2d9774437ba558daa873e.zip |
fix RewriteStoreUserOfWholeAlloca to use the correct type size
method, fixing a crash on PR4146. While the store will
ultimately overwrite the "padded size" number of bits in memory,
the stored value may be a subset of this size. This function
only wants to handle the case where all bits are stored.
llvm-svn: 71224
Diffstat (limited to 'llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp')
-rw-r--r-- | llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp b/llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp index 1bc8a1e3ea8..db6500c930b 100644 --- a/llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp +++ b/llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp @@ -903,9 +903,10 @@ void SROA::RewriteStoreUserOfWholeAlloca(StoreInst *SI, // If this isn't a store of an integer to the whole alloca, it may be a store // to the first element. Just ignore the store in this case and normal SROA - // will handle it. + // will handle it. We don't handle types here that have tail padding, like + // an alloca of type {i1}. if (!isa<IntegerType>(SrcVal->getType()) || - TD->getTypePaddedSizeInBits(SrcVal->getType()) != AllocaSizeBits) + TD->getTypeSizeInBits(SrcVal->getType()) != AllocaSizeBits) return; DOUT << "PROMOTING STORE TO WHOLE ALLOCA: " << *AI << *SI; @@ -1015,9 +1016,10 @@ void SROA::RewriteLoadUserOfWholeAlloca(LoadInst *LI, AllocationInst *AI, // If this isn't a load of the whole alloca to an integer, it may be a load // of the first element. Just ignore the load in this case and normal SROA - // will handle it. + // will handle it. We don't handle types here that have tail padding, like + // an alloca of type {i1}. if (!isa<IntegerType>(LI->getType()) || - TD->getTypePaddedSizeInBits(LI->getType()) != AllocaSizeBits) + TD->getTypeSizeInBits(LI->getType()) != AllocaSizeBits) return; DOUT << "PROMOTING LOAD OF WHOLE ALLOCA: " << *AI << *LI; |