summaryrefslogtreecommitdiff
path: root/test/Transforms/ScalarRepl
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-01-07 08:11:13 +0000
committerChris Lattner <sabre@nondot.org>2009-01-07 08:11:13 +0000
commitd2fa781169175b827e50953a1d0b7edc6b0c4801 (patch)
treec2421b82d9706cbc476aa1e887390ecbae0edfae /test/Transforms/ScalarRepl
parentd93afec1dbbb1abb3df55e2e007b5f256d09f84a (diff)
downloadllvm-d2fa781169175b827e50953a1d0b7edc6b0c4801.tar.gz
llvm-d2fa781169175b827e50953a1d0b7edc6b0c4801.tar.bz2
llvm-d2fa781169175b827e50953a1d0b7edc6b0c4801.tar.xz
Implement the first half of PR3290: if there is a store of an
integer to a (transitive) bitcast the alloca and if that integer has the full size of the alloca, then it clobbers the whole thing. Handle this by extracting pieces out of the stored integer and filing them away in the SROA'd elements. This triggers fairly frequently because the CFE uses integers to pass small structs by value and the inliner exposes these. For example, in kimwitu++, I see a bunch of these with i64 stores to "%struct.std::pair<std::_Rb_tree_const_iterator<kc::impl_abstract_phylum*>,bool>" In 176.gcc I see a few i32 stores to "%struct..0anon". In the testcase, this is a difference between compiling test1 to: _test1: subl $12, %esp movl 20(%esp), %eax movl %eax, 4(%esp) movl 16(%esp), %eax movl %eax, (%esp) movl (%esp), %eax addl 4(%esp), %eax addl $12, %esp ret vs: _test1: movl 8(%esp), %eax addl 4(%esp), %eax ret The second half of this will be to handle loads of the same form. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61853 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/ScalarRepl')
-rw-r--r--test/Transforms/ScalarRepl/copy-aggregate.ll31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/Transforms/ScalarRepl/copy-aggregate.ll b/test/Transforms/ScalarRepl/copy-aggregate.ll
new file mode 100644
index 0000000000..c3685d0930
--- /dev/null
+++ b/test/Transforms/ScalarRepl/copy-aggregate.ll
@@ -0,0 +1,31 @@
+; RUN: llvm-as < %s | opt -scalarrepl | llvm-dis | not grep alloca
+; PR3290
+
+;; Store of integer to whole alloca struct.
+define i32 @test1(i64 %V) nounwind {
+ %X = alloca {{i32, i32}}
+ %Y = bitcast {{i32,i32}}* %X to i64*
+ store i64 %V, i64* %Y
+
+ %A = getelementptr {{i32,i32}}* %X, i32 0, i32 0, i32 0
+ %B = getelementptr {{i32,i32}}* %X, i32 0, i32 0, i32 1
+ %a = load i32* %A
+ %b = load i32* %B
+ %c = add i32 %a, %b
+ ret i32 %c
+}
+
+;; Store of integer to whole struct/array alloca.
+define float @test2(i128 %V) nounwind {
+ %X = alloca {[4 x float]}
+ %Y = bitcast {[4 x float]}* %X to i128*
+ store i128 %V, i128* %Y
+
+ %A = getelementptr {[4 x float]}* %X, i32 0, i32 0, i32 0
+ %B = getelementptr {[4 x float]}* %X, i32 0, i32 0, i32 3
+ %a = load float* %A
+ %b = load float* %B
+ %c = add float %a, %b
+ ret float %c
+}
+