86 lines · plain
1; RUN: opt -passes=attributor-cgscc -attributor-annotate-decl-cs -attributor-allow-shallow-wrappers -S < %s | FileCheck %s --check-prefix=CHECK2 3; TEST 1: simple test, without argument4; A wrapper will be generated for this function, Check the wrapper first5; CHECK-NOT: Function Attrs:6; CHECK: define linkonce i32 @inner1()7; CHECK: tail call i32 @0()8; CHECK: ret9;10; Check the original function, which is wrapped and becomes anonymous11; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)12; CHECK: define internal noundef i32 @0()13; CHECK: ret i32 114define linkonce i32 @inner1() {15entry:16 %a = alloca i3217 store i32 1, ptr %a18 %b = load i32, ptr %a19 ret i32 %b20}21 22; Check for call23; CHECK: define i32 @outer124; CHECK: call i32 @inner125; CHECK: ret26define i32 @outer1() {27entry:28 %ret = call i32 @inner1()29 ret i32 %ret30}31 32; TEST 2: with argument33; CHECK-NOT: Function Attrs34; CHECK: define linkonce i32 @inner2(i32 %a, i32 %b)35; CHECK: tail call i32 @1(i32 %a, i32 %b)36; CHECK: ret37;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, %b41; CHECK: ret i32 %c42define linkonce i32 @inner2(i32 %a, i32 %b) {43entry:44 %c = add i32 %a, %b45 ret i32 %c46}47 48; CHECK: define i32 @outer249; CHECK: call i32 @inner250; CHECK: ret51define i32 @outer2() {52entry:53 %ret = call i32 @inner2(i32 1, i32 2)54 ret i32 %ret55}56 57; TEST 3: check nocurse58; This function calls itself, there will be no attribute59; CHECK-NOT: Function Attrs60; CHECK: define linkonce i32 @inner3(i32 %0)61; CHECK: tail call i32 @2(i32 %0)62; CHECK: ret63;64; CHECK-NOT: Function Attrs:65; CHECK: define internal i32 @2(i32 %0)66define linkonce i32 @inner3(i32) {67entry:68 %1 = alloca i3269 store i32 %0, ptr %170 br label %2712:72 %3 = load i32, ptr %173 %4 = icmp slt i32 %3, 474 br i1 %4, label %5, label %9755:76 %6 = load i32, ptr %177 %7 = add nsw i32 %6, 178 %8 = call i32 @inner3(i32 %7)79 store i32 %8, ptr %180 br label %2819:82 %10 = load i32, ptr %183 ret i32 %1084}85 86