50 lines · plain
1; RUN: opt -S -passes=inline %s -debug-only=inline-cost 2>&1 | FileCheck %s2; REQUIRES: asserts3 4@a = global i32 45 6; Only the load and ret should be included in the instruction count, not7; the instructions feeding the assume.8; CHECK: Analyzing call of inner...9; CHECK: NumInstructions: 210define i32 @inner(ptr %y) {11 %a1 = load volatile i32, ptr @a12 13 ; Because these instructions are used only by the @llvm.assume intrinsic,14 ; they're free and should not be included in the instruction count when15 ; computing the inline cost.16 %a2 = mul i32 %a1, %a117 %a3 = sub i32 %a1, %a218 %a4 = udiv i32 %a3, -1319 %a5 = mul i32 %a4, %a420 %a6 = add i32 %a5, %a521 %ca = icmp sgt i32 %a6, -722 %r = call i1 @llvm.type.test(ptr %y, metadata !0)23 %ca2 = icmp eq i1 %ca, %r24 tail call void @llvm.assume(i1 %ca2)25 26 ret i32 %a127}28 29; Only the ret should be included in the instruction count, the load and icmp30; are both ephemeral.31; CHECK: Analyzing call of inner2...32; CHECK: NumInstructions: 133define void @inner2(ptr %y) {34 %v = load i8, ptr %y35 %c = icmp eq i8 %v, 4236 call void @llvm.assume(i1 %c)37 ret void38}39 40define i32 @outer(ptr %y) optsize {41 %r = call i32 @inner(ptr %y)42 call void @inner2(ptr %y)43 ret i32 %r44}45 46declare void @llvm.assume(i1) nounwind47declare i1 @llvm.type.test(ptr, metadata) nounwind readnone48 49!0 = !{i32 0, !"typeid1"}50