diff --git a/llvm/test/tools/llvm-profgen/cs-preinline.test b/llvm/test/tools/llvm-profgen/cs-preinline.test --- a/llvm/test/tools/llvm-profgen/cs-preinline.test +++ b/llvm/test/tools/llvm-profgen/cs-preinline.test @@ -3,20 +3,20 @@ ; RUN: FileCheck %s --input-file %t --check-prefix=CHECK-DEFAULT ; Test llvm-profgen with preinliner on will merge not inlinable profile into base profile. -; RUN: llvm-profgen --format=text --perfscript=%S/Inputs/inline-cs-noprobe.perfscript --binary=%S/Inputs/inline-cs-noprobe.perfbin --output=%t --csspgo-preinliner=1 +; RUN: llvm-profgen --format=text --perfscript=%S/Inputs/inline-cs-noprobe.perfscript --binary=%S/Inputs/inline-cs-noprobe.perfbin --csspgo-preinliner=1 --sample-profile-hot-inline-threshold=3000 --sample-profile-cold-inline-threshold=45 --output=%t ; RUN: FileCheck %s --input-file %t --check-prefix=CHECK-PREINL ; Test preinliner threshold that prevents all possible inlining and merges everything into base profile. -; RUN: llvm-profgen --format=text --perfscript=%S/Inputs/inline-cs-noprobe.perfscript --binary=%S/Inputs/inline-cs-noprobe.perfbin --output=%t --csspgo-preinliner=1 -sample-profile-cold-inline-threshold=0 +; RUN: llvm-profgen --format=text --perfscript=%S/Inputs/inline-cs-noprobe.perfscript --binary=%S/Inputs/inline-cs-noprobe.perfbin --csspgo-preinliner=1 --sample-profile-hot-inline-threshold=3000 --sample-profile-cold-inline-threshold=0 --output=%t ; RUN: FileCheck %s --input-file %t --check-prefix=CHECK-NO-PREINL ; Test cold profile trimming. Only base profiles should be dropped. -; RUN: llvm-profgen --format=text --perfscript=%S/Inputs/inline-cs-noprobe.perfscript --binary=%S/Inputs/inline-cs-noprobe.perfbin --output=%t --csspgo-preinliner=1 --trim-cold-profile=1 --profile-summary-hot-count=400 +; RUN: llvm-profgen --format=text --perfscript=%S/Inputs/inline-cs-noprobe.perfscript --binary=%S/Inputs/inline-cs-noprobe.perfbin --csspgo-preinliner=1 --sample-profile-hot-inline-threshold=3000 --sample-profile-cold-inline-threshold=45 --output=%t --trim-cold-profile=1 --profile-summary-hot-count=400 ; RUN: FileCheck %s --input-file %t --check-prefix=CHECK-TRIM ; Test llvm-profgen with preinliner on will merge not inlinable profile into base profile. -; RUN: llvm-profgen --format=text --perfscript=%S/Inputs/inline-cs-noprobe.perfscript --binary=%S/Inputs/inline-cs-noprobe.perfbin --output=%t --csspgo-preinliner=1 --gen-cs-nested-profile=1 +; RUN: llvm-profgen --format=text --perfscript=%S/Inputs/inline-cs-noprobe.perfscript --binary=%S/Inputs/inline-cs-noprobe.perfbin --csspgo-preinliner=1 --sample-profile-hot-inline-threshold=3000 --sample-profile-cold-inline-threshold=45 --output=%t --gen-cs-nested-profile=1 ; RUN: FileCheck %s --input-file %t --check-prefix=CHECK-PREINL-NEST ; CHECK-DEFAULT: [main:1 @ foo]:309:0 diff --git a/llvm/tools/llvm-profgen/CSPreInliner.cpp b/llvm/tools/llvm-profgen/CSPreInliner.cpp --- a/llvm/tools/llvm-profgen/CSPreInliner.cpp +++ b/llvm/tools/llvm-profgen/CSPreInliner.cpp @@ -61,7 +61,14 @@ // ContextTracker.getFuncNameFor to work, if `Profiles` can have md5 codes // as their profile context. ContextTracker(Profiles, nullptr), ProfileMap(Profiles), Binary(Binary), - HotCountThreshold(HotThreshold), ColdCountThreshold(ColdThreshold) {} + HotCountThreshold(HotThreshold), ColdCountThreshold(ColdThreshold) { + // Set default preinliner hot/cold call site threshold tuned with CSSPGO. + // for good performance with reasonable profile size. + if (!SampleHotCallSiteThreshold.getNumOccurrences()) + SampleHotCallSiteThreshold = 1500; + if (!SampleColdCallSiteThreshold.getNumOccurrences()) + SampleColdCallSiteThreshold = 0; +} std::vector CSPreInliner::buildTopDownOrder() { std::vector Order;