diff options
author | Chris Lattner <sabre@nondot.org> | 2008-02-18 06:12:38 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-02-18 06:12:38 +0000 |
commit | bf1d8a7099bb23e9dc92b56fe2564cbc2a71b063 (patch) | |
tree | 2088a996d29f56b54ce1f2ce592e3b2d61952304 /test | |
parent | 28cb2051c85f72a425c1fa595d10b175413416bb (diff) | |
download | external_llvm-bf1d8a7099bb23e9dc92b56fe2564cbc2a71b063.zip external_llvm-bf1d8a7099bb23e9dc92b56fe2564cbc2a71b063.tar.gz external_llvm-bf1d8a7099bb23e9dc92b56fe2564cbc2a71b063.tar.bz2 |
optimize away stackrestore calls that have no intervening alloca or call.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47258 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r-- | test/Transforms/InstCombine/stacksaverestore.ll | 43 |
1 files changed, 40 insertions, 3 deletions
diff --git a/test/Transforms/InstCombine/stacksaverestore.ll b/test/Transforms/InstCombine/stacksaverestore.ll index 29001a0..c82a425 100644 --- a/test/Transforms/InstCombine/stacksaverestore.ll +++ b/test/Transforms/InstCombine/stacksaverestore.ll @@ -1,4 +1,7 @@ -; RUN: llvm-as < %s | opt -instcombine | llvm-dis | not grep {call.*stackrestore} +; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep {call.*stackrestore} | count 1 + +declare i8* @llvm.stacksave() +declare void @llvm.stackrestore(i8*) ;; Test that llvm.stackrestore is removed when possible. define i32* @test1(i32 %P) { @@ -13,7 +16,41 @@ define void @test2(i8* %X) { ret void } -declare i8* @llvm.stacksave() +define void @foo(i32 %size) nounwind { +entry: + %tmp118124 = icmp sgt i32 %size, 0 ; <i1> [#uses=1] + br i1 %tmp118124, label %bb.preheader, label %return -declare void @llvm.stackrestore(i8*) +bb.preheader: ; preds = %entry + %tmp25 = add i32 %size, -1 ; <i32> [#uses=1] + %tmp125 = icmp slt i32 %size, 1 ; <i1> [#uses=1] + %smax = select i1 %tmp125, i32 1, i32 %size ; <i32> [#uses=1] + br label %bb + +bb: ; preds = %bb, %bb.preheader + %i.0.reg2mem.0 = phi i32 [ 0, %bb.preheader ], [ %indvar.next, %bb ] ; <i32> [#uses=2] + %tmp = call i8* @llvm.stacksave( ) ; <i8*> [#uses=1] + %tmp23 = alloca i8, i32 %size ; <i8*> [#uses=2] + %tmp27 = getelementptr i8* %tmp23, i32 %tmp25 ; <i8*> [#uses=1] + store i8 0, i8* %tmp27, align 1 + %tmp28 = call i8* @llvm.stacksave( ) ; <i8*> [#uses=1] + %tmp52 = alloca i8, i32 %size ; <i8*> [#uses=1] + %tmp53 = call i8* @llvm.stacksave( ) ; <i8*> [#uses=1] + %tmp77 = alloca i8, i32 %size ; <i8*> [#uses=1] + %tmp78 = call i8* @llvm.stacksave( ) ; <i8*> [#uses=1] + %tmp102 = alloca i8, i32 %size ; <i8*> [#uses=1] + call void @bar( i32 %i.0.reg2mem.0, i8* %tmp23, i8* %tmp52, i8* %tmp77, i8* %tmp102, i32 %size ) nounwind + call void @llvm.stackrestore( i8* %tmp78 ) + call void @llvm.stackrestore( i8* %tmp53 ) + call void @llvm.stackrestore( i8* %tmp28 ) + call void @llvm.stackrestore( i8* %tmp ) + %indvar.next = add i32 %i.0.reg2mem.0, 1 ; <i32> [#uses=2] + %exitcond = icmp eq i32 %indvar.next, %smax ; <i1> [#uses=1] + br i1 %exitcond, label %return, label %bb + +return: ; preds = %bb, %entry + ret void +} + +declare void @bar(i32, i8*, i8*, i8*, i8*, i32) |