1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 19:12:56 +02:00

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
This commit is contained in:
Chris Lattner 2009-05-08 15:54:41 +00:00
parent 10038ab095
commit 0fd5aea274
2 changed files with 18 additions and 4 deletions

View File

@ -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;

View File

@ -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
}