106 lines · plain
1; REQUIRES: x86_64-linux2;3; RUN: rm -rf %t4; RUN: split-file %s %t5; RUN: llvm-ctxprof-util fromYAML --input=%t/profile.yaml --output=%t/profile.ctxprofdata6; RUN: opt -passes='require<ctx-prof-analysis>,print<ctx-prof-analysis>' -ctx-profile-printer-level=everything \7; RUN: %t/example.ll -S 2>&1 | FileCheck %s --check-prefix=NO-CTX8 9; RUN: not opt -passes='require<ctx-prof-analysis>,print<ctx-prof-analysis>' -ctx-profile-printer-level=everything \10; RUN: -use-ctx-profile=does_not_exist.ctxprofdata %t/example.ll -S 2>&1 | FileCheck %s --check-prefix=NO-FILE11 12; RUN: opt -module-summary -passes='thinlto-pre-link<O2>' \13; RUN: -use-ctx-profile=%t/profile.ctxprofdata %t/example.ll -S -o %t/prelink.ll14 15; RUN: opt -module-summary -passes='thinlto-pre-link<O2>' -use-ctx-profile=%t/profile.ctxprofdata \16; RUN: %t/example.ll -S -o %t/prelink.ll17; RUN: opt -passes='require<ctx-prof-analysis>,print<ctx-prof-analysis>' -ctx-profile-printer-level=everything \18; RUN: -use-ctx-profile=%t/profile.ctxprofdata %t/prelink.ll -S 2> %t/output.txt19; RUN: diff %t/expected-profile-output.txt %t/output.txt20 21; NO-FILE: error: could not open contextual profile file22; NO-CTX: No contextual profile was provided23;24; This is the reference profile, laid out in the format the json formatter will25; output it from opt.26;--- profile.yaml27Contexts:28 - Guid: 1234129 TotalRootEntryCount: 9030 Counters: [9]31 - Guid: 1207487034863155064232 TotalRootEntryCount: 2433 Counters: [5]34 - Guid: 1187229159338683369635 TotalRootEntryCount: 436 Counters: [1]37 Callsites: -38 - Guid: 72845332285665141239 Counters: [6, 7]40;--- expected-profile-output.txt41Function Info:424909520559318251808 : an_entrypoint. MaxCounterID: 2. MaxCallsiteID: 14311872291593386833696 : foo. MaxCounterID: 1. MaxCallsiteID: 14412074870348631550642 : another_entrypoint_no_callees. MaxCounterID: 1. MaxCallsiteID: 045 46Current Profile:47 48Contexts:49 - Guid: 1234150 TotalRootEntryCount: 9051 Counters: [ 9 ]52 - Guid: 1187229159338683369653 TotalRootEntryCount: 454 Counters: [ 1 ]55 Callsites:56 - - Guid: 72845332285665141257 Counters: [ 6, 7 ]58 - Guid: 1207487034863155064259 TotalRootEntryCount: 2460 Counters: [ 5 ]61 62Flat Profile:6312341 : 810 64728453322856651412 : 24 28 6511872291593386833696 : 4 6612074870348631550642 : 120 67;--- example.ll68declare void @bar()69 70define private void @foo(i32 %a, ptr %fct) #0 !guid !0 {71 %t = icmp eq i32 %a, 072 br i1 %t, label %yes, label %no73yes:74 call void %fct(i32 %a)75 br label %exit76no:77 call void @bar()78 br label %exit79exit:80 ret void81}82 83define void @an_entrypoint(i32 %a) {84 %t = icmp eq i32 %a, 085 br i1 %t, label %yes, label %no86 87yes:88 call void @foo(i32 1, ptr null)89 ret void90no:91 ret void92}93 94define void @another_entrypoint_no_callees(i32 %a) {95 %t = icmp eq i32 %a, 096 br i1 %t, label %yes, label %no97 98yes:99 ret void100no:101 ret void102}103 104attributes #0 = { noinline }105!0 = !{ i64 11872291593386833696 }106