1; RUN: opt -S -simplifycfg < %s | FileCheck %s 2 3declare i32 @f(i32 %val) 4 5; Check that eliminating cases with unreachable branches keeps 6; prof branch_weights metadata consistent with switch instruction. 7define i32 @test_switch_to_unreachable(i32 %val) { 8; CHECK-LABEL: test_switch_to_unreachable 9; CHECK: switch 10; CHECK-NOT: i32 0, label %on0 11 switch i32 %val, label %otherwise [ 12 i32 0, label %on0 13 i32 1, label %on1 14 i32 2, label %on2 15 ], !prof !{!"branch_weights", i32 99, i32 0, i32 1, i32 2} 16; CHECK: !prof ![[MD0:[0-9]+]] 17 18otherwise: 19 %result = call i32 @f(i32 -1) 20 ret i32 %result 21 22on0: 23 unreachable 24 ret i32 125 25 26on1: 27 %result1 = call i32 @f(i32 -2) 28 ret i32 %result1 29 30on2: 31 %result2 = call i32 @f(i32 -3) 32 ret i32 %result2 33} 34 35; CHECK: ![[MD0]] = !{!"branch_weights", i32 99, i32 2, i32 1} 36