diff options
author | Yevgeny Rouban <yevgeny.rouban@azul.com> | 2019-06-17 05:55:12 +0000 |
---|---|---|
committer | Yevgeny Rouban <yevgeny.rouban@azul.com> | 2019-06-17 05:55:12 +0000 |
commit | ee62c40eae93c180d29e94841fbeb280ee737d26 (patch) | |
tree | fdbbcb0883b4bdaabddb64c70309b9f0e8f46c96 /llvm/test/Transforms/SimplifyCFG | |
parent | 1d1cf30b738b88a58919221cc419109ba9519a61 (diff) | |
download | bcm5719-llvm-ee62c40eae93c180d29e94841fbeb280ee737d26.tar.gz bcm5719-llvm-ee62c40eae93c180d29e94841fbeb280ee737d26.zip |
[SimplifyCFG] Fix prof branch_weights MD while removing unreachable switch cases
SimplifyCFG has a bug that results in inconsistent prof branch_weights metadata
if unreachable switch cases are removed. This patch fixes this bug by making use
of the newly introduced SwitchInstProfUpdateWrapper class (see patch D62122).
A new test is created.
Differential Revision: https://reviews.llvm.org/D62186
llvm-svn: 363527
Diffstat (limited to 'llvm/test/Transforms/SimplifyCFG')
-rw-r--r-- | llvm/test/Transforms/SimplifyCFG/switch-profmd.ll | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/llvm/test/Transforms/SimplifyCFG/switch-profmd.ll b/llvm/test/Transforms/SimplifyCFG/switch-profmd.ll new file mode 100644 index 00000000000..c17214e18f2 --- /dev/null +++ b/llvm/test/Transforms/SimplifyCFG/switch-profmd.ll @@ -0,0 +1,35 @@ +; RUN: opt -S -simplifycfg < %s | FileCheck %s + +declare i32 @f(i32 %val) + +; Check that eliminating cases with unreachable branches keeps +; prof branch_weights metadata consistent with switch instruction. +define i32 @test_switch_to_unreachable(i32 %val) { +; CHECK-LABEL: test_switch_to_unreachable +; CHECK: switch +; CHECK-NOT: i32 0, label %on0 + switch i32 %val, label %otherwise [ + i32 0, label %on0 + i32 1, label %on1 + i32 2, label %on2 + ], !prof !{!"branch_weights", i32 99, i32 0, i32 1, i32 2} +; CHECK: !prof ![[MD0:[0-9]+]] + +otherwise: + %result = call i32 @f(i32 -1) + ret i32 %result + +on0: + unreachable + ret i32 125 + +on1: + %result1 = call i32 @f(i32 -2) + ret i32 %result1 + +on2: + %result2 = call i32 @f(i32 -3) + ret i32 %result2 +} + +; CHECK: ![[MD0]] = !{!"branch_weights", i32 99, i32 2, i32 1} |