Skip to content

Commit 08d4a50

Browse files
committed
[FunctionAttrs] Precommit tests for willreturn inference.
Tests for D94502.
1 parent a14040b commit 08d4a50

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
; RUN: opt -function-attrs -S %s | FileCheck %s
2+
3+
; TODO
4+
define void @mustprogress_readnone() mustprogress {
5+
; CHECK-NOT: Function Attrs: {{.*}} willreturn
6+
; CHECK: define void @mustprogress_readnone()
7+
;
8+
entry:
9+
br label %while.body
10+
11+
while.body:
12+
br label %while.body
13+
}
14+
15+
; TODO
16+
define i32 @mustprogress_load(i32* %ptr) mustprogress {
17+
; CHECK-NOT: Function Attrs: {{.*}} willreturn
18+
; CHECK: define i32 @mustprogress_load(
19+
;
20+
entry:
21+
%r = load i32, i32* %ptr
22+
ret i32 %r
23+
}
24+
25+
define void @mustprogress_store(i32* %ptr) mustprogress {
26+
; CHECK-NOT: Function Attrs: {{.*}} willreturn
27+
; CHECK: define void @mustprogress_store(
28+
;
29+
entry:
30+
store i32 0, i32* %ptr
31+
ret void
32+
}
33+
34+
declare void @unknown_fn()
35+
36+
define void @mustprogress_call_unknown_fn() mustprogress {
37+
; CHECK-NOT: Function Attrs: {{.*}} willreturn
38+
; CHECK: define void @mustprogress_call_unknown_fn(
39+
;
40+
call void @unknown_fn()
41+
ret void
42+
}
43+
44+
; TODO
45+
define i32 @mustprogress_call_known_functions(i32* %ptr) mustprogress {
46+
; CHECK-NOT: Function Attrs: {{.*}} willreturn
47+
; CHECK: define i32 @mustprogress_call_known_functions(
48+
;
49+
call void @mustprogress_readnone()
50+
%r = call i32 @mustprogress_load(i32* %ptr)
51+
ret i32 %r
52+
}
53+
54+
declare i32 @__gxx_personality_v0(...)
55+
56+
; TODO
57+
define i64 @mustprogress_mayunwind() mustprogress personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
58+
; CHECK-NOT: Function Attrs: {{.*}} willreturn
59+
; CHECK: define i64 @mustprogress_mayunwind(
60+
;
61+
%a = invoke i64 @fn_noread()
62+
to label %A unwind label %B
63+
A:
64+
ret i64 10
65+
66+
B:
67+
%val = landingpad { i8*, i32 }
68+
catch i8* null
69+
ret i64 0
70+
}
71+
72+
declare i64 @fn_noread() readnone

0 commit comments

Comments
 (0)