Skip to content

Commit c42fcdd

Browse files
committed
[SimplifyCFG] Add pre-commit test for the miscompilation report
1 parent 3d41567 commit c42fcdd

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

llvm/test/Transforms/SimplifyCFG/switch-on-const.ll

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,32 @@ default:
280280
ret void
281281
}
282282

283+
@G = constant i16 zeroinitializer, align 1
284+
285+
; Make sure we don't remove edges when the condition is a unresolved constant expression.
286+
287+
define i16 @switch_on_nonimmediate_constant_expr() {
288+
; CHECK-LABEL: @switch_on_nonimmediate_constant_expr(
289+
; CHECK-NEXT: entry:
290+
; CHECK-NEXT: ret i16 789
291+
;
292+
entry:
293+
switch i32 ptrtoint (ptr @G to i32), label %sw.default [
294+
i32 1, label %sw.bb
295+
i32 2, label %sw.bb1
296+
]
297+
298+
sw.bb:
299+
ret i16 123
300+
301+
sw.bb1:
302+
ret i16 456
303+
304+
sw.default:
305+
ret i16 789
306+
}
307+
308+
283309
declare void @llvm.trap() nounwind noreturn
284310
declare void @bees.a() nounwind
285311
declare void @bees.b() nounwind

0 commit comments

Comments
 (0)