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 | ef554846f061b9b467e7824f8d01e3c59778f3f6 (patch) | |
tree | f97e89519e8214fab89332ff73c363af96c57e33 | |
parent | 4b7f7a6e1f3eacf116472c1b0d0eaddf01fa4495 (diff) | |
download | external_llvm-ef554846f061b9b467e7824f8d01e3c59778f3f6.zip external_llvm-ef554846f061b9b467e7824f8d01e3c59778f3f6.tar.gz external_llvm-ef554846f061b9b467e7824f8d01e3c59778f3f6.tar.bz2 |
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71224 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Transforms/Scalar/ScalarReplAggregates.cpp | 10 | ||||
-rw-r--r-- | test/Transforms/ScalarRepl/2009-05-08-I1Crash.ll | 12 |
2 files changed, 18 insertions, 4 deletions
diff --git a/lib/Transforms/Scalar/ScalarReplAggregates.cpp b/lib/Transforms/Scalar/ScalarReplAggregates.cpp index 1bc8a1e..db6500c 100644 --- a/lib/Transforms/Scalar/ScalarReplAggregates.cpp +++ b/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; diff --git a/test/Transforms/ScalarRepl/2009-05-08-I1Crash.ll b/test/Transforms/ScalarRepl/2009-05-08-I1Crash.ll new file mode 100644 index 0000000..0a604e9 --- /dev/null +++ b/test/Transforms/ScalarRepl/2009-05-08-I1Crash.ll @@ -0,0 +1,12 @@ +; RUN: llvm-as < %s | opt -scalarrepl | llvm-dis +; PR4146 + + %wrapper = type { i1 } + +define void @f() { +entry: + %w = alloca %wrapper, align 8 ; <%wrapper*> [#uses=1] + %0 = getelementptr %wrapper* %w, i64 0, i32 0 ; <i1*> + store i1 true, i1* %0 + ret void +} |