97 lines · plain
1; RUN: opt -S -passes='cgscc(inline,instcombine)' < %s | FileCheck %s2; RUN: opt -S -intra-scc-cost-multiplier=3 -passes='cgscc(inline,instcombine)' < %s | FileCheck %s --check-prefix=THREE3 4; We use call to a dummy function to avoid inlining test1 into test2 or vice5; versa, such that we aren't left with a trivial cycle, as trivial cycles are6; special-cased to never be inlined.7; However, InstCombine will eliminate these calls after inlining, and thus8; make the functions eligible for inlining in their callers.9declare void @dummy() readnone nounwind willreturn10 11define void @test1() {12; CHECK-LABEL: define void @test1(13; CHECK-NEXT: call void @test2()14; CHECK-NEXT: call void @test2()15; CHECK-NEXT: ret void16;17 call void @test2()18 call void @test2()19 call void @dummy()20 call void @dummy()21 call void @dummy()22 call void @dummy()23 call void @dummy()24 call void @dummy()25 call void @dummy()26 call void @dummy()27 call void @dummy()28 call void @dummy()29 call void @dummy()30 ret void31}32 33define void @test2() {34; CHECK-LABEL: define void @test2(35; CHECK-NEXT: call void @test3()36; CHECK-NEXT: call void @test3()37; CHECK-NEXT: ret void38;39 call void @test3() noinline40 call void @test3() noinline41 call void @dummy()42 call void @dummy()43 call void @dummy()44 call void @dummy()45 call void @dummy()46 call void @dummy()47 call void @dummy()48 call void @dummy()49 call void @dummy()50 call void @dummy()51 call void @dummy()52 ret void53}54 55define void @test3() {56; CHECK-LABEL: define void @test3(57; CHECK-NEXT: call void @test1()58; CHECK-NEXT: call void @test1()59; CHECK-NEXT: ret void60;61 call void @test1()62 call void @test1()63 call void @dummy()64 call void @dummy()65 call void @dummy()66 call void @dummy()67 call void @dummy()68 call void @dummy()69 call void @dummy()70 call void @dummy()71 call void @dummy()72 call void @dummy()73 call void @dummy()74 ret void75}76 77; The inlined call sites should have the "function-inline-cost-multiplier" call site attribute.78define void @f() {79; CHECK-LABEL: define void @f(80; CHECK-NEXT: call void @test3() #[[COSTMULT:[0-9]+]]81; CHECK-NEXT: call void @test3() #[[COSTMULT]]82; CHECK-NEXT: call void @test3() #[[COSTMULT]]83; CHECK-NEXT: call void @test3() #[[COSTMULT]]84; CHECK-NEXT: call void @test3() #[[COSTMULT]]85; CHECK-NEXT: call void @test3() #[[COSTMULT]]86; CHECK-NEXT: call void @test3() #[[COSTMULT]]87; CHECK-NEXT: call void @test3() #[[COSTMULT]]88; CHECK-NEXT: ret void89;90 call void @test1()91 call void @test1()92 ret void93}94 95; CHECK: [[COSTMULT]] = { noinline "function-inline-cost-multiplier"="4" }96; THREE: "function-inline-cost-multiplier"="9"97