Index: clang/test/CodeGenCXX/Inputs/profile-remap.proftext =================================================================== --- clang/test/CodeGenCXX/Inputs/profile-remap.proftext +++ clang/test/CodeGenCXX/Inputs/profile-remap.proftext @@ -2,6 +2,6 @@ _ZN3Foo8functionENS_1XE 29667547796 2 -10 +100 90 Index: clang/test/Profile/Inputs/gcc-flag-compatibility_IR.proftext =================================================================== --- clang/test/Profile/Inputs/gcc-flag-compatibility_IR.proftext +++ clang/test/Profile/Inputs/gcc-flag-compatibility_IR.proftext @@ -6,6 +6,6 @@ # Num Counters: 2 # Counter Values: -100 1 +100 Index: compiler-rt/test/profile/Linux/counter_promo_for.c =================================================================== --- compiler-rt/test/profile/Linux/counter_promo_for.c +++ compiler-rt/test/profile/Linux/counter_promo_for.c @@ -1,13 +1,13 @@ // RUN: rm -fr %t.promo.prof // RUN: rm -fr %t.nopromo.prof -// RUN: %clang_pgogen=%t.promo.prof/ -o %t.promo.gen -O2 %s -// RUN: %clang_pgogen=%t.promo.prof/ -o %t.promo.gen.ll -emit-llvm -S -O2 %s +// RUN: %clang_pgogen=%t.promo.prof/ -mllvm -pgo-instrument-entry=false -o %t.promo.gen -O2 %s +// RUN: %clang_pgogen=%t.promo.prof/ -mllvm -pgo-instrument-entry=false -o %t.promo.gen.ll -emit-llvm -S -O2 %s // RUN: cat %t.promo.gen.ll | FileCheck --check-prefix=PROMO %s // RUN: %run %t.promo.gen // RUN: llvm-profdata merge -o %t.promo.profdata %t.promo.prof/ // RUN: llvm-profdata show --counts --all-functions %t.promo.profdata > %t.promo.dump -// RUN: %clang_pgogen=%t.nopromo.prof/ -mllvm -do-counter-promotion=false -mllvm -simplifycfg-sink-common=false -o %t.nopromo.gen -O2 %s -// RUN: %clang_pgogen=%t.nopromo.prof/ -mllvm -do-counter-promotion=false -mllvm -simplifycfg-sink-common=false -o %t.nopromo.gen.ll -emit-llvm -S -O2 %s +// RUN: %clang_pgogen=%t.nopromo.prof/ -mllvm -do-counter-promotion=false -mllvm -pgo-instrument-entry=false -mllvm -simplifycfg-sink-common=false -o %t.nopromo.gen -O2 %s +// RUN: %clang_pgogen=%t.nopromo.prof/ -mllvm -do-counter-promotion=false -mllvm -pgo-instrument-entry=false -mllvm -simplifycfg-sink-common=false -o %t.nopromo.gen.ll -emit-llvm -S -O2 %s // RUN: cat %t.nopromo.gen.ll | FileCheck --check-prefix=NOPROMO %s // RUN: %run %t.nopromo.gen // RUN: llvm-profdata merge -o %t.nopromo.profdata %t.nopromo.prof/ Index: compiler-rt/test/profile/Linux/counter_promo_while.c =================================================================== --- compiler-rt/test/profile/Linux/counter_promo_while.c +++ compiler-rt/test/profile/Linux/counter_promo_while.c @@ -1,13 +1,13 @@ // RUN: rm -fr %t.promo.prof // RUN: rm -fr %t.nopromo.prof -// RUN: %clang_pgogen=%t.promo.prof/ -o %t.promo.gen -O2 %s -// RUN: %clang_pgogen=%t.promo.prof/ -o %t.promo.gen.ll -emit-llvm -S -O2 %s +// RUN: %clang_pgogen=%t.promo.prof/ -mllvm -pgo-instrument-entry=false -o %t.promo.gen -O2 %s +// RUN: %clang_pgogen=%t.promo.prof/ -mllvm -pgo-instrument-entry=false -o %t.promo.gen.ll -emit-llvm -S -O2 %s // RUN: cat %t.promo.gen.ll | FileCheck --check-prefix=PROMO %s // RUN: %run %t.promo.gen // RUN: llvm-profdata merge -o %t.promo.profdata %t.promo.prof/ // RUN: llvm-profdata show --counts --all-functions %t.promo.profdata > %t.promo.dump -// RUN: %clang_pgogen=%t.nopromo.prof/ -mllvm -do-counter-promotion=false -mllvm -simplifycfg-sink-common=false -o %t.nopromo.gen -O2 %s -// RUN: %clang_pgogen=%t.nopromo.prof/ -mllvm -do-counter-promotion=false -mllvm -simplifycfg-sink-common=false -o %t.nopromo.gen.ll -emit-llvm -S -O2 %s +// RUN: %clang_pgogen=%t.nopromo.prof/ -mllvm -do-counter-promotion=false -mllvm -pgo-instrument-entry=false -mllvm -simplifycfg-sink-common=false -o %t.nopromo.gen -O2 %s +// RUN: %clang_pgogen=%t.nopromo.prof/ -mllvm -do-counter-promotion=false -mllvm -pgo-instrument-entry=false -mllvm -simplifycfg-sink-common=false -o %t.nopromo.gen.ll -emit-llvm -S -O2 %s // RUN: cat %t.nopromo.gen.ll | FileCheck --check-prefix=NOPROMO %s // RUN: %run %t.nopromo.gen // RUN: llvm-profdata merge -o %t.nopromo.profdata %t.nopromo.prof/ Index: compiler-rt/test/profile/Linux/instrprof-value-merge.c =================================================================== --- compiler-rt/test/profile/Linux/instrprof-value-merge.c +++ compiler-rt/test/profile/Linux/instrprof-value-merge.c @@ -1,3 +1,11 @@ +// RUN: %clang_pgogen -mllvm -pgo-instrument-entry=false -o %t -O3 %s +// RUN: rm -rf %t.profdir +// RUN: env LLVM_PROFILE_FILE=%t.profdir/default_%m.profraw %run %t +// RUN: env LLVM_PROFILE_FILE=%t.profdir/default_%m.profraw %run %t +// RUN: env LLVM_PROFILE_FILE=%t.profdir/default_%m.profraw %run %t +// RUN: env LLVM_PROFILE_FILE=%t.profdir/default_%m.profraw %run %t 1 +// RUN: env LLVM_PROFILE_FILE=%t.profdir/default_%m.profraw %run %t 1 +// RUN: llvm-profdata show -counts -function=main -ic-targets -memop-sizes %t.profdir/default_*.profraw | FileCheck %s --check-prefixes=CHECK,NOENTRY // RUN: %clang_pgogen -o %t -O3 %s // RUN: rm -rf %t.profdir // RUN: env LLVM_PROFILE_FILE=%t.profdir/default_%m.profraw %run %t @@ -5,7 +13,7 @@ // RUN: env LLVM_PROFILE_FILE=%t.profdir/default_%m.profraw %run %t // RUN: env LLVM_PROFILE_FILE=%t.profdir/default_%m.profraw %run %t 1 // RUN: env LLVM_PROFILE_FILE=%t.profdir/default_%m.profraw %run %t 1 -// RUN: llvm-profdata show -counts -function=main -ic-targets -memop-sizes %t.profdir/default_*.profraw | FileCheck %s +// RUN: llvm-profdata show -counts -function=main -ic-targets -memop-sizes %t.profdir/default_*.profraw | FileCheck %s --check-prefixes=CHECK,ENTRY #include @@ -49,7 +57,8 @@ // CHECK: Counters: 6 // CHECK: Indirect Call Site Count: 3 // CHECK: Number of Memory Intrinsics Calls: 3 -// CHECK: Block counts: [27, 297, 12, 132, 3, 2] +// NOTENTRY: Block counts: [27, 297, 12, 132, 3, 2] +// ENTRY: Block counts: [5, 27, 297, 12, 132, 2] // CHECK: Indirect Target Results: // CHECK: [ 0, foo, 3 ] // CHECK: [ 1, foo, 27 ] Index: compiler-rt/test/profile/infinite_loop.c =================================================================== --- compiler-rt/test/profile/infinite_loop.c +++ compiler-rt/test/profile/infinite_loop.c @@ -1,6 +1,9 @@ -// RUN: %clang_pgogen -O2 -o %t %s +// RUN: %clang_pgogen -O2 -mllvm -pgo-instrument-entry=false -o %t %s // RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t -// RUN: llvm-profdata show -function main -counts %t.profraw| FileCheck %s +// RUN: llvm-profdata show -function main -counts %t.profraw| FileCheck %s --check-prefixes=CHECK,NOENTRY +// RUN: %clang_pgogen -O2 -o %t %s +// RUN: env LLVM_PROFILE_FILE=%t2.profraw %run %t +// RUN: llvm-profdata show -function main -counts %t2.profraw| FileCheck %s --check-prefixes=CHECK,ENTRY void exit(int); int g; @@ -24,7 +27,5 @@ // CHECK-NEXT: main: // CHECK-NEXT: Hash: {{.*}} // CHECK-NEXT: Counters: 2 -// CHECK-NEXT: Block counts: [1000, 1] - - - +// NOTENTRY-NEXT: Block counts: [1000, 1] +// ENTRY-NEXT: Block counts: [1, 1000] Index: compiler-rt/test/profile/runtime_infinite.c =================================================================== --- compiler-rt/test/profile/runtime_infinite.c +++ compiler-rt/test/profile/runtime_infinite.c @@ -4,9 +4,12 @@ // that the entry of main is properly instrumented // and has non-zero count. -// RUN: %clang_pgogen -mllvm -do-counter-promotion=false -O2 -o %t %s +// RUN: %clang_pgogen -mllvm -do-counter-promotion=false -mllvm -pgo-instrument-entry=false -O2 -o %t %s // RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t -// RUN: llvm-profdata show -function main -counts %t.profraw| FileCheck %s +// RUN: llvm-profdata show -function main -counts %t.profraw| FileCheck %s --check-prefixes=CHECK,NOTENTRY +// RUN: %clang_pgogen -mllvm -do-counter-promotion=false -O2 -o %t %s +// RUN: env LLVM_PROFILE_FILE=%t2.profraw %run %t +// RUN: llvm-profdata show -function main -counts %t2.profraw| FileCheck %s --check-prefixes=CHECK,ENTRY void exit(int); int __llvm_profile_dump(void); @@ -33,4 +36,5 @@ } // CHECK-LABEL: main -// CHECK: [10001, 1] +// NOENTRY: [10001, 1] +// ENTRY: [1, 10001] Index: llvm/include/llvm/ProfileData/InstrProfData.inc =================================================================== --- llvm/include/llvm/ProfileData/InstrProfData.inc +++ llvm/include/llvm/ProfileData/InstrProfData.inc @@ -657,7 +657,7 @@ /* Raw profile format version (start from 1). */ #define INSTR_PROF_RAW_VERSION 5 /* Indexed profile format version (start from 1). */ -#define INSTR_PROF_INDEX_VERSION 6 +#define INSTR_PROF_INDEX_VERSION 7 /* Coverage mapping format version (start from 0). */ #define INSTR_PROF_COVMAP_VERSION 3 Index: llvm/lib/Transforms/Instrumentation/CFGMST.h =================================================================== --- llvm/lib/Transforms/Instrumentation/CFGMST.h +++ llvm/lib/Transforms/Instrumentation/CFGMST.h @@ -31,7 +31,7 @@ using namespace llvm; static cl::opt PGOInstrumentEntry( - "pgo-instrument-entry", cl::init(false), cl::Hidden, + "pgo-instrument-entry", cl::init(true), cl::Hidden, cl::desc("Force to instrument function entry basicblock.")); namespace llvm { @@ -107,7 +107,7 @@ const BasicBlock *Entry = &(F.getEntryBlock()); uint64_t EntryWeight = (BFI != nullptr ? BFI->getEntryFreq() : 2); // If we want to instrument the entry count, lower the weight to 0. - if (PGOInstrumentEntry) + if (DoInstrumentFuncEntry()) EntryWeight = 0; Edge *EntryIncoming = nullptr, *EntryOutgoing = nullptr, *ExitOutgoing = nullptr, *ExitIncoming = nullptr; @@ -282,14 +282,27 @@ BranchProbabilityInfo *BPI; BlockFrequencyInfo *BFI; + // If function entry will be always instrumented. + // Internal option PGOInstrumentEntry takes precedence over this. + bool InstrumentFuncEntry; + + inline bool DoInstrumentFuncEntry() { + if (PGOInstrumentEntry.getNumOccurrences() > 0) + return PGOInstrumentEntry; + + return InstrumentFuncEntry; + } + public: - CFGMST(Function &Func, BranchProbabilityInfo *BPI_ = nullptr, + CFGMST(Function &Func, bool InstrumentFuncEntry_, + BranchProbabilityInfo *BPI_ = nullptr, BlockFrequencyInfo *BFI_ = nullptr) - : F(Func), BPI(BPI_), BFI(BFI_) { + : F(Func), BPI(BPI_), BFI(BFI_), + InstrumentFuncEntry(InstrumentFuncEntry_) { buildEdges(); sortEdgesByWeight(); computeMinimumSpanningTree(); - if (PGOInstrumentEntry && (AllEdges.size() > 1)) + if (AllEdges.size() > 1 && DoInstrumentFuncEntry()) std::iter_swap(std::move(AllEdges.begin()), std::move(AllEdges.begin() + AllEdges.size() - 1)); } Index: llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp =================================================================== --- llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp +++ llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp @@ -528,6 +528,9 @@ // Is this is context-sensitive instrumentation. bool IsCS; + // If we instrument function entry BB by default. + bool InstrumentFuncEntry; + // A map that stores the Comdat group in function F. std::unordered_multimap &ComdatMembers; @@ -572,9 +575,11 @@ Function &Func, TargetLibraryInfo &TLI, std::unordered_multimap &ComdatMembers, bool CreateGlobalVar = false, BranchProbabilityInfo *BPI = nullptr, - BlockFrequencyInfo *BFI = nullptr, bool IsCS = false) + BlockFrequencyInfo *BFI = nullptr, bool IsCS = false, + bool InstrumentFuncEntry = true) : F(Func), IsCS(IsCS), ComdatMembers(ComdatMembers), VPC(Func, TLI), - ValueSites(IPVK_Last + 1), SIVisitor(Func), MST(F, BPI, BFI) { + ValueSites(IPVK_Last + 1), SIVisitor(Func), + MST(F, InstrumentFuncEntry, BPI, BFI) { // This should be done before CFG hash computation. SIVisitor.countSelects(Func); ValueSites[IPVK_MemOPSize] = VPC.get(IPVK_MemOPSize); @@ -1004,9 +1009,10 @@ PGOUseFunc(Function &Func, Module *Modu, TargetLibraryInfo &TLI, std::unordered_multimap &ComdatMembers, BranchProbabilityInfo *BPI, BlockFrequencyInfo *BFIin, - ProfileSummaryInfo *PSI, bool IsCS) + ProfileSummaryInfo *PSI, bool IsCS, bool InstrumentFuncEntry) : F(Func), M(Modu), BFI(BFIin), PSI(PSI), - FuncInfo(Func, TLI, ComdatMembers, false, BPI, BFIin, IsCS), + FuncInfo(Func, TLI, ComdatMembers, false, BPI, BFIin, IsCS, + InstrumentFuncEntry), FreqAttr(FFA_Normal), IsCS(IsCS) {} // Read counts for the instrumented BB from profile. @@ -1619,6 +1625,10 @@ collectComdatMembers(M, ComdatMembers); std::vector HotFunctions; std::vector ColdFunctions; + + // From index profile version 7, we instrument function entry BB by default. + // This can be overwritten by internal option in CFGMST.h + bool InstrumentFuncEntry = (PGOReader->getVersion() >= 7); for (auto &F : M) { if (F.isDeclaration()) continue; @@ -1628,7 +1638,8 @@ // Split indirectbr critical edges here before computing the MST rather than // later in getInstrBB() to avoid invalidating it. SplitIndirectBrCriticalEdges(F, BPI, BFI); - PGOUseFunc Func(F, &M, TLI, ComdatMembers, BPI, BFI, PSI, IsCS); + PGOUseFunc Func(F, &M, TLI, ComdatMembers, BPI, BFI, PSI, IsCS, + InstrumentFuncEntry); bool AllZeros = false; if (!Func.readCounters(PGOReader.get(), AllZeros)) continue; Index: llvm/test/Transforms/PGOProfile/Inputs/PR41279.proftext =================================================================== --- llvm/test/Transforms/PGOProfile/Inputs/PR41279.proftext +++ llvm/test/Transforms/PGOProfile/Inputs/PR41279.proftext @@ -2,7 +2,7 @@ foo 60927483247 4 -3 +8 2 3 2 Index: llvm/test/Transforms/PGOProfile/Inputs/PR41279_2.proftext =================================================================== --- llvm/test/Transforms/PGOProfile/Inputs/PR41279_2.proftext +++ llvm/test/Transforms/PGOProfile/Inputs/PR41279_2.proftext @@ -2,6 +2,6 @@ f 62077759478 2 +5 3 -2 Index: llvm/test/Transforms/PGOProfile/Inputs/branch2_entry.proftext =================================================================== --- /dev/null +++ llvm/test/Transforms/PGOProfile/Inputs/branch2_entry.proftext @@ -0,0 +1,8 @@ +# :ir is the flag to indicate this is IR level profile. +:ir +test_br_2 +29667547796 +2 +2 +1 + Index: llvm/test/Transforms/PGOProfile/Inputs/criticaledge_entry.proftext =================================================================== --- /dev/null +++ llvm/test/Transforms/PGOProfile/Inputs/criticaledge_entry.proftext @@ -0,0 +1,19 @@ +# :ir is the flag to indicate this is IR level profile. +:ir +test_criticalEdge +82323253069 +8 +7 +2 +1 +2 +0 +1 +2 +1 + +:bar +12884901887 +1 +7 + Index: llvm/test/Transforms/PGOProfile/Inputs/indirectbr_entry.proftext =================================================================== --- /dev/null +++ llvm/test/Transforms/PGOProfile/Inputs/indirectbr_entry.proftext @@ -0,0 +1,12 @@ +# IR level Instrumentation Flag +:ir +foo +# Func Hash: +47485104005 +# Num Counters: +4 +# Counter Values: +202 +20 +5 +63 Index: llvm/test/Transforms/PGOProfile/Inputs/irreducible_entry.proftext =================================================================== --- /dev/null +++ llvm/test/Transforms/PGOProfile/Inputs/irreducible_entry.proftext @@ -0,0 +1,29 @@ +:ir +_Z11irreducibleii +# Func Hash: +64451410787 +# Num Counters: +6 +# Counter Values: +1 +1000 +950 +100 +373 +0 + +_Z11irreduciblePh +# Func Hash: +104649601521 +# Num Counters: +9 +# Counter Values: +1 +100 +300 +99 +300 +201 +1 +0 +0 Index: llvm/test/Transforms/PGOProfile/Inputs/landingpad_entry.proftext =================================================================== --- /dev/null +++ llvm/test/Transforms/PGOProfile/Inputs/landingpad_entry.proftext @@ -0,0 +1,16 @@ +# :ir is the flag to indicate this is IR level profile. +:ir +foo +59130013419 +4 +5 +1 +2 +0 + +bar +24868915205 +2 +3 +2 + Index: llvm/test/Transforms/PGOProfile/Inputs/loop1_entry.proftext =================================================================== --- /dev/null +++ llvm/test/Transforms/PGOProfile/Inputs/loop1_entry.proftext @@ -0,0 +1,8 @@ +# :ir is the flag to indicate this is IR level profile. +:ir +test_simple_for +34137660316 +2 +4 +96 + Index: llvm/test/Transforms/PGOProfile/Inputs/loop2_entry.proftext =================================================================== --- /dev/null +++ llvm/test/Transforms/PGOProfile/Inputs/loop2_entry.proftext @@ -0,0 +1,9 @@ +# :ir is the flag to indicate this is IR level profile. +:ir +test_nested_for +53929068288 +3 +6 +33 +10 + Index: llvm/test/Transforms/PGOProfile/Inputs/misexpect-branch_entry.proftext =================================================================== --- /dev/null +++ llvm/test/Transforms/PGOProfile/Inputs/misexpect-branch_entry.proftext @@ -0,0 +1,38 @@ +# IR level Instrumentation Flag +:ir +bar +# Func Hash: +29667547796 +# Num Counters: +2 +# Counter Values: +2000000 +1600332 + +baz +# Func Hash: +12884901887 +# Num Counters: +1 +# Counter Values: +399668 + +foo +# Func Hash: +29212902728 +# Num Counters: +2 +# Counter Values: +40803991 +1600332 + +main +# Func Hash: +41605652536 +# Num Counters: +3 +# Counter Values: +2000000 +2000 +1 + Index: llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch-correct_entry.proftext =================================================================== --- /dev/null +++ llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch-correct_entry.proftext @@ -0,0 +1,16 @@ +# IR level Instrumentation Flag +:ir +main +# Func Hash: +74054140268 +# Num Counters: +7 +# Counter Values: +1 +0 +0 +20000 +0 +0 +0 + Index: llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch_entry.proftext =================================================================== --- /dev/null +++ llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch_entry.proftext @@ -0,0 +1,16 @@ +# IR level Instrumentation Flag +:ir +main +# Func Hash: +74054140268 +# Num Counters: +7 +# Counter Values: +11889 +3973 +3970 +0 +8111 +1 +0 + Index: llvm/test/Transforms/PGOProfile/Inputs/select1.proftext =================================================================== --- llvm/test/Transforms/PGOProfile/Inputs/select1.proftext +++ llvm/test/Transforms/PGOProfile/Inputs/select1.proftext @@ -2,7 +2,7 @@ test_br_2 72057623705475732 3 -4 +5 1 1 Index: llvm/test/Transforms/PGOProfile/Inputs/select2.proftext =================================================================== --- llvm/test/Transforms/PGOProfile/Inputs/select2.proftext +++ llvm/test/Transforms/PGOProfile/Inputs/select2.proftext @@ -6,6 +6,6 @@ # Num Counters: 3 # Counter Values: -800 3 +800 300 Index: llvm/test/Transforms/PGOProfile/Inputs/switch_entry.proftext =================================================================== --- /dev/null +++ llvm/test/Transforms/PGOProfile/Inputs/switch_entry.proftext @@ -0,0 +1,10 @@ +# :ir is the flag to indicate this is IR level profile. +:ir +test_switch +46200943743 +4 +10 +5 +2 +3 + Index: llvm/test/Transforms/PGOProfile/PR41279.ll =================================================================== --- llvm/test/Transforms/PGOProfile/PR41279.ll +++ llvm/test/Transforms/PGOProfile/PR41279.ll @@ -23,6 +23,7 @@ br i1 %5, label %7, label %13 ; USE: br i1 %5, label %7, label %13 ; USE-SAME: !prof ![[BW_ENTRY1:[0-9]+]] +; GEN: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @__profn_foo, i32 0, i32 0), i64 60927483247, i32 4, i32 0) 6: cleanupret from %17 unwind to caller @@ -55,8 +56,6 @@ 13: call void @f3({ i8*, i64 }* %0, { i8*, i64 }* %1, i64 1) br label %14 -; GEN: 13: -; GEN: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @__profn_foo, i32 0, i32 0), i64 60927483247, i32 4, i32 0) 14: ret void Index: llvm/test/Transforms/PGOProfile/PR41279_2.ll =================================================================== --- llvm/test/Transforms/PGOProfile/PR41279_2.ll +++ llvm/test/Transforms/PGOProfile/PR41279_2.ll @@ -17,6 +17,8 @@ %__exception_code2 = alloca i32, align 4 invoke void @f() #2 to label %invoke.cont unwind label %catch.dispatch +;GEN: entry: +;GEN: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @__profn_f, i32 0, i32 0), i64 62077759478, i32 2, i32 0) catch.dispatch: %0 = catchswitch within none [label %__except] unwind to caller @@ -58,9 +60,6 @@ invoke.cont3: br label %__try.cont7 -;GEN: invoke.cont3: -;GEN: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @__profn_f, i32 0, i32 0), i64 62077759478, i32 2, i32 0) - } declare dso_local i32 @__C_specific_handler(...) Index: llvm/test/Transforms/PGOProfile/branch2.ll =================================================================== --- llvm/test/Transforms/PGOProfile/branch2.ll +++ llvm/test/Transforms/PGOProfile/branch2.ll @@ -1,8 +1,14 @@ -; RUN: opt < %s -pgo-instr-gen -S | FileCheck %s --check-prefix=GEN -; RUN: opt < %s -passes=pgo-instr-gen -S | FileCheck %s --check-prefix=GEN +; RUN: opt < %s -pgo-instr-gen -pgo-instrument-entry=false -S | FileCheck %s --check-prefixes=GEN,NOTENTRY +; RUN: opt < %s -passes=pgo-instr-gen -pgo-instrument-entry=false -S | FileCheck %s --check-prefixes=GEN,NOTENTRY ; RUN: llvm-profdata merge %S/Inputs/branch2.proftext -o %t.profdata -; RUN: opt < %s -pgo-instr-use -pgo-test-profile-file=%t.profdata -S | FileCheck %s --check-prefix=USE -; RUN: opt < %s -passes=pgo-instr-use -pgo-test-profile-file=%t.profdata -S | FileCheck %s --check-prefix=USE +; RUN: opt < %s -pgo-instr-use -pgo-instrument-entry=false -pgo-test-profile-file=%t.profdata -S | FileCheck %s --check-prefix=USE +; RUN: opt < %s -passes=pgo-instr-use -pgo-instrument-entry=false -pgo-test-profile-file=%t.profdata -S | FileCheck %s --check-prefix=USE + +; RUN: opt < %s -pgo-instr-gen -pgo-instrument-entry=true -S | FileCheck %s --check-prefixes=GEN,ENTRY +; RUN: opt < %s -passes=pgo-instr-gen -pgo-instrument-entry=true -S | FileCheck %s --check-prefixes=GEN,ENTRY +; RUN: llvm-profdata merge %S/Inputs/branch2_entry.proftext -o %t.profdata +; RUN: opt < %s -pgo-instr-use -pgo-instrument-entry=true -pgo-test-profile-file=%t.profdata -S | FileCheck %s --check-prefix=USE +; RUN: opt < %s -passes=pgo-instr-use -pgo-instrument-entry=true -pgo-test-profile-file=%t.profdata -S | FileCheck %s --check-prefix=USE target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-unknown-linux-gnu" @@ -13,7 +19,8 @@ define i32 @test_br_2(i32 %i) { entry: ; GEN: entry: -; GEN-NOT: llvm.instrprof.increment +; NOTENTRY-NOT: llvm.instrprof.increment +; ENTRY: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @__profn_test_br_2, i32 0, i32 0), i64 29667547796, i32 2, i32 0) %cmp = icmp sgt i32 %i, 0 br i1 %cmp, label %if.then, label %if.else ; USE: br i1 %cmp, label %if.then, label %if.else @@ -22,7 +29,8 @@ if.then: ; GEN: if.then: -; GEN: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @__profn_test_br_2, i32 0, i32 0), i64 29667547796, i32 2, i32 0) +; NOTENTRY: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @__profn_test_br_2, i32 0, i32 0), i64 29667547796, i32 2, i32 0) +; ENTRY-NOT: llvm.instrprof.increment %add = add nsw i32 %i, 2 br label %if.end Index: llvm/test/Transforms/PGOProfile/counter_promo.ll =================================================================== --- llvm/test/Transforms/PGOProfile/counter_promo.ll +++ llvm/test/Transforms/PGOProfile/counter_promo.ll @@ -1,13 +1,13 @@ ; RUN: opt < %s -pgo-instr-gen -instrprof -do-counter-promotion=true -S | FileCheck --check-prefix=PROMO --check-prefix=NONATOMIC_PROMO %s -; RUN: opt < %s --passes=pgo-instr-gen,instrprof -do-counter-promotion=true -S | FileCheck --check-prefix=PROMO --check-prefix=NONATOMIC_PROMO %s +; RUN: opt < %s --passes=pgo-instr-gen,instrprof -do-counter-promotion=true -S | FileCheck --check-prefix=PROMO --check-prefix=NONATOMIC_PROMO %s ; RUN: opt < %s -pgo-instr-gen -instrprof -do-counter-promotion=true -atomic-counter-update-promoted -S | FileCheck --check-prefix=PROMO --check-prefix=ATOMIC_PROMO %s -; RUN: opt < %s --passes=pgo-instr-gen,instrprof -do-counter-promotion=true -atomic-counter-update-promoted -S | FileCheck --check-prefix=PROMO --check-prefix=ATOMIC_PROMO %s +; RUN: opt < %s --passes=pgo-instr-gen,instrprof -do-counter-promotion=true -atomic-counter-update-promoted -S | FileCheck --check-prefix=PROMO --check-prefix=ATOMIC_PROMO %s define void @foo(i32 %n, i32 %N) { ; PROMO-LABEL: @foo -; PROMO: {{.*}} = load {{.*}} @__profc_foo{{.*}} 3) -; PROMO-NEXT: add -; PROMO-NEXT: store {{.*}}@__profc_foo{{.*}}3) +; PROMO: {{.*}} = load {{.*}} @__profc_foo{{.*}} 0) +; PROMO-NEXT: add +; PROMO-NEXT: store {{.*}}@__profc_foo{{.*}}0) bb: %tmp = add nsw i32 %n, 1 %tmp1 = add nsw i32 %n, -1 @@ -48,18 +48,18 @@ bb12: ; preds = %bb9 ret void -; NONATOMIC_PROMO: %[[PROMO1:[a-z0-9.]+]] = load {{.*}} @__profc_foo{{.*}} 0) -; NONATOMIC_PROMO-NEXT: add {{.*}} %[[PROMO1]], %[[LIVEOUT1]] -; NONATOMIC_PROMO-NEXT: store {{.*}}@__profc_foo{{.*}}0) -; NONATOMIC_PROMO-NEXT: %[[PROMO2:[a-z0-9.]+]] = load {{.*}} @__profc_foo{{.*}} 1) -; NONATOMIC_PROMO-NEXT: add {{.*}} %[[PROMO2]], %[[LIVEOUT2]] +; NONATOMIC_PROMO: %[[PROMO1:[a-z0-9.]+]] = load {{.*}} @__profc_foo{{.*}} 1) +; NONATOMIC_PROMO-NEXT: add {{.*}} %[[PROMO1]], %[[LIVEOUT1]] ; NONATOMIC_PROMO-NEXT: store {{.*}}@__profc_foo{{.*}}1) -; NONATOMIC_PROMO-NEXT: %[[PROMO3:[a-z0-9.]+]] = load {{.*}} @__profc_foo{{.*}} 2) -; NONATOMIC_PROMO-NEXT: add {{.*}} %[[PROMO3]], %[[LIVEOUT3]] +; NONATOMIC_PROMO-NEXT: %[[PROMO2:[a-z0-9.]+]] = load {{.*}} @__profc_foo{{.*}} 2) +; NONATOMIC_PROMO-NEXT: add {{.*}} %[[PROMO2]], %[[LIVEOUT2]] ; NONATOMIC_PROMO-NEXT: store {{.*}}@__profc_foo{{.*}}2) -; ATOMIC_PROMO: atomicrmw add {{.*}} @__profc_foo{{.*}}0), i64 %[[LIVEOUT1]] seq_cst -; ATOMIC_PROMO-NEXT: atomicrmw add {{.*}} @__profc_foo{{.*}}1), i64 %[[LIVEOUT2]] seq_cst -; ATOMIC_PROMO-NEXT: atomicrmw add {{.*}} @__profc_foo{{.*}}2), i64 %[[LIVEOUT3]] seq_cst +; NONATOMIC_PROMO-NEXT: %[[PROMO3:[a-z0-9.]+]] = load {{.*}} @__profc_foo{{.*}} 3) +; NONATOMIC_PROMO-NEXT: add {{.*}} %[[PROMO3]], %[[LIVEOUT3]] +; NONATOMIC_PROMO-NEXT: store {{.*}}@__profc_foo{{.*}}3) +; ATOMIC_PROMO: atomicrmw add {{.*}} @__profc_foo{{.*}}1), i64 %[[LIVEOUT1]] seq_cst +; ATOMIC_PROMO-NEXT: atomicrmw add {{.*}} @__profc_foo{{.*}}2), i64 %[[LIVEOUT2]] seq_cst +; ATOMIC_PROMO-NEXT: atomicrmw add {{.*}} @__profc_foo{{.*}}3), i64 %[[LIVEOUT3]] seq_cst ; PROMO-NOT: @__profc_foo Index: llvm/test/Transforms/PGOProfile/counter_promo_exit_catchswitch.ll =================================================================== --- llvm/test/Transforms/PGOProfile/counter_promo_exit_catchswitch.ll +++ llvm/test/Transforms/PGOProfile/counter_promo_exit_catchswitch.ll @@ -2,8 +2,10 @@ ; compilation for loops that exit to a catchswitch block. In this case, counters ; do not get promoted out of the loop body. -; RUN: opt < %s -pgo-instr-gen -instrprof -do-counter-promotion=true -S | FileCheck %s -; RUN: opt < %s -passes=pgo-instr-gen,instrprof -do-counter-promotion=true -S | FileCheck %s +; RUN: opt < %s -pgo-instr-gen -instrprof -pgo-instrument-entry=false -do-counter-promotion=true -S | FileCheck %s --check-prefixes=CHECK,NOTENTRY +; RUN: opt < %s -passes=pgo-instr-gen,instrprof -pgo-instrument-entry=false -do-counter-promotion=true -S | FileCheck %s --check-prefixes=CHECK,NOTENTRY +; RUN: opt < %s -pgo-instr-gen -instrprof -pgo-instrument-entry=true -do-counter-promotion=true -S | FileCheck %s --check-prefixes=CHECK,ENTRY +; RUN: opt < %s -passes=pgo-instr-gen,instrprof -pgo-instrument-entry=true -do-counter-promotion=true -S | FileCheck %s --check-prefixes=CHECK,ENTRY ; Source used to create test: ; @@ -36,9 +38,11 @@ for.body: ; preds = %for.cond ; CHECK: for.body: -; CHECK: %pgocount1 = load i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @"__profc_?run@@YAXH@Z", i64 0, i64 0) +; NOTENTRY: %pgocount1 = load i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @"__profc_?run@@YAXH@Z", i64 0, i64 0) +; TENTRY: %pgocount1 = load i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @"__profc_?run@@YAXH@Z", i64 0, i64 1) ; CHECK: %1 = add i64 %pgocount1, 1 -; CHECK: store i64 %1, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @"__profc_?run@@YAXH@Z", i64 0, i64 0) +; NOTENTRY: store i64 %1, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @"__profc_?run@@YAXH@Z", i64 0, i64 0) +; ENTRY: store i64 %1, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @"__profc_?run@@YAXH@Z", i64 0, i64 1) %idxprom = zext i32 %i.0 to i64 %arrayidx = getelementptr inbounds [200 x i8], [200 x i8]* @"?buffer@@3PADA", i64 0, i64 %idxprom %0 = load i8, i8* %arrayidx, align 1 @@ -51,9 +55,11 @@ for.inc: ; preds = %if.end ; CHECK: for.inc: -; CHECK: %pgocount2 = load i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @"__profc_?run@@YAXH@Z", i64 0, i64 1) +; NOTENTRY: %pgocount2 = load i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @"__profc_?run@@YAXH@Z", i64 0, i64 1) +; ENTRY: %pgocount2 = load i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @"__profc_?run@@YAXH@Z", i64 0, i64 2) ; CHECK: %3 = add i64 %pgocount2, 1 -; CHECK: store i64 %3, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @"__profc_?run@@YAXH@Z", i64 0, i64 1) +; NOTENTRY: store i64 %3, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @"__profc_?run@@YAXH@Z", i64 0, i64 1) +; ENTRY: store i64 %3, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @"__profc_?run@@YAXH@Z", i64 0, i64 2) %inc = add nuw nsw i32 %i.0, 1 br label %for.cond Index: llvm/test/Transforms/PGOProfile/counter_promo_mexits.ll =================================================================== --- llvm/test/Transforms/PGOProfile/counter_promo_mexits.ll +++ llvm/test/Transforms/PGOProfile/counter_promo_mexits.ll @@ -40,34 +40,31 @@ ; PROMO-LABEL: bb14: tail call void @bar(i32 0) br label %bb15 -; PROMO: %pgocount.promoted{{.*}} = load {{.*}} @__profc_foo{{.*}} 0) -; PROMO-NEXT: add -; PROMO-NEXT: store {{.*}}@__profc_foo{{.*}}0) -; PROMO-NEXT: %pgocount.promoted{{.*}} = load {{.*}} @__profc_foo{{.*}} 1) -; PROMO-NEXT: add +; PROMO: %pgocount.promoted{{.*}} = load {{.*}} @__profc_foo{{.*}} 1) +; PROMO-NEXT: add ; PROMO-NEXT: store {{.*}}@__profc_foo{{.*}}1) ; PROMO-NEXT: %pgocount.promoted{{.*}} = load {{.*}} @__profc_foo{{.*}} 2) -; PROMO-NEXT: add +; PROMO-NEXT: add ; PROMO-NEXT: store {{.*}}@__profc_foo{{.*}}2) -; PROMO-NEXT: %pgocount{{.*}} = load {{.*}} @__profc_foo{{.*}} 3) -; PROMO-NEXT: add +; PROMO-NEXT: %pgocount.promoted{{.*}} = load {{.*}} @__profc_foo{{.*}} 3) +; PROMO-NEXT: add ; PROMO-NEXT: store {{.*}}@__profc_foo{{.*}}3) bb15_0: ; preds = %bb11 ; PROMO-LABEL: bb15_0: br label %bb15 -; PROMO: %pgocount.promoted{{.*}} = load {{.*}} @__profc_foo{{.*}} 0) -; PROMO-NEXT: add -; PROMO-NEXT: store {{.*}}@__profc_foo{{.*}}0) -; PROMO-NEXT: %pgocount.promoted{{.*}} = load {{.*}} @__profc_foo{{.*}} 1) -; PROMO-NEXT: add +; PROMO: %pgocount.promoted{{.*}} = load {{.*}} @__profc_foo{{.*}} 1) +; PROMO-NEXT: add ; PROMO-NEXT: store {{.*}}@__profc_foo{{.*}}1) ; PROMO-NEXT: %pgocount.promoted{{.*}} = load {{.*}} @__profc_foo{{.*}} 2) -; PROMO-NEXT: add +; PROMO-NEXT: add ; PROMO-NEXT: store {{.*}}@__profc_foo{{.*}}2) +; PROMO-NEXT: %pgocount.promoted{{.*}} = load {{.*}} @__profc_foo{{.*}} 3) +; PROMO-NEXT: add +; PROMO-NEXT: store {{.*}}@__profc_foo{{.*}}3) ; PROMO-NEXT: %pgocount{{.*}} = load {{.*}} @__profc_foo{{.*}} 4) -; PROMO-NEXT: add +; PROMO-NEXT: add ; PROMO-NEXT: store {{.*}}@__profc_foo{{.*}}4) ; PROMO-NOT: @__profc_foo Index: llvm/test/Transforms/PGOProfile/criticaledge.ll =================================================================== --- llvm/test/Transforms/PGOProfile/criticaledge.ll +++ llvm/test/Transforms/PGOProfile/criticaledge.ll @@ -1,8 +1,14 @@ -; RUN: opt < %s -pgo-instr-gen -S | FileCheck %s --check-prefix=GEN -; RUN: opt < %s -passes=pgo-instr-gen -S | FileCheck %s --check-prefix=GEN +; RUN: opt < %s -pgo-instr-gen -pgo-instrument-entry=false -S | FileCheck %s --check-prefix=GEN +; RUN: opt < %s -passes=pgo-instr-gen -pgo-instrument-entry=false -S | FileCheck %s --check-prefix=GEN ; RUN: llvm-profdata merge %S/Inputs/criticaledge.proftext -o %t.profdata -; RUN: opt < %s -pgo-instr-use -pgo-test-profile-file=%t.profdata -S | FileCheck %s --check-prefix=USE -; RUN: opt < %s -passes=pgo-instr-use -pgo-test-profile-file=%t.profdata -S | FileCheck %s --check-prefix=USE +; RUN: opt < %s -pgo-instr-use -pgo-instrument-entry=false -pgo-test-profile-file=%t.profdata -S | FileCheck %s --check-prefix=USE +; RUN: opt < %s -passes=pgo-instr-use -pgo-instrument-entry=false -pgo-test-profile-file=%t.profdata -S | FileCheck %s --check-prefix=USE +; +; RUN: opt < %s -pgo-instr-gen -pgo-instrument-entry=true -S | FileCheck %s --check-prefix=GEN +; RUN: opt < %s -passes=pgo-instr-gen -pgo-instrument-entry=true -S | FileCheck %s --check-prefix=GEN +; RUN: llvm-profdata merge %S/Inputs/criticaledge_entry.proftext -o %t2.profdata +; RUN: opt < %s -pgo-instr-use -pgo-instrument-entry=true -pgo-test-profile-file=%t2.profdata -S | FileCheck %s --check-prefix=USE +; RUN: opt < %s -passes=pgo-instr-use -pgo-instrument-entry=true -pgo-test-profile-file=%t2.profdata -S | FileCheck %s --check-prefix=USE target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-unknown-linux-gnu" @@ -14,7 +20,8 @@ define i32 @test_criticalEdge(i32 %i, i32 %j) { entry: ; CHECK: entry: -; GEN-NOT: call void @llvm.instrprof.increment +; NOTENTRY-NOT: call void @llvm.instrprof.increment +; ENTRY: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @__profn_test_criticalEdge, i32 0, i32 0), i64 82323253069, i32 8, i32 0) switch i32 %i, label %sw.default [ i32 1, label %sw.bb i32 2, label %sw.bb1 @@ -28,11 +35,13 @@ ; USE-SAME: !prof ![[BW_SWITCH:[0-9]+]] ; CHECK: entry.sw.bb2_crit_edge1: -; GEN: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @__profn_test_criticalEdge, i32 0, i32 0), i64 82323253069, i32 8, i32 1) +; NOTENTRY: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @__profn_test_criticalEdge, i32 0, i32 0), i64 82323253069, i32 8, i32 1) +; ENTRY: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @__profn_test_criticalEdge, i32 0, i32 0), i64 82323253069, i32 8, i32 2) ; CHECK: br label %sw.bb2 ; CHECK: entry.sw.bb2_crit_edge: -; GEN: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @__profn_test_criticalEdge, i32 0, i32 0), i64 82323253069, i32 8, i32 0) +; NOTENTRY: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @__profn_test_criticalEdge, i32 0, i32 0), i64 82323253069, i32 8, i32 0) +; TENTRY: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @__profn_test_criticalEdge, i32 0, i32 0), i64 82323253069, i32 8, i32 1) ; CHECK: br label %sw.bb2 sw.bb: @@ -57,7 +66,8 @@ if.then: ; GEN: if.then: -; GEN: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @__profn_test_criticalEdge, i32 0, i32 0), i64 82323253069, i32 8, i32 2) +; NOTENTRY: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @__profn_test_criticalEdge, i32 0, i32 0), i64 82323253069, i32 8, i32 2) +; ENTRY-NOT: call void @llvm.instrprof.increment %call4 = call i32 @bar(i32 4) br label %return Index: llvm/test/Transforms/PGOProfile/cspgo_profile_summary.ll =================================================================== --- llvm/test/Transforms/PGOProfile/cspgo_profile_summary.ll +++ llvm/test/Transforms/PGOProfile/cspgo_profile_summary.ll @@ -1,8 +1,8 @@ ; Test the profile summary for context sensitive PGO (CSPGO) ; RUN: llvm-profdata merge %S/Inputs/cspgo.proftext -o %t.profdata -; RUN: opt < %s -O2 -disable-preinline -pgo-kind=pgo-instr-use-pipeline -profile-file=%t.profdata -S | FileCheck %s --check-prefix=PGOSUMMARY -; RUN: opt < %s -O2 -disable-preinline -pgo-kind=pgo-instr-use-pipeline -profile-file=%t.profdata -S -cspgo-kind=cspgo-instr-use-pipeline| FileCheck %s --check-prefix=CSPGOSUMMARY +; 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=PGOSUMMARY +; 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=CSPGOSUMMARY target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-unknown-linux-gnu" Index: llvm/test/Transforms/PGOProfile/indirectbr.ll =================================================================== --- llvm/test/Transforms/PGOProfile/indirectbr.ll +++ llvm/test/Transforms/PGOProfile/indirectbr.ll @@ -1,8 +1,13 @@ ; RUN: llvm-profdata merge %S/Inputs/indirectbr.proftext -o %t.profdata -; RUN: opt < %s -pgo-instr-use -pgo-test-profile-file=%t.profdata -S | FileCheck %s --check-prefix=USE +; RUN: opt < %s -pgo-instr-use -pgo-instrument-entry=false -pgo-test-profile-file=%t.profdata -S | FileCheck %s --check-prefix=USE ; New PM -; RUN: opt < %s -passes=pgo-instr-use -pgo-test-profile-file=%t.profdata -S | FileCheck %s --check-prefix=USE -; RUN: opt < %s -passes=pgo-instr-use -pgo-test-profile-file=%t.profdata -S | opt -S -analyze -branch-prob | FileCheck %s --check-prefix=BRANCHPROB +; RUN: opt < %s -passes=pgo-instr-use -pgo-instrument-entry=false -pgo-test-profile-file=%t.profdata -S | FileCheck %s --check-prefix=USE +; RUN: opt < %s -passes=pgo-instr-use -pgo-instrument-entry=false -pgo-test-profile-file=%t.profdata -S | opt -S -analyze -branch-prob | FileCheck %s --check-prefix=BRANCHPROB +; RUN: llvm-profdata merge %S/Inputs/indirectbr_entry.proftext -o %t2.profdata +; RUN: opt < %s -pgo-instr-use -pgo-instrument-entry=true -pgo-test-profile-file=%t2.profdata -S | FileCheck %s --check-prefix=USE +; New PM +; RUN: opt < %s -passes=pgo-instr-use -pgo-instrument-entry=true -pgo-test-profile-file=%t2.profdata -S | FileCheck %s --check-prefix=USE +; RUN: opt < %s -passes=pgo-instr-use -pgo-instrument-entry=true -pgo-test-profile-file=%t2.profdata -S | opt -S -analyze -branch-prob | FileCheck %s --check-prefix=BRANCHPROB target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-unknown-linux-gnu" Index: llvm/test/Transforms/PGOProfile/irreducible.ll =================================================================== --- llvm/test/Transforms/PGOProfile/irreducible.ll +++ llvm/test/Transforms/PGOProfile/irreducible.ll @@ -1,6 +1,9 @@ ; RUN: llvm-profdata merge %S/Inputs/irreducible.proftext -o %t.profdata -; RUN: opt < %s -pgo-instr-use -pgo-test-profile-file=%t.profdata -S | FileCheck %s --check-prefix=USE -; RUN: opt < %s -passes=pgo-instr-use -pgo-test-profile-file=%t.profdata -S | FileCheck %s --check-prefix=USE +; RUN: opt < %s -pgo-instr-use -pgo-instrument-entry=false -pgo-test-profile-file=%t.profdata -S | FileCheck %s --check-prefix=USE +; RUN: opt < %s -passes=pgo-instr-use -pgo-instrument-entry=false -pgo-test-profile-file=%t.profdata -S | FileCheck %s --check-prefix=USE +; RUN: llvm-profdata merge %S/Inputs/irreducible_entry.proftext -o %t2.profdata +; RUN: opt < %s -pgo-instr-use -pgo-instrument-entry=true -pgo-test-profile-file=%t2.profdata -S | FileCheck %s --check-prefix=USE +; RUN: opt < %s -passes=pgo-instr-use -pgo-instrument-entry=true -pgo-test-profile-file=%t2.profdata -S | FileCheck %s --check-prefix=USE ; GEN: $__llvm_profile_raw_version = comdat any Index: llvm/test/Transforms/PGOProfile/landingpad.ll =================================================================== --- llvm/test/Transforms/PGOProfile/landingpad.ll +++ llvm/test/Transforms/PGOProfile/landingpad.ll @@ -1,8 +1,14 @@ -; RUN: opt < %s -pgo-instr-gen -S | FileCheck %s --check-prefix=GEN -; RUN: opt < %s -passes=pgo-instr-gen -S | FileCheck %s --check-prefix=GEN +; RUN: opt < %s -pgo-instr-gen -pgo-instrument-entry=false -S | FileCheck %s --check-prefixes=GEN,NOTENTRY +; RUN: opt < %s -passes=pgo-instr-gen -pgo-instrument-entry=false -S | FileCheck %s --check-prefixes=GEN,NOTENTRY ; RUN: llvm-profdata merge %S/Inputs/landingpad.proftext -o %t.profdata -; RUN: opt < %s -pgo-instr-use -pgo-test-profile-file=%t.profdata -S | FileCheck %s --check-prefix=USE -; RUN: opt < %s -passes=pgo-instr-use -pgo-test-profile-file=%t.profdata -S | FileCheck %s --check-prefix=USE +; RUN: opt < %s -pgo-instr-use -pgo-instrument-entry=false -pgo-test-profile-file=%t.profdata -S | FileCheck %s --check-prefix=USE +; RUN: opt < %s -passes=pgo-instr-use -pgo-instrument-entry=false -pgo-test-profile-file=%t.profdata -S | FileCheck %s --check-prefix=USE +; +; RUN: opt < %s -pgo-instr-gen -pgo-instrument-entry=true -S | FileCheck %s --check-prefixes=GEN,ENTRY +; RUN: opt < %s -passes=pgo-instr-gen -pgo-instrument-entry=true -S | FileCheck %s --check-prefixes=GEN,ENTRY +; RUN: llvm-profdata merge %S/Inputs/landingpad_entry.proftext -o %t2.profdata +; RUN: opt < %s -pgo-instr-use -pgo-instrument-entry=true -pgo-test-profile-file=%t2.profdata -S | FileCheck %s --check-prefix=USE +; RUN: opt < %s -passes=pgo-instr-use -pgo-instrument-entry=true -pgo-test-profile-file=%t2.profdata -S | FileCheck %s --check-prefix=USE target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-unknown-linux-gnu" @@ -46,7 +52,8 @@ define i32 @foo(i32 %i) personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) { entry: ; GEN: entry: -; GEN-NOT: call void @llvm.instrprof.increment +; NOTENTRY-NOT: call void @llvm.instrprof.increment +; ENTRY: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @__profn_foo, i32 0, i32 0), i64 59130013419, i32 4, i32 0) %rem = srem i32 %i, 2 %tobool = icmp ne i32 %rem, 0 br i1 %tobool, label %if.then, label %if.end @@ -102,7 +109,8 @@ if.end: ; GEN: if.end: -; GEN: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @__profn_foo, i32 0, i32 0), i64 59130013419, i32 4, i32 0) +; NOTENTRY: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @__profn_foo, i32 0, i32 0), i64 59130013419, i32 4, i32 0) +; ENTRY-NOT: call void @llvm.instrprof.increment %tmp8 = load i32, i32* @val, align 4 %add = add nsw i32 %tmp8, %i store i32 %add, i32* @val, align 4 Index: llvm/test/Transforms/PGOProfile/loop1.ll =================================================================== --- llvm/test/Transforms/PGOProfile/loop1.ll +++ llvm/test/Transforms/PGOProfile/loop1.ll @@ -1,8 +1,14 @@ -; RUN: opt < %s -pgo-instr-gen -S | FileCheck %s --check-prefix=GEN -; RUN: opt < %s -passes=pgo-instr-gen -S | FileCheck %s --check-prefix=GEN +; RUN: opt < %s -pgo-instr-gen -pgo-instrument-entry=false -S | FileCheck %s --check-prefixes=GEN,NOTENTRY +; RUN: opt < %s -passes=pgo-instr-gen -pgo-instrument-entry=false -S | FileCheck %s --check-prefixes=GEN,NOTENTRY ; RUN: llvm-profdata merge %S/Inputs/loop1.proftext -o %t.profdata -; RUN: opt < %s -pgo-instr-use -pgo-test-profile-file=%t.profdata -S | FileCheck %s --check-prefix=USE -; RUN: opt < %s -passes=pgo-instr-use -pgo-test-profile-file=%t.profdata -S | FileCheck %s --check-prefix=USE +; RUN: opt < %s -pgo-instr-use -pgo-instrument-entry=false -pgo-test-profile-file=%t.profdata -S | FileCheck %s --check-prefix=USE +; RUN: opt < %s -passes=pgo-instr-use -pgo-instrument-entry=false -pgo-test-profile-file=%t.profdata -S | FileCheck %s --check-prefix=USE +; RUN: opt < %s -pgo-instr-gen -pgo-instrument-entry=true -S | FileCheck %s --check-prefixes=GEN,ENTRY +; RUN: opt < %s -passes=pgo-instr-gen -pgo-instrument-entry=true -S | FileCheck %s --check-prefixes=GEN,ENTRY +; RUN: llvm-profdata merge %S/Inputs/loop1_entry.proftext -o %t.profdata +; RUN: opt < %s -pgo-instr-use -pgo-instrument-entry=true -pgo-test-profile-file=%t.profdata -S | FileCheck %s --check-prefix=USE +; RUN: opt < %s -passes=pgo-instr-use -pgo-instrument-entry=true -pgo-test-profile-file=%t.profdata -S | FileCheck %s --check-prefix=USE + target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-unknown-linux-gnu" @@ -13,7 +19,8 @@ define i32 @test_simple_for(i32 %n) { entry: ; GEN: entry: -; GEN: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @__profn_test_simple_for, i32 0, i32 0), i64 34137660316, i32 2, i32 1) +; NOTENTRY: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @__profn_test_simple_for, i32 0, i32 0), i64 34137660316, i32 2, i32 1) +; ENTRY: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @__profn_test_simple_for, i32 0, i32 0), i64 34137660316, i32 2, i32 0) br label %for.cond for.cond: @@ -35,7 +42,8 @@ for.inc: ; GEN: for.inc: -; GEN: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @__profn_test_simple_for, i32 0, i32 0), i64 34137660316, i32 2, i32 0) +; NOTENTRY: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @__profn_test_simple_for, i32 0, i32 0), i64 34137660316, i32 2, i32 0) +; ENTRY: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @__profn_test_simple_for, i32 0, i32 0), i64 34137660316, i32 2, i32 1) %inc1 = add nsw i32 %i, 1 br label %for.cond Index: llvm/test/Transforms/PGOProfile/loop2.ll =================================================================== --- llvm/test/Transforms/PGOProfile/loop2.ll +++ llvm/test/Transforms/PGOProfile/loop2.ll @@ -1,8 +1,13 @@ -; RUN: opt < %s -pgo-instr-gen -S | FileCheck %s --check-prefix=GEN -; RUN: opt < %s -passes=pgo-instr-gen -S | FileCheck %s --check-prefix=GEN +; RUN: opt < %s -pgo-instr-gen -pgo-instrument-entry=false -S | FileCheck %s --check-prefixes=GEN,NOTENTRY +; RUN: opt < %s -passes=pgo-instr-gen -pgo-instrument-entry=false -S | FileCheck %s --check-prefixes=GEN,NOTENTRY ; RUN: llvm-profdata merge %S/Inputs/loop2.proftext -o %t.profdata -; RUN: opt < %s -pgo-instr-use -pgo-test-profile-file=%t.profdata -S | FileCheck %s --check-prefix=USE -; RUN: opt < %s -passes=pgo-instr-use -pgo-test-profile-file=%t.profdata -S | FileCheck %s --check-prefix=USE +; RUN: opt < %s -pgo-instr-use -pgo-instrument-entry=false -pgo-test-profile-file=%t.profdata -S | FileCheck %s --check-prefix=USE +; RUN: opt < %s -passes=pgo-instr-use -pgo-instrument-entry=false -pgo-test-profile-file=%t.profdata -S | FileCheck %s --check-prefix=USE +; RUN: opt < %s -pgo-instr-gen -pgo-instrument-entry=true -S | FileCheck %s --check-prefixes=GEN,ENTRY +; RUN: opt < %s -passes=pgo-instr-gen -pgo-instrument-entry=true -S | FileCheck %s --check-prefixes=GEN,ENTRY +; RUN: llvm-profdata merge %S/Inputs/loop2_entry.proftext -o %t.profdata +; RUN: opt < %s -pgo-instr-use -pgo-instrument-entry=true -pgo-test-profile-file=%t.profdata -S | FileCheck %s --check-prefix=USE +; RUN: opt < %s -passes=pgo-instr-use -pgo-instrument-entry=true -pgo-test-profile-file=%t.profdata -S | FileCheck %s --check-prefix=USE target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-unknown-linux-gnu" @@ -13,7 +18,8 @@ define i32 @test_nested_for(i32 %r, i32 %s) { entry: ; GEN: entry: -; GEN: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @__profn_test_nested_for, i32 0, i32 0), i64 53929068288, i32 3, i32 2) +; NOTENTRY: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @__profn_test_nested_for, i32 0, i32 0), i64 53929068288, i32 3, i32 2) +; ENTRY: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @__profn_test_nested_for, i32 0, i32 0), i64 53929068288, i32 3, i32 0) br label %for.cond.outer for.cond.outer: @@ -49,7 +55,8 @@ for.inc.inner: ; GEN: for.inc.inner: -; GEN: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @__profn_test_nested_for, i32 0, i32 0), i64 53929068288, i32 3, i32 0) +; NOTENTRY: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @__profn_test_nested_for, i32 0, i32 0), i64 53929068288, i32 3, i32 0) +; ENTRY: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @__profn_test_nested_for, i32 0, i32 0), i64 53929068288, i32 3, i32 1) %inc.1 = add nsw i32 %j.0, 1 br label %for.cond.inner @@ -59,7 +66,8 @@ for.inc.outer: ; GEN: for.inc.outer: -; GEN: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @__profn_test_nested_for, i32 0, i32 0), i64 53929068288, i32 3, i32 1) +; NOTENTRY: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @__profn_test_nested_for, i32 0, i32 0), i64 53929068288, i32 3, i32 1) +; ENTRY: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @__profn_test_nested_for, i32 0, i32 0), i64 53929068288, i32 3, i32 2) %inc.2 = add nsw i32 %i.0, 1 br label %for.cond.outer Index: llvm/test/Transforms/PGOProfile/misexpect-branch-stripped.ll =================================================================== --- llvm/test/Transforms/PGOProfile/misexpect-branch-stripped.ll +++ llvm/test/Transforms/PGOProfile/misexpect-branch-stripped.ll @@ -1,20 +1,28 @@ - ; RUN: llvm-profdata merge %S/Inputs/misexpect-branch.proftext -o %t.profdata - -; RUN: opt < %s -lower-expect -pgo-instr-use -pgo-test-profile-file=%t.profdata -S -pgo-warn-misexpect 2>&1 | FileCheck %s --check-prefix=WARNING -; RUN: opt < %s -lower-expect -pgo-instr-use -pgo-test-profile-file=%t.profdata -S -pass-remarks=misexpect 2>&1 | FileCheck %s --check-prefix=REMARK -; RUN: opt < %s -lower-expect -pgo-instr-use -pgo-test-profile-file=%t.profdata -S -pgo-warn-misexpect -pass-remarks=misexpect 2>&1 | FileCheck %s --check-prefix=BOTH -; RUN: opt < %s -lower-expect -pgo-instr-use -pgo-test-profile-file=%t.profdata -S 2>&1 | FileCheck %s --check-prefix=DISABLED +; RUN: opt < %s -lower-expect -pgo-instr-use -pgo-instrument-entry=false -pgo-test-profile-file=%t.profdata -S -pgo-warn-misexpect 2>&1 | FileCheck %s --check-prefix=WARNING +; RUN: opt < %s -lower-expect -pgo-instr-use -pgo-instrument-entry=false -pgo-test-profile-file=%t.profdata -S -pass-remarks=misexpect 2>&1 | FileCheck %s --check-prefix=REMARK +; RUN: opt < %s -lower-expect -pgo-instr-use -pgo-instrument-entry=false -pgo-test-profile-file=%t.profdata -S -pgo-warn-misexpect -pass-remarks=misexpect 2>&1 | FileCheck %s --check-prefix=BOTH +; RUN: opt < %s -lower-expect -pgo-instr-use -pgo-instrument-entry=false -pgo-test-profile-file=%t.profdata -S 2>&1 | FileCheck %s --check-prefix=DISABLED ; New PM -; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-test-profile-file=%t.profdata -pgo-warn-misexpect -S 2>&1 | FileCheck %s --check-prefix=WARNING -; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-test-profile-file=%t.profdata -pass-remarks=misexpect -S 2>&1 | FileCheck %s --check-prefix=REMARK -; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-test-profile-file=%t.profdata -pgo-warn-misexpect -pass-remarks=misexpect -S 2>&1 | FileCheck %s --check-prefix=BOTH -; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-test-profile-file=%t.profdata -S 2>&1 | FileCheck %s --check-prefix=DISABLED +; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-instrument-entry=false -pgo-test-profile-file=%t.profdata -pgo-warn-misexpect -S 2>&1 | FileCheck %s --check-prefix=WARNING +; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-instrument-entry=false -pgo-test-profile-file=%t.profdata -pass-remarks=misexpect -S 2>&1 | FileCheck %s --check-prefix=REMARK +; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-instrument-entry=false -pgo-test-profile-file=%t.profdata -pgo-warn-misexpect -pass-remarks=misexpect -S 2>&1 | FileCheck %s --check-prefix=BOTH +; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-instrument-entry=false -pgo-test-profile-file=%t.profdata -S 2>&1 | FileCheck %s --check-prefix=DISABLED +; RUN: llvm-profdata merge %S/Inputs/misexpect-branch_entry.proftext -o %t2.profdata +; RUN: opt < %s -lower-expect -pgo-instr-use -pgo-instrument-entry=true -pgo-test-profile-file=%t2.profdata -S -pgo-warn-misexpect 2>&1 | FileCheck %s --check-prefix=WARNING +; RUN: opt < %s -lower-expect -pgo-instr-use -pgo-instrument-entry=true -pgo-test-profile-file=%t2.profdata -S -pass-remarks=misexpect 2>&1 | FileCheck %s --check-prefix=REMARK +; RUN: opt < %s -lower-expect -pgo-instr-use -pgo-instrument-entry=true -pgo-test-profile-file=%t2.profdata -S -pgo-warn-misexpect -pass-remarks=misexpect 2>&1 | FileCheck %s --check-prefix=BOTH +; RUN: opt < %s -lower-expect -pgo-instr-use -pgo-instrument-entry=true -pgo-test-profile-file=%t2.profdata -S 2>&1 | FileCheck %s --check-prefix=DISABLED +; New PM +; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-instrument-entry=true -pgo-test-profile-file=%t2.profdata -pgo-warn-misexpect -S 2>&1 | FileCheck %s --check-prefix=WARNING +; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-instrument-entry=true -pgo-test-profile-file=%t2.profdata -pass-remarks=misexpect -S 2>&1 | FileCheck %s --check-prefix=REMARK +; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-instrument-entry=true -pgo-test-profile-file=%t2.profdata -pgo-warn-misexpect -pass-remarks=misexpect -S 2>&1 | FileCheck %s --check-prefix=BOTH +; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-instrument-entry=true -pgo-test-profile-file=%t2.profdata -S 2>&1 | FileCheck %s --check-prefix=DISABLED ; WARNING-DAG: warning: :0:0: 19.98% ; WARNING-NOT: remark: :0:0: Potential performance regression from use of the llvm.expect intrinsic: Annotation was correct on 19.98% (399668 / 2000000) of profiled executions. Index: llvm/test/Transforms/PGOProfile/misexpect-branch.ll =================================================================== --- llvm/test/Transforms/PGOProfile/misexpect-branch.ll +++ llvm/test/Transforms/PGOProfile/misexpect-branch.ll @@ -1,19 +1,28 @@ - ; RUN: llvm-profdata merge %S/Inputs/misexpect-branch.proftext -o %t.profdata - -; RUN: opt < %s -lower-expect -pgo-instr-use -pgo-test-profile-file=%t.profdata -S -pgo-warn-misexpect 2>&1 | FileCheck %s --check-prefix=WARNING -; RUN: opt < %s -lower-expect -pgo-instr-use -pgo-test-profile-file=%t.profdata -S -pass-remarks=misexpect 2>&1 | FileCheck %s --check-prefix=REMARK -; RUN: opt < %s -lower-expect -pgo-instr-use -pgo-test-profile-file=%t.profdata -S -pgo-warn-misexpect -pass-remarks=misexpect 2>&1 | FileCheck %s --check-prefix=BOTH -; RUN: opt < %s -lower-expect -pgo-instr-use -pgo-test-profile-file=%t.profdata -S 2>&1 | FileCheck %s --check-prefix=DISABLED +; RUN: opt < %s -lower-expect -pgo-instr-use -pgo-instrument-entry=false -pgo-test-profile-file=%t.profdata -S -pgo-warn-misexpect 2>&1 | FileCheck %s --check-prefix=WARNING +; RUN: opt < %s -lower-expect -pgo-instr-use -pgo-instrument-entry=false -pgo-test-profile-file=%t.profdata -S -pass-remarks=misexpect 2>&1 | FileCheck %s --check-prefix=REMARK +; RUN: opt < %s -lower-expect -pgo-instr-use -pgo-instrument-entry=false -pgo-test-profile-file=%t.profdata -S -pgo-warn-misexpect -pass-remarks=misexpect 2>&1 | FileCheck %s --check-prefix=BOTH +; RUN: opt < %s -lower-expect -pgo-instr-use -pgo-instrument-entry=false -pgo-test-profile-file=%t.profdata -S 2>&1 | FileCheck %s --check-prefix=DISABLED ; New PM -; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-test-profile-file=%t.profdata -pgo-warn-misexpect -S 2>&1 | FileCheck %s --check-prefix=WARNING -; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-test-profile-file=%t.profdata -pass-remarks=misexpect -S 2>&1 | FileCheck %s --check-prefix=REMARK -; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-test-profile-file=%t.profdata -pgo-warn-misexpect -pass-remarks=misexpect -S 2>&1 | FileCheck %s --check-prefix=BOTH -; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-test-profile-file=%t.profdata -S 2>&1 | FileCheck %s --check-prefix=DISABLED +; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-instrument-entry=false -pgo-test-profile-file=%t.profdata -pgo-warn-misexpect -S 2>&1 | FileCheck %s --check-prefix=WARNING +; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-instrument-entry=false -pgo-test-profile-file=%t.profdata -pass-remarks=misexpect -S 2>&1 | FileCheck %s --check-prefix=REMARK +; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-instrument-entry=false -pgo-test-profile-file=%t.profdata -pgo-warn-misexpect -pass-remarks=misexpect -S 2>&1 | FileCheck %s --check-prefix=BOTH +; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-instrument-entry=false -pgo-test-profile-file=%t.profdata -S 2>&1 | FileCheck %s --check-prefix=DISABLED +; RUN: llvm-profdata merge %S/Inputs/misexpect-branch_entry.proftext -o %t2.profdata +; RUN: opt < %s -lower-expect -pgo-instr-use -pgo-instrument-entry=true -pgo-test-profile-file=%t2.profdata -S -pgo-warn-misexpect 2>&1 | FileCheck %s --check-prefix=WARNING +; RUN: opt < %s -lower-expect -pgo-instr-use -pgo-instrument-entry=true -pgo-test-profile-file=%t2.profdata -S -pass-remarks=misexpect 2>&1 | FileCheck %s --check-prefix=REMARK +; RUN: opt < %s -lower-expect -pgo-instr-use -pgo-instrument-entry=true -pgo-test-profile-file=%t2.profdata -S -pgo-warn-misexpect -pass-remarks=misexpect 2>&1 | FileCheck %s --check-prefix=BOTH +; RUN: opt < %s -lower-expect -pgo-instr-use -pgo-instrument-entry=true -pgo-test-profile-file=%t2.profdata -S 2>&1 | FileCheck %s --check-prefix=DISABLED + +; New PM +; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-instrument-entry=true -pgo-test-profile-file=%t2.profdata -pgo-warn-misexpect -S 2>&1 | FileCheck %s --check-prefix=WARNING +; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-instrument-entry=true -pgo-test-profile-file=%t2.profdata -pass-remarks=misexpect -S 2>&1 | FileCheck %s --check-prefix=REMARK +; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-instrument-entry=true -pgo-test-profile-file=%t2.profdata -pgo-warn-misexpect -pass-remarks=misexpect -S 2>&1 | FileCheck %s --check-prefix=BOTH +; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-instrument-entry=true -pgo-test-profile-file=%t2.profdata -S 2>&1 | FileCheck %s --check-prefix=DISABLED ; WARNING-DAG: warning: misexpect-branch.c:22:0: 19.98% ; WARNING-NOT: remark: misexpect-branch.c:22:0: Potential performance regression from use of the llvm.expect intrinsic: Annotation was correct on 19.98% (399668 / 2000000) of profiled executions. Index: llvm/test/Transforms/PGOProfile/misexpect-switch-default.ll =================================================================== --- llvm/test/Transforms/PGOProfile/misexpect-switch-default.ll +++ llvm/test/Transforms/PGOProfile/misexpect-switch-default.ll @@ -1,16 +1,15 @@ - ; RUN: llvm-profdata merge %S/Inputs/misexpect-switch.proftext -o %t.profdata -; RUN: opt < %s -lower-expect -pgo-instr-use -pgo-test-profile-file=%t.profdata -S -pgo-warn-misexpect 2>&1 | FileCheck %s --check-prefix=WARNING -; RUN: opt < %s -lower-expect -pgo-instr-use -pgo-test-profile-file=%t.profdata -S -pass-remarks=misexpect 2>&1 | FileCheck %s --check-prefix=REMARK -; RUN: opt < %s -lower-expect -pgo-instr-use -pgo-test-profile-file=%t.profdata -S -pgo-warn-misexpect -pass-remarks=misexpect 2>&1 | FileCheck %s --check-prefix=BOTH -; RUN: opt < %s -lower-expect -pgo-instr-use -pgo-test-profile-file=%t.profdata -S 2>&1 | FileCheck %s --check-prefix=DISABLED +; RUN: opt < %s -lower-expect -pgo-instrument-entry=false -pgo-instr-use -pgo-test-profile-file=%t.profdata -S -pgo-warn-misexpect 2>&1 | FileCheck %s --check-prefix=WARNING +; RUN: opt < %s -lower-expect -pgo-instrument-entry=false -pgo-instr-use -pgo-test-profile-file=%t.profdata -S -pass-remarks=misexpect 2>&1 | FileCheck %s --check-prefix=REMARK +; RUN: opt < %s -lower-expect -pgo-instrument-entry=false -pgo-instr-use -pgo-test-profile-file=%t.profdata -S -pgo-warn-misexpect -pass-remarks=misexpect 2>&1 | FileCheck %s --check-prefix=BOTH +; RUN: opt < %s -lower-expect -pgo-instrument-entry=false -pgo-instr-use -pgo-test-profile-file=%t.profdata -S 2>&1 | FileCheck %s --check-prefix=DISABLED ; New PM -; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-test-profile-file=%t.profdata -pgo-warn-misexpect -S 2>&1 | FileCheck %s --check-prefix=WARNING -; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-test-profile-file=%t.profdata -pass-remarks=misexpect -S 2>&1 | FileCheck %s --check-prefix=REMARK -; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-test-profile-file=%t.profdata -pgo-warn-misexpect -pass-remarks=misexpect -S 2>&1 | FileCheck %s --check-prefix=BOTH -; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-test-profile-file=%t.profdata -S 2>&1 | FileCheck %s --check-prefix=DISABLED +; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-instrument-entry=false -pgo-test-profile-file=%t.profdata -pgo-warn-misexpect -S 2>&1 | FileCheck %s --check-prefix=WARNING +; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-instrument-entry=false -pgo-test-profile-file=%t.profdata -pass-remarks=misexpect -S 2>&1 | FileCheck %s --check-prefix=REMARK +; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-instrument-entry=false -pgo-test-profile-file=%t.profdata -pgo-warn-misexpect -pass-remarks=misexpect -S 2>&1 | FileCheck %s --check-prefix=BOTH +; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-instrument-entry=false -pgo-test-profile-file=%t.profdata -S 2>&1 | FileCheck %s --check-prefix=DISABLED ; WARNING-DAG: warning: :0:0: 0.00% ; WARNING-NOT: remark: :0:0: Potential performance regression from use of the llvm.expect intrinsic: Annotation was correct on 0.00% (0 / 27943) of profiled executions. @@ -32,7 +31,6 @@ ; CHECK-DAG: !{!"misexpect", i64 0, i64 2000, i64 1} - ; ModuleID = 'misexpect-switch.c' source_filename = "misexpect-switch.c" target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" Index: llvm/test/Transforms/PGOProfile/misexpect-switch.ll =================================================================== --- llvm/test/Transforms/PGOProfile/misexpect-switch.ll +++ llvm/test/Transforms/PGOProfile/misexpect-switch.ll @@ -1,21 +1,36 @@ - ; RUN: llvm-profdata merge %S/Inputs/misexpect-switch.proftext -o %t.profdata ; RUN: llvm-profdata merge %S/Inputs/misexpect-switch-correct.proftext -o %t.c.profdata -; RUN: opt < %s -lower-expect -pgo-instr-use -pgo-test-profile-file=%t.profdata -S -pgo-warn-misexpect 2>&1 | FileCheck %s --check-prefix=WARNING -; RUN: opt < %s -lower-expect -pgo-instr-use -pgo-test-profile-file=%t.profdata -S -pass-remarks=misexpect 2>&1 | FileCheck %s --check-prefix=REMARK -; RUN: opt < %s -lower-expect -pgo-instr-use -pgo-test-profile-file=%t.profdata -S -pgo-warn-misexpect -pass-remarks=misexpect 2>&1 | FileCheck %s --check-prefix=BOTH -; RUN: opt < %s -lower-expect -pgo-instr-use -pgo-test-profile-file=%t.profdata -S 2>&1 | FileCheck %s --check-prefix=DISABLED +; RUN: opt < %s -lower-expect -pgo-instr-use -pgo-instrument-entry=false -pgo-test-profile-file=%t.profdata -S -pgo-warn-misexpect 2>&1 | FileCheck %s --check-prefix=WARNING +; RUN: opt < %s -lower-expect -pgo-instr-use -pgo-instrument-entry=false -pgo-test-profile-file=%t.profdata -S -pass-remarks=misexpect 2>&1 | FileCheck %s --check-prefix=REMARK +; RUN: opt < %s -lower-expect -pgo-instr-use -pgo-instrument-entry=false -pgo-test-profile-file=%t.profdata -S -pgo-warn-misexpect -pass-remarks=misexpect 2>&1 | FileCheck %s --check-prefix=BOTH +; RUN: opt < %s -lower-expect -pgo-instr-use -pgo-instrument-entry=false -pgo-test-profile-file=%t.profdata -S 2>&1 | FileCheck %s --check-prefix=DISABLED ; New PM -; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-test-profile-file=%t.profdata -pgo-warn-misexpect -S 2>&1 | FileCheck %s --check-prefix=WARNING -; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-test-profile-file=%t.profdata -pass-remarks=misexpect -S 2>&1 | FileCheck %s --check-prefix=REMARK -; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-test-profile-file=%t.profdata -pgo-warn-misexpect -pass-remarks=misexpect -S 2>&1 | FileCheck %s --check-prefix=BOTH -; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-test-profile-file=%t.profdata -S 2>&1 | FileCheck %s --check-prefix=DISABLED +; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-instrument-entry=false -pgo-test-profile-file=%t.profdata -pgo-warn-misexpect -S 2>&1 | FileCheck %s --check-prefix=WARNING +; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-instrument-entry=false -pgo-test-profile-file=%t.profdata -pass-remarks=misexpect -S 2>&1 | FileCheck %s --check-prefix=REMARK +; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-instrument-entry=false -pgo-test-profile-file=%t.profdata -pgo-warn-misexpect -pass-remarks=misexpect -S 2>&1 | FileCheck %s --check-prefix=BOTH +; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-instrument-entry=false -pgo-test-profile-file=%t.profdata -S 2>&1 | FileCheck %s --check-prefix=DISABLED + +; RUN: opt < %s -lower-expect -pgo-instr-use -pgo-instrument-entry=false -pgo-test-profile-file=%t.c.profdata -S -pgo-warn-misexpect -pass-remarks=misexpect 2>&1 | FileCheck %s --check-prefix=CORRECT +; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-instrument-entry=false -pgo-test-profile-file=%t.c.profdata -pgo-warn-misexpect -pass-remarks=misexpect -S 2>&1 | FileCheck %s --check-prefix=CORRECT -; RUN: opt < %s -lower-expect -pgo-instr-use -pgo-test-profile-file=%t.c.profdata -S -pgo-warn-misexpect -pass-remarks=misexpect 2>&1 | FileCheck %s --check-prefix=CORRECT -; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-test-profile-file=%t.c.profdata -pgo-warn-misexpect -pass-remarks=misexpect -S 2>&1 | FileCheck %s --check-prefix=CORRECT +; RUN: llvm-profdata merge %S/Inputs/misexpect-switch_entry.proftext -o %t2.profdata +; RUN: llvm-profdata merge %S/Inputs/misexpect-switch-correct_entry.proftext -o %t2.c.profdata +; RUN: opt < %s -lower-expect -pgo-instr-use -pgo-instrument-entry=true -pgo-test-profile-file=%t2.profdata -S -pgo-warn-misexpect 2>&1 | FileCheck %s --check-prefix=WARNING +; RUN: opt < %s -lower-expect -pgo-instr-use -pgo-instrument-entry=true -pgo-test-profile-file=%t2.profdata -S -pass-remarks=misexpect 2>&1 | FileCheck %s --check-prefix=REMARK +; RUN: opt < %s -lower-expect -pgo-instr-use -pgo-instrument-entry=true -pgo-test-profile-file=%t2.profdata -S -pgo-warn-misexpect -pass-remarks=misexpect 2>&1 | FileCheck %s --check-prefix=BOTH +; RUN: opt < %s -lower-expect -pgo-instr-use -pgo-instrument-entry=true -pgo-test-profile-file=%t2.profdata -S 2>&1 | FileCheck %s --check-prefix=DISABLED + +; New PM +; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-instrument-entry=true -pgo-test-profile-file=%t2.profdata -pgo-warn-misexpect -S 2>&1 | FileCheck %s --check-prefix=WARNING +; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-instrument-entry=true -pgo-test-profile-file=%t2.profdata -pass-remarks=misexpect -S 2>&1 | FileCheck %s --check-prefix=REMARK +; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-instrument-entry=true -pgo-test-profile-file=%t2.profdata -pgo-warn-misexpect -pass-remarks=misexpect -S 2>&1 | FileCheck %s --check-prefix=BOTH +; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-instrument-entry=true -pgo-test-profile-file=%t2.profdata -S 2>&1 | FileCheck %s --check-prefix=DISABLED + +; RUN: opt < %s -lower-expect -pgo-instr-use -pgo-instrument-entry=true -pgo-test-profile-file=%t2.c.profdata -S -pgo-warn-misexpect -pass-remarks=misexpect 2>&1 | FileCheck %s --check-prefix=CORRECT +; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-instrument-entry=true -pgo-test-profile-file=%t2.c.profdata -pgo-warn-misexpect -pass-remarks=misexpect -S 2>&1 | FileCheck %s --check-prefix=CORRECT ; WARNING-DAG: warning: misexpect-switch.c:26:5: 0.00% ; WARNING-NOT: remark: misexpect-switch.c:26:5: Potential performance regression from use of the llvm.expect intrinsic: Annotation was correct on 0.00% (0 / 8112) of profiled executions. @@ -35,8 +50,6 @@ ; CORRECT-NOT: remark: {{.*}} ; CHECK-DAG: !{!"misexpect", i64 0, i64 2000, i64 1} - - ; ModuleID = 'misexpect-switch.c' source_filename = "misexpect-switch.c" target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" Index: llvm/test/Transforms/PGOProfile/switch.ll =================================================================== --- llvm/test/Transforms/PGOProfile/switch.ll +++ llvm/test/Transforms/PGOProfile/switch.ll @@ -1,8 +1,13 @@ -; RUN: opt < %s -pgo-instr-gen -S | FileCheck %s --check-prefix=GEN -; RUN: opt < %s -passes=pgo-instr-gen -S | FileCheck %s --check-prefix=GEN +; RUN: opt < %s -pgo-instr-gen -pgo-instrument-entry=false -S | FileCheck %s --check-prefixes=GEN,NOTENTRY +; RUN: opt < %s -passes=pgo-instr-gen -pgo-instrument-entry=false -S | FileCheck %s --check-prefixes=GEN,NOTENTRY ; RUN: llvm-profdata merge %S/Inputs/switch.proftext -o %t.profdata -; RUN: opt < %s -pgo-instr-use -pgo-test-profile-file=%t.profdata -S | FileCheck %s --check-prefix=USE -; RUN: opt < %s -passes=pgo-instr-use -pgo-test-profile-file=%t.profdata -S | FileCheck %s --check-prefix=USE +; RUN: opt < %s -pgo-instr-use -pgo-instrument-entry=false -pgo-test-profile-file=%t.profdata -S | FileCheck %s --check-prefix=USE +; RUN: opt < %s -passes=pgo-instr-use -pgo-instrument-entry=false -pgo-test-profile-file=%t.profdata -S | FileCheck %s --check-prefix=USE +; RUN: opt < %s -pgo-instr-gen -pgo-instrument-entry=true -S | FileCheck %s --check-prefixes=GEN,ENTRY +; RUN: opt < %s -passes=pgo-instr-gen -pgo-instrument-entry=true -S | FileCheck %s --check-prefixes=GEN,ENTRY +; RUN: llvm-profdata merge %S/Inputs/switch_entry.proftext -o %t.profdata +; RUN: opt < %s -pgo-instr-use -pgo-instrument-entry=true -pgo-test-profile-file=%t.profdata -S | FileCheck %s --check-prefix=USE +; RUN: opt < %s -passes=pgo-instr-use -pgo-instrument-entry=true -pgo-test-profile-file=%t.profdata -S | FileCheck %s --check-prefix=USE target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-unknown-linux-gnu" @@ -13,7 +18,8 @@ define void @test_switch(i32 %i) { entry: ; GEN: entry: -; GEN-NOT: call void @llvm.instrprof.increment +; NOTENTRY-NOT: call void @llvm.instrprof.increment +; ENTRY: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__profn_test_switch, i32 0, i32 0), i64 46200943743, i32 4, i32 0) switch i32 %i, label %sw.default [ i32 1, label %sw.bb i32 2, label %sw.bb1 @@ -30,7 +36,8 @@ sw.bb1: ; GEN: sw.bb1: -; GEN: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__profn_test_switch, i32 0, i32 0), i64 46200943743, i32 4, i32 0) +; NOTENTRY: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__profn_test_switch, i32 0, i32 0), i64 46200943743, i32 4, i32 0) +; ENTRY-NOT: call void @llvm.instrprof.increment br label %sw.epilog sw.bb2: Index: llvm/test/Transforms/PGOProfile/thinlto_cspgo_use.ll =================================================================== --- llvm/test/Transforms/PGOProfile/thinlto_cspgo_use.ll +++ llvm/test/Transforms/PGOProfile/thinlto_cspgo_use.ll @@ -3,7 +3,7 @@ ; RUN: opt -module-summary %s -o %t1.bc ; RUN: opt -module-summary %S/Inputs/thinlto_cspgo_bar_use.ll -o %t2.bc ; RUN: llvm-profdata merge %S/Inputs/thinlto_cs.proftext -o %t3.profdata -; RUN: llvm-lto2 run -lto-cspgo-profile-file=%t3.profdata -save-temps -o %t %t1.bc %t2.bc \ +; RUN: llvm-lto2 run -lto-cspgo-profile-file=%t3.profdata -pgo-instrument-entry=false -save-temps -o %t %t1.bc %t2.bc \ ; RUN: -r=%t1.bc,foo,pl \ ; RUN: -r=%t1.bc,bar,l \ ; RUN: -r=%t1.bc,main,plx \