diff options
author | Nick Lewycky <nicholas@mxc.ca> | 2012-01-20 08:35:20 +0000 |
---|---|---|
committer | Nick Lewycky <nicholas@mxc.ca> | 2012-01-20 08:35:20 +0000 |
commit | 38b6d9dd22e3989d8d9a1b9916df13b7976a0a85 (patch) | |
tree | 69a1b9827c98d2772f895aef1f7ea3ae11a19900 /test | |
parent | b5c26ef9da16052597d59a412eaae32098aa1be0 (diff) | |
download | external_llvm-38b6d9dd22e3989d8d9a1b9916df13b7976a0a85.zip external_llvm-38b6d9dd22e3989d8d9a1b9916df13b7976a0a85.tar.gz external_llvm-38b6d9dd22e3989d8d9a1b9916df13b7976a0a85.tar.bz2 |
Fix CountCodeReductionForAlloca to more accurately represent what SROA can and
can't handle. Also don't produce non-zero results for things which won't be
transformed by SROA at all just because we saw the loads/stores before we saw
the use of the address.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148536 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r-- | test/Transforms/Inline/alloca-bonus.ll | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/test/Transforms/Inline/alloca-bonus.ll b/test/Transforms/Inline/alloca-bonus.ll new file mode 100644 index 0000000..2587ae1 --- /dev/null +++ b/test/Transforms/Inline/alloca-bonus.ll @@ -0,0 +1,44 @@ +; RUN: opt -inline < %s -S -o - -inline-threshold=8 | FileCheck %s + +declare void @llvm.lifetime.start(i64 %size, i8* nocapture %ptr) + +@glbl = external global i32 + +define void @outer1() { +; CHECK: @outer1 +; CHECK-NOT: call void @inner1 + %ptr = alloca i32 + call void @inner1(i32* %ptr) + ret void +} + +define void @inner1(i32 *%ptr) { + %A = load i32* %ptr + store i32 0, i32* %ptr + %C = getelementptr i32* %ptr, i32 0 + %D = getelementptr i32* %ptr, i32 1 + %E = bitcast i32* %ptr to i8* + %F = select i1 false, i32* %ptr, i32* @glbl + call void @llvm.lifetime.start(i64 0, i8* %E) + ret void +} + +define void @outer2() { +; CHECK: @outer2 +; CHECK: call void @inner2 + %ptr = alloca i32 + call void @inner2(i32* %ptr) + ret void +} + +; %D poisons this call, scalar-repl can't handle that instruction. +define void @inner2(i32 *%ptr) { + %A = load i32* %ptr + store i32 0, i32* %ptr + %C = getelementptr i32* %ptr, i32 0 + %D = getelementptr i32* %ptr, i32 %A + %E = bitcast i32* %ptr to i8* + %F = select i1 false, i32* %ptr, i32* @glbl + call void @llvm.lifetime.start(i64 0, i8* %E) + ret void +} |