diff options
| author | Hans Wennborg <hans@hanshq.net> | 2019-04-16 12:13:25 +0000 |
|---|---|---|
| committer | Hans Wennborg <hans@hanshq.net> | 2019-04-16 12:13:25 +0000 |
| commit | 21eb771dcb5c11d7500fa6ad551c97a921997f05 (patch) | |
| tree | 31b8037fa1c516299cfa7152e3f774a804a3bb9b /llvm/test/Transforms | |
| parent | 7fe7e15b2cf4b5061d339432afcb1f1375a49c27 (diff) | |
| download | bcm5719-llvm-21eb771dcb5c11d7500fa6ad551c97a921997f05.tar.gz bcm5719-llvm-21eb771dcb5c11d7500fa6ad551c97a921997f05.zip | |
Re-commit r357452: SimplifyCFG SinkCommonCodeFromPredecessors: Also sink function calls without used results (PR41259)
The original commit caused false positives from AddressSanitizer's
use-after-scope checks, which have now been fixed in r358478.
> The code was previously checking that candidates for sinking had exactly
> one use or were a store instruction (which can't have uses). This meant
> we could sink call instructions only if they had a use.
>
> That limitation seemed a bit arbitrary, so this patch changes it to
> "instruction has zero or one use" which seems more natural and removes
> the need to special-case stores.
>
> Differential revision: https://reviews.llvm.org/D59936
llvm-svn: 358483
Diffstat (limited to 'llvm/test/Transforms')
| -rw-r--r-- | llvm/test/Transforms/SimplifyCFG/sink-common-code.ll | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/llvm/test/Transforms/SimplifyCFG/sink-common-code.ll b/llvm/test/Transforms/SimplifyCFG/sink-common-code.ll index 02c29bd3540..12a3e59cd37 100644 --- a/llvm/test/Transforms/SimplifyCFG/sink-common-code.ll +++ b/llvm/test/Transforms/SimplifyCFG/sink-common-code.ll @@ -843,6 +843,50 @@ if.end: ; CHECK: insertvalue ; CHECK-NOT: insertvalue + +declare void @baz(i32) + +define void @test_sink_void_calls(i32 %x) { +entry: + switch i32 %x, label %default [ + i32 0, label %bb0 + i32 1, label %bb1 + i32 2, label %bb2 + i32 3, label %bb3 + i32 4, label %bb4 + ] +bb0: + call void @baz(i32 12) + br label %return +bb1: + call void @baz(i32 34) + br label %return +bb2: + call void @baz(i32 56) + br label %return +bb3: + call void @baz(i32 78) + br label %return +bb4: + call void @baz(i32 90) + br label %return +default: + unreachable +return: + ret void + +; Check that the calls get sunk to the return block. +; We would previously not sink calls without uses, see PR41259. +; CHECK-LABEL: @test_sink_void_calls +; CHECK-NOT: call +; CHECK-LABEL: return: +; CHECK: phi +; CHECK: call +; CHECK-NOT: call +; CHECK: ret +} + + ; CHECK: ![[$TBAA]] = !{![[TYPE:[0-9]]], ![[TYPE]], i64 0} ; CHECK: ![[TYPE]] = !{!"float", ![[TEXT:[0-9]]]} ; CHECK: ![[TEXT]] = !{!"an example type tree"} |

