154 lines · plain
1; Test the profile summary for context sensitive PGO (CSPGO)2 3; RUN: llvm-profdata merge %S/Inputs/cspgo.proftext -o %t.profdata4; RUN: opt < %s -passes='default<O2>' -disable-preinline -pgo-instrument-entry=false -pgo-kind=pgo-instr-use-pipeline -profile-file=%t.profdata -S | FileCheck %s --check-prefix=PGOSUMMARY5; RUN: opt < %s -O2 -disable-preinline -pgo-instrument-entry=false -pgo-kind=pgo-instr-use-pipeline -profile-file=%t.profdata -S | FileCheck %s --check-prefix=PGOSUMMARY6; RUN: opt < %s -O2 -disable-preinline -pgo-instrument-entry=false -pgo-kind=pgo-instr-use-pipeline -profile-file=%t.profdata -S -cspgo-kind=cspgo-instr-use-pipeline| FileCheck %s --check-prefix=CSPGOSUMMARY7 8target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"9target triple = "x86_64-unknown-linux-gnu"10 11@odd = common dso_local global i32 0, align 412@even = common dso_local global i32 0, align 413@not_six = common dso_local global i32 0, align 414 15define dso_local i32 @goo(i32 %n) {16entry:17 %i = alloca i32, align 418 store volatile i32 %n, ptr %i, align 419 %i.0. = load volatile i32, ptr %i, align 420 ret i32 %i.0.21}22 23define dso_local void @bar(i32 %n) {24entry:25 %call = call fastcc i32 @cond(i32 %n)26 %tobool = icmp eq i32 %call, 027 br i1 %tobool, label %if.else, label %if.then28 29if.then:30 %0 = load i32, ptr @odd, align 431 %inc = add i32 %0, 132 store i32 %inc, ptr @odd, align 433 br label %if.end34 35if.else:36 %1 = load i32, ptr @even, align 437 %inc1 = add i32 %1, 138 store i32 %inc1, ptr @even, align 439 br label %if.end40 41if.end:42 br label %for.cond43 44for.cond:45 %i.0 = phi i32 [ 0, %if.end ], [ %inc6, %for.inc ]46 %cmp = icmp ult i32 %i.0, 447 br i1 %cmp, label %for.body, label %for.end48 49for.body:50 %mul = mul nsw i32 %i.0, %n51 %rem = srem i32 %mul, 652 %tobool2 = icmp eq i32 %rem, 053 br i1 %tobool2, label %for.inc, label %if.then354 55if.then3:56 %2 = load i32, ptr @not_six, align 457 %inc4 = add i32 %2, 158 store i32 %inc4, ptr @not_six, align 459 br label %for.inc60 61for.inc:62 %inc6 = add nuw nsw i32 %i.0, 163 br label %for.cond64 65for.end:66 ret void67}68; PGOSUMMARY-LABEL: @bar69; PGOSUMMARY: %even.odd = select i1 %tobool{{[0-9]*}}, ptr @even, ptr @odd70; PGOSUMMARY-SAME: !prof ![[BW_PGO_BAR:[0-9]+]]71; CSPGOSUMMARY-LABEL: @bar72; CSPGOSUMMARY: %even.odd = select i1 %tobool{{[0-9]*}}, ptr @even, ptr @odd73; CSPGOSUMMARY-SAME: !prof ![[BW_CSPGO_BAR:[0-9]+]]74 75define internal fastcc i32 @cond(i32 %i) {76entry:77 %rem = srem i32 %i, 278 ret i32 %rem79}80 81define dso_local void @foo() {82entry:83 br label %for.cond84 85for.cond:86 %i.0 = phi i32 [ 0, %entry ], [ %add4, %for.body ]87 %cmp = icmp slt i32 %i.0, 20000088 br i1 %cmp, label %for.body, label %for.end89 90for.body:91 %call = call i32 @goo(i32 %i.0)92 call void @bar(i32 %call)93 %add = add nsw i32 %call, 194 call void @bar(i32 %add)95 %call1 = call i32 @bar_m(i32 %call) #496 %call3 = call i32 @bar_m2(i32 %add) #497 call fastcc void @barbar()98 %add4 = add nsw i32 %call, 299 br label %for.cond100 101for.end:102 ret void103}104; CSPGOSUMMARY-LABEL: @foo105; CSPGOSUMMARY: %even.odd.i = select i1 %tobool.i{{[0-9]*}}, ptr @even, ptr @odd106; CSPGOSUMMARY-SAME: !prof ![[BW_CSPGO_BAR]]107; CSPGOSUMMARY: %even.odd.i2 = select i1 %tobool.i{{[0-9]*}}, ptr @odd, ptr @even108; CSPGOSUMMARY-SAME: !prof ![[BW_CSPGO_BAR]]109 110declare dso_local i32 @bar_m(i32)111declare dso_local i32 @bar_m2(i32)112 113define internal fastcc void @barbar() {114entry:115 %0 = load i32, ptr @odd, align 4116 %inc = add i32 %0, 1117 store i32 %inc, ptr @odd, align 4118 ret void119}120 121define dso_local i32 @main() {122entry:123 call void @foo()124 ret i32 0125}126 127; PGOSUMMARY: {{![0-9]+}} = !{i32 1, !"ProfileSummary", !{{[0-9]+}}}128; PGOSUMMARY: {{![0-9]+}} = !{!"ProfileFormat", !"InstrProf"}129; PGOSUMMARY: {{![0-9]+}} = !{!"TotalCount", i64 2100001}130; PGOSUMMARY: {{![0-9]+}} = !{!"MaxCount", i64 800000}131; PGOSUMMARY: {{![0-9]+}} = !{!"MaxInternalCount", i64 399999}132; PGOSUMMARY: {{![0-9]+}} = !{!"MaxFunctionCount", i64 800000}133; PGOSUMMARY: {{![0-9]+}} = !{!"NumCounts", i64 14}134; PGOSUMMARY: {{![0-9]+}} = !{!"NumFunctions", i64 8}135; PGOSUMMARY-DAG: ![[BW_PGO_BAR]] = !{!"branch_weights", i32 100000, i32 100000}136 137; CSPGOSUMMARY: {{![0-9]+}} = !{i32 1, !"ProfileSummary", !1}138; CSPGOSUMMARY: {{![0-9]+}} = !{!"ProfileFormat", !"InstrProf"}139; CSPGOSUMMARY: {{![0-9]+}} = !{!"TotalCount", i64 2100001}140; CSPGOSUMMARY: {{![0-9]+}} = !{!"MaxCount", i64 800000}141; CSPGOSUMMARY: {{![0-9]+}} = !{!"MaxInternalCount", i64 399999}142; CSPGOSUMMARY: {{![0-9]+}} = !{!"MaxFunctionCount", i64 800000}143; CSPGOSUMMARY: {{![0-9]+}} = !{!"NumCounts", i64 14}144; CSPGOSUMMARY: {{![0-9]+}} = !{!"NumFunctions", i64 8}145; CSPGOSUMMARY: {{![0-9]+}} = !{!"DetailedSummary", !{{[0-9]+}}}146; CSPGOSUMMARY: {{![0-9]+}} = !{i32 1, !"CSProfileSummary", !{{[0-9]+}}}147; CSPGOSUMMARY: {{![0-9]+}} = !{!"ProfileFormat", !"CSInstrProf"}148; CSPGOSUMMARY: {{![0-9]+}} = !{!"TotalCount", i64 1299950}149; CSPGOSUMMARY: {{![0-9]+}} = !{!"MaxCount", i64 200000}150; CSPGOSUMMARY: {{![0-9]+}} = !{!"MaxInternalCount", i64 100000}151; CSPGOSUMMARY: {{![0-9]+}} = !{!"MaxFunctionCount", i64 200000}152; CSPGOSUMMARY: {{![0-9]+}} = !{!"NumCounts", i64 23}153; CSPGOSUMMARY-DAG: ![[BW_CSPGO_BAR]] = !{!"branch_weights", i32 100000, i32 100000}154