1; RUN: opt < %s -inline -S | FileCheck %s 2; RUN: opt < %s --passes=inline -S | FileCheck %s 3 4; Test that functions with attribute optnone are not inlined. 5; Also test that only functions with attribute alwaysinline are 6; valid candidates for inlining if the caller has the optnone attribute. 7 8; Function Attrs: alwaysinline nounwind readnone uwtable 9define i32 @alwaysInlineFunction(i32 %a) #0 { 10entry: 11 %mul = mul i32 %a, %a 12 ret i32 %mul 13} 14 15; Function Attrs: nounwind readnone uwtable 16define i32 @simpleFunction(i32 %a) #1 { 17entry: 18 %add = add i32 %a, %a 19 ret i32 %add 20} 21 22; Function Attrs: nounwind noinline optnone readnone uwtable 23define i32 @OptnoneFunction(i32 %a) #2 { 24entry: 25 %0 = tail call i32 @alwaysInlineFunction(i32 %a) 26 %1 = tail call i32 @simpleFunction(i32 %a) 27 %add = add i32 %0, %1 28 ret i32 %add 29} 30 31; CHECK-LABEL: @OptnoneFunction 32; CHECK-NOT: call i32 @alwaysInlineFunction(i32 %a) 33; CHECK: call i32 @simpleFunction(i32 %a) 34; CHECK: ret 35 36; Function Attrs: nounwind readnone uwtable 37define i32 @bar(i32 %a) #1 { 38entry: 39 %0 = tail call i32 @OptnoneFunction(i32 5) 40 %1 = tail call i32 @simpleFunction(i32 6) 41 %add = add i32 %0, %1 42 ret i32 %add 43} 44 45; CHECK-LABEL: @bar 46; CHECK: call i32 @OptnoneFunction(i32 5) 47; CHECK-NOT: call i32 @simpleFunction(i32 6) 48; CHECK: ret 49 50 51attributes #0 = { alwaysinline nounwind readnone uwtable } 52attributes #1 = { nounwind readnone uwtable } 53attributes #2 = { nounwind noinline optnone readnone uwtable } 54