1 ; RUN: opt < %s -functionattrs -S | FileCheck %s
2 ; RUN: opt < %s -attributor -attributor-disable=false -attributor-max-iterations-verify -attributor-max-iterations=3 -S | FileCheck %s --check-prefix=ATTRIBUTOR
5 ; CHECK: Function Attrs: norecurse nounwind readnone
6 ; CHECK-NEXT: define i32 @foo1()
7 ; ATTRIBUTOR: Function Attrs: nofree nosync nounwind
8 ; ATTRIBUTOR-NEXT: define i32 @foo1()
14 ; CHECK: Function Attrs: nounwind readnone
15 ; CHECK-NEXT: define i32 @scc1_foo()
16 ; ATTRIBUTOR: Function Attrs: nofree noreturn nosync nounwind
17 ; ATTRIBUTOR-NEXT: define i32 @scc1_foo()
18 define i32 @scc1_foo() {
19 %1 = call i32 @scc1_bar()
25 ; CHECK: Function Attrs: nounwind readnone
26 ; CHECK-NEXT: define i32 @scc1_bar()
27 ; ATTRIBUTOR: Function Attrs: nofree noreturn nosync nounwind
28 ; ATTRIBUTOR-NEXT: define i32 @scc1_bar()
29 define i32 @scc1_bar() {
30 %1 = call i32 @scc1_foo()
34 ; CHECK: declare i32 @non_nounwind()
35 declare i32 @non_nounwind()
38 ; CHECK: define void @call_non_nounwind() {
39 ; ATTRIBUTOR: define void @call_non_nounwind() {
40 define void @call_non_nounwind(){
41 tail call i32 @non_nounwind()
46 ; int maybe_throw(bool canThrow) {
53 ; CHECK: define i32 @maybe_throw(i1 zeroext %0)
54 ; ATTRIBUTOR: define i32 @maybe_throw(i1 zeroext %0)
55 define i32 @maybe_throw(i1 zeroext %0) {
56 br i1 %0, label %2, label %3
59 tail call void @__cxa_rethrow() #1
66 declare void @__cxa_rethrow()
71 ; int a = doThing(true);
73 ; catch(...) { return -1; }
77 ; CHECK: define i32 @catch_thing()
78 ; ATTRIBUTOR: define i32 @catch_thing()
79 define i32 @catch_thing() personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
80 invoke void @__cxa_rethrow() #1
81 to label %1 unwind label %2
87 %3 = landingpad { i8*, i32 }
89 %4 = extractvalue { i8*, i32 } %3, 0
90 %5 = tail call i8* @__cxa_begin_catch(i8* %4) #2
91 tail call void @__cxa_end_catch()
95 define i32 @catch_thing_user() {
96 ; ATTRIBUTOR: define i32 @catch_thing_user
97 ; ATTRIBUTOR-NEXT: %catch_thing_call = call
98 ; ATTRIBUTOR-NEXT: ret i32 -1
99 %catch_thing_call = call i32 @catch_thing()
100 ret i32 %catch_thing_call
104 declare i32 @__gxx_personality_v0(...)
106 declare i8* @__cxa_begin_catch(i8*)
108 declare void @__cxa_end_catch()