1; RUN: opt -passes=attributor-cgscc -attributor-annotate-decl-cs -attributor-allow-shallow-wrappers -S < %s | FileCheck %s --check-prefix=CHECK 2 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() 8; CHECK: ret 9; 10; Check the original function, which is wrapped and becomes anonymous 11; CHECK: Function Attrs: nofree norecurse nosync nounwind readnone willreturn 12; CHECK: define internal i32 @0() 13; CHECK: %a = alloca i32 14; CHECK: store i32 1, i32* %a 15; CHECK: %b = load i32, i32* %a 16; CHECK: ret i32 %b 17define linkonce i32 @inner1() { 18entry: 19 %a = alloca i32 20 store i32 1, i32* %a 21 %b = load i32, i32* %a 22 ret i32 %b 23} 24 25; Check for call 26; CHECK: define i32 @outer1 27; CHECK: call i32 @inner1 28; CHECK: ret 29define i32 @outer1() { 30entry: 31 %ret = call i32 @inner1() 32 ret i32 %ret 33} 34 35; TEST 2: with argument 36; CHECK-NOT: Function Attrs 37; CHECK: define linkonce i32 @inner2(i32 %a, i32 %b) 38; CHECK: tail call i32 @1(i32 %a, i32 %b) 39; CHECK: ret 40; 41; CHECK: Function Attrs: nofree norecurse nosync nounwind readnone willreturn 42; CHECK: define internal i32 @1(i32 %a, i32 %b) 43; CHECK: %c = add i32 %a, %b 44; CHECK: ret i32 %c 45define linkonce i32 @inner2(i32 %a, i32 %b) { 46entry: 47 %c = add i32 %a, %b 48 ret i32 %c 49} 50 51; CHECK: define i32 @outer2 52; CHECK: call i32 @inner2 53; CHECK: ret 54define i32 @outer2() { 55entry: 56 %ret = call i32 @inner2(i32 1, i32 2) 57 ret i32 %ret 58} 59 60; TEST 3: check nocurse 61; This function calls itself, there will be no attribute 62; CHECK-NOT: Function Attrs 63; CHECK: define linkonce i32 @inner3(i32 %0) 64; CHECK: tail call i32 @2(i32 %0) 65; CHECK: ret 66; 67; CHECK-NOT: Function Attrs: 68; CHECK: define internal i32 @2(i32 %0) 69define linkonce i32 @inner3(i32) { 70entry: 71 %1 = alloca i32 72 store i32 %0, i32* %1 73 br label %2 742: 75 %3 = load i32, i32* %1 76 %4 = icmp slt i32 %3, 4 77 br i1 %4, label %5, label %9 785: 79 %6 = load i32, i32* %1 80 %7 = add nsw i32 %6, 1 81 %8 = call i32 @inner3(i32 %7) 82 store i32 %8, i32* %1 83 br label %2 849: 85 %10 = load i32, i32* %1 86 ret i32 %10 87} 88 89