diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2012-10-04 16:11:49 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2012-10-04 16:11:49 +0000 |
commit | 1e21db6e831923bb35d2c5e22b50ad198de49a61 (patch) | |
tree | 253053dc74e2c5ae2589dd1f211e0faf8824b897 /test/Transforms/SimplifyCFG/phi-undef-loadstore.ll | |
parent | 7508f946bc4b5022cc4612c8c7492f2e23043976 (diff) | |
download | external_llvm-1e21db6e831923bb35d2c5e22b50ad198de49a61.zip external_llvm-1e21db6e831923bb35d2c5e22b50ad198de49a61.tar.gz external_llvm-1e21db6e831923bb35d2c5e22b50ad198de49a61.tar.bz2 |
SimplifyCFG: Enhance the "remove CFG edge that leads to null pointer dereference" optimization to also handle instructions with multiple uses.
We conservatively only check the first use to avoid walking long use chains.
This catches the common case of having both a load and a store to a pointer
supplied by a PHI node.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165232 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/SimplifyCFG/phi-undef-loadstore.ll')
-rw-r--r-- | test/Transforms/SimplifyCFG/phi-undef-loadstore.ll | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/test/Transforms/SimplifyCFG/phi-undef-loadstore.ll b/test/Transforms/SimplifyCFG/phi-undef-loadstore.ll index 65d888e..028fb07 100644 --- a/test/Transforms/SimplifyCFG/phi-undef-loadstore.ll +++ b/test/Transforms/SimplifyCFG/phi-undef-loadstore.ll @@ -85,3 +85,31 @@ if.end7: ; preds = %if.else, %if.then4, ; CHECK: if.end7: ; CHECK: phi i32* [ %a, %if.then ], [ null, %if.then4 ], [ null, %if.else ] } + +define i32 @test4(i32* %a, i32 %b, i32* %c, i32 %d) nounwind { +entry: + %tobool = icmp eq i32 %b, 0 + br i1 %tobool, label %if.else, label %if.then + +if.then: ; preds = %entry + tail call void @bar() nounwind + br label %if.end7 + +if.else: ; preds = %entry + %tobool3 = icmp eq i32 %d, 0 + br i1 %tobool3, label %if.end7, label %if.then4 + +if.then4: ; preds = %if.else + tail call void @bar() nounwind + br label %if.end7 + +if.end7: ; preds = %if.else, %if.then4, %if.then + %x.0 = phi i32* [ %a, %if.then ], [ null, %if.then4 ], [ null, %if.else ] + %gep = getelementptr i32* %x.0, i32 10 + %tmp9 = load i32* %gep + %tmp10 = or i32 %tmp9, 1 + store i32 %tmp10, i32* %gep + ret i32 %tmp9 +; CHECK: @test4 +; CHECK-NOT: phi +} |