1 ; RUN: opt -passes=attributor-cgscc -attributor-annotate-decl-cs -attributor-allow-shallow-wrappers -S < %s | FileCheck %s --check-prefix=CHECK
3 ; TEST 1: simple test, without argument
4 ; A wrapper will be generated for this function, Check the wrapper first
5 ; CHECK-NOT: Function Attrs:
6 ; CHECK: define linkonce i32 @inner1()
7 ; CHECK: tail call i32 @0()
10 ; Check the original function, which is wrapped and becomes anonymous
11 ; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
12 ; CHECK: define internal noundef i32 @0()
14 define linkonce i32 @inner1() {
23 ; CHECK: define i32 @outer1
24 ; CHECK: call i32 @inner1
26 define i32 @outer1() {
28 %ret = call i32 @inner1()
32 ; TEST 2: with argument
33 ; CHECK-NOT: Function Attrs
34 ; CHECK: define linkonce i32 @inner2(i32 %a, i32 %b)
35 ; CHECK: tail call i32 @1(i32 %a, i32 %b)
38 ; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
39 ; CHECK: define internal i32 @1(i32 %a, i32 %b)
40 ; CHECK: %c = add i32 %a, %b
42 define linkonce i32 @inner2(i32 %a, i32 %b) {
48 ; CHECK: define i32 @outer2
49 ; CHECK: call i32 @inner2
51 define i32 @outer2() {
53 %ret = call i32 @inner2(i32 1, i32 2)
57 ; TEST 3: check nocurse
58 ; This function calls itself, there will be no attribute
59 ; CHECK-NOT: Function Attrs
60 ; CHECK: define linkonce i32 @inner3(i32 %0)
61 ; CHECK: tail call i32 @2(i32 %0)
64 ; CHECK-NOT: Function Attrs:
65 ; CHECK: define internal i32 @2(i32 %0)
66 define linkonce i32 @inner3(i32) {
73 %4 = icmp slt i32 %3, 4
74 br i1 %4, label %5, label %9
77 %7 = add nsw i32 %6, 1
78 %8 = call i32 @inner3(i32 %7)
82 %10 = load i32, ptr %1