llvm.org GIT mirror llvm / ef55484
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 Chris Lattner 10 years ago
2 changed file(s) with 18 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
902902
903903 // If this isn't a store of an integer to the whole alloca, it may be a store
904904 // to the first element. Just ignore the store in this case and normal SROA
905 // will handle it.
905 // will handle it. We don't handle types here that have tail padding, like
906 // an alloca of type {i1}.
906907 if (!isa(SrcVal->getType()) ||
907 TD->getTypePaddedSizeInBits(SrcVal->getType()) != AllocaSizeBits)
908 TD->getTypeSizeInBits(SrcVal->getType()) != AllocaSizeBits)
908909 return;
909910
910911 DOUT << "PROMOTING STORE TO WHOLE ALLOCA: " << *AI << *SI;
10141015
10151016 // If this isn't a load of the whole alloca to an integer, it may be a load
10161017 // of the first element. Just ignore the load in this case and normal SROA
1017 // will handle it.
1018 // will handle it. We don't handle types here that have tail padding, like
1019 // an alloca of type {i1}.
10181020 if (!isa(LI->getType()) ||
1019 TD->getTypePaddedSizeInBits(LI->getType()) != AllocaSizeBits)
1021 TD->getTypeSizeInBits(LI->getType()) != AllocaSizeBits)
10201022 return;
10211023
10221024 DOUT << "PROMOTING LOAD OF WHOLE ALLOCA: " << *AI << *LI;
0 ; RUN: llvm-as < %s | opt -scalarrepl | llvm-dis
1 ; PR4146
2
3 %wrapper = type { i1 }
4
5 define void @f() {
6 entry:
7 %w = alloca %wrapper, align 8 ; <%wrapper*> [#uses=1]
8 %0 = getelementptr %wrapper* %w, i64 0, i32 0 ;
9 store i1 true, i1* %0
10 ret void
11 }