Skip to content

Commit 611f5b8

Browse files
committed
[GVN] Add test for #116668 (NFC)
1 parent e98396f commit 611f5b8

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

llvm/test/Transforms/GVN/setjmp.ll

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
2+
; RUN: opt -S -passes=gvn < %s | FileCheck %s
3+
4+
declare i32 @setjmp() returns_twice
5+
declare void @longjmp()
6+
declare ptr @malloc(i64)
7+
8+
; FIXME: This is a miscompile.
9+
define i32 @test() {
10+
; CHECK-LABEL: define i32 @test() {
11+
; CHECK-NEXT: [[MALLOC:%.*]] = call noalias ptr @malloc(i64 4)
12+
; CHECK-NEXT: store i32 10, ptr [[MALLOC]], align 4
13+
; CHECK-NEXT: [[SJ:%.*]] = call i32 @setjmp()
14+
; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[SJ]], 0
15+
; CHECK-NEXT: br i1 [[CMP]], label %[[IF_THEN:.*]], label %[[IF_END:.*]]
16+
; CHECK: [[IF_THEN]]:
17+
; CHECK-NEXT: store i32 20, ptr [[MALLOC]], align 4
18+
; CHECK-NEXT: call void @longjmp()
19+
; CHECK-NEXT: unreachable
20+
; CHECK: [[IF_END]]:
21+
; CHECK-NEXT: ret i32 10
22+
;
23+
%malloc = call noalias ptr @malloc(i64 4)
24+
store i32 10, ptr %malloc, align 4
25+
%sj = call i32 @setjmp()
26+
%cmp = icmp eq i32 %sj, 0
27+
br i1 %cmp, label %if.then, label %if.end
28+
29+
if.then:
30+
store i32 20, ptr %malloc
31+
call void @longjmp()
32+
unreachable
33+
34+
if.end:
35+
%res = load i32, ptr %malloc
36+
ret i32 %res
37+
}

0 commit comments

Comments
 (0)