diff options
author | Chris Lattner <sabre@nondot.org> | 2011-02-18 04:43:06 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2011-02-18 04:43:06 +0000 |
commit | 78f7a25f9826ba66610b5bca83ebea71793abf59 (patch) | |
tree | a081b6180cddd66932f73da6dc34fc673193a5f0 /test/Transforms/JumpThreading/indirectbr.ll | |
parent | 13fb0db0c26ec498cf8ffb0f9943d28962d4ced7 (diff) | |
download | external_llvm-78f7a25f9826ba66610b5bca83ebea71793abf59.zip external_llvm-78f7a25f9826ba66610b5bca83ebea71793abf59.tar.gz external_llvm-78f7a25f9826ba66610b5bca83ebea71793abf59.tar.bz2 |
prevent jump threading from merging blocks when their address is
taken (and used!). This prevents merging the blocks (invalidating
the block addresses) in a case like this:
#define _THIS_IP_ ({ __label__ __here; __here: (unsigned long)&&__here; })
void foo() {
printf("%p\n", _THIS_IP_);
printf("%p\n", _THIS_IP_);
printf("%p\n", _THIS_IP_);
}
which fixes PR4151.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125829 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/JumpThreading/indirectbr.ll')
-rw-r--r-- | test/Transforms/JumpThreading/indirectbr.ll | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/test/Transforms/JumpThreading/indirectbr.ll b/test/Transforms/JumpThreading/indirectbr.ll index 6c5321d..141277f 100644 --- a/test/Transforms/JumpThreading/indirectbr.ll +++ b/test/Transforms/JumpThreading/indirectbr.ll @@ -44,7 +44,9 @@ indirectgoto: ; preds = %if.else, %entry ; Check constant folding of indirectbr ; CHECK: void @test2 -; CHECK-NEXT: : +; CHECK: entry: +; CHECK-NEXT: br label %L1 +; CHECK: L1: ; CHECK-NEXT: call void @bar ; CHECK-NEXT: ret void define void @test2() nounwind { @@ -59,3 +61,34 @@ L2: ; preds = %indirectgoto call void @baz() ret void } + + +; PR4151 +; Don't merge address-taken blocks. +@.str = private unnamed_addr constant [4 x i8] c"%p\0A\00" + +; CHECK: @test3 +; CHECK: __here: +; CHECK: blockaddress(@test3, %__here) +; CHECK: __here1: +; CHECK: blockaddress(@test3, %__here1) +; CHECK: __here3: +; CHECK: blockaddress(@test3, %__here3) +define void @test3() nounwind ssp noredzone { +entry: + br label %__here + +__here: ; preds = %entry + %call = call i32 (...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i64 0, i64 0), i64 ptrtoint (i8* blockaddress(@test3, %__here) to i64)) nounwind noredzone + br label %__here1 + +__here1: ; preds = %__here + %call2 = call i32 (...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i64 0, i64 0), i64 ptrtoint (i8* blockaddress(@test3, %__here1) to i64)) nounwind noredzone + br label %__here3 + +__here3: ; preds = %__here1 + %call4 = call i32 (...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i64 0, i64 0), i64 ptrtoint (i8* blockaddress(@test3, %__here3) to i64)) nounwind noredzone + ret void +} + +declare i32 @printf(...) noredzone |