Author: Nikita Popov Date: 2023-02-28T15:23:07+01:00 New Revision: 26202a57e5e78b5473ef657737d181f0a68ed56d
URL: https://github.com/llvm/llvm-project/commit/26202a57e5e78b5473ef657737d181f0a68ed56d DIFF: https://github.com/llvm/llvm-project/commit/26202a57e5e78b5473ef657737d181f0a68ed56d.diff LOG: [CGProfile] Don't fetch BFI without profile (NFCI) Don't fetch BFI if the function has no entry count. Peculiarly, the implementation was already doing this for the (no longer existing) legacy PM implementation, but the same principle applies to the new pass manager. The only reason why the new PM doesn't have LazyBFI is that with the new pass manager all passes are lazy. This improves compile-time for non-PGO builds. Added: Modified: clang/test/CodeGen/sanitizer-module-constructor.c llvm/lib/Transforms/Instrumentation/CGProfile.cpp llvm/test/Other/new-pm-defaults.ll llvm/test/Other/new-pm-lto-defaults.ll llvm/test/Other/new-pm-thinlto-defaults.ll Removed: ################################################################################ diff --git a/clang/test/CodeGen/sanitizer-module-constructor.c b/clang/test/CodeGen/sanitizer-module-constructor.c index abc579c6fe23d..e4d08cde2620a 100644 --- a/clang/test/CodeGen/sanitizer-module-constructor.c +++ b/clang/test/CodeGen/sanitizer-module-constructor.c @@ -18,4 +18,4 @@ void h(void) { f(e); } // CHECK: Running pass: {{.*}}SanitizerPass // CHECK-NOT: Running pass: LoopSimplifyPass on {{.*}}san.module_ctor -// CHECK: Running analysis: DominatorTreeAnalysis on {{.*}}san.module_ctor +// CHECK: Running analysis: TargetLibraryAnalysis on {{.*}}san.module_ctor diff --git a/llvm/lib/Transforms/Instrumentation/CGProfile.cpp b/llvm/lib/Transforms/Instrumentation/CGProfile.cpp index 638790eea9a35..391aae3f0495d 100644 --- a/llvm/lib/Transforms/Instrumentation/CGProfile.cpp +++ b/llvm/lib/Transforms/Instrumentation/CGProfile.cpp @@ -46,7 +46,7 @@ addModuleFlags(Module &M, } static bool runCGProfilePass( - Module &M, FunctionAnalysisManager &FAM, bool LazyBFI) { + Module &M, FunctionAnalysisManager &FAM) { MapVector<std::pair<Function *, Function *>, uint64_t> Counts; InstrProfSymtab Symtab; auto UpdateCounts = [&](TargetTransformInfo &TTI, Function *F, @@ -63,10 +63,8 @@ static bool runCGProfilePass( (void)(bool) Symtab.create(M); for (auto &F : M) { // Avoid extra cost of running passes for BFI when the function doesn't have - // entry count. Since LazyBlockFrequencyInfoPass only exists in LPM, check - // if using LazyBlockFrequencyInfoPass. - // TODO: Remove LazyBFI when LazyBlockFrequencyInfoPass is available in NPM. - if (F.isDeclaration() || (LazyBFI && !F.getEntryCount())) + // entry count. + if (F.isDeclaration() || !F.getEntryCount()) continue; auto &BFI = FAM.getResult<BlockFrequencyAnalysis>(F); if (BFI.getEntryFreq() == 0) @@ -104,7 +102,7 @@ static bool runCGProfilePass( PreservedAnalyses CGProfilePass::run(Module &M, ModuleAnalysisManager &MAM) { FunctionAnalysisManager &FAM = MAM.getResult<FunctionAnalysisManagerModuleProxy>(M).getManager(); - runCGProfilePass(M, FAM, false); + runCGProfilePass(M, FAM); return PreservedAnalyses::all(); } diff --git a/llvm/test/Other/new-pm-defaults.ll b/llvm/test/Other/new-pm-defaults.ll index 9158ed54b3003..8b2bc4c84bcad 100644 --- a/llvm/test/Other/new-pm-defaults.ll +++ b/llvm/test/Other/new-pm-defaults.ll @@ -274,8 +274,6 @@ ; CHECK-O-NEXT: Running pass: GlobalDCEPass ; CHECK-O-NEXT: Running pass: ConstantMergePass ; CHECK-DEFAULT-NEXT: Running pass: CGProfilePass -; CHECK-DEFAULT-NEXT: Running analysis: BlockFrequencyAnalysis -; CHECK-DEFAULT-NEXT: Running analysis: BranchProbabilityAnalysis ; CHECK-DEFAULT-NEXT: Running pass: RelLookupTableConverterPass ; CHECK-LTO-NOT: Running pass: RelLookupTableConverterPass ; CHECK-O-NEXT: Running pass: AnnotationRemarksPass on foo diff --git a/llvm/test/Other/new-pm-lto-defaults.ll b/llvm/test/Other/new-pm-lto-defaults.ll index ee570015008e1..f93a39b9578c1 100644 --- a/llvm/test/Other/new-pm-lto-defaults.ll +++ b/llvm/test/Other/new-pm-lto-defaults.ll @@ -140,8 +140,6 @@ ; CHECK-O23SZ-NEXT: Running pass: EliminateAvailableExternallyPass ; CHECK-O23SZ-NEXT: Running pass: GlobalDCEPass ; CHECK-O23SZ-NEXT: Running pass: CGProfilePass -; CHECK-O23SZ-NEXT: Running analysis: BlockFrequencyAnalysis on foo -; CHECK-O23SZ-NEXT: Running analysis: BranchProbabilityAnalysis on foo ; CHECK-EP-NEXT: Running pass: NoOpModulePass ; CHECK-O-NEXT: Running pass: AnnotationRemarksPass on foo ; CHECK-O-NEXT: Running pass: PrintModulePass diff --git a/llvm/test/Other/new-pm-thinlto-defaults.ll b/llvm/test/Other/new-pm-thinlto-defaults.ll index 22585aa8ce652..6d73544b191c0 100644 --- a/llvm/test/Other/new-pm-thinlto-defaults.ll +++ b/llvm/test/Other/new-pm-thinlto-defaults.ll @@ -236,8 +236,6 @@ ; CHECK-POSTLINK-O-NEXT: Running pass: GlobalDCEPass ; CHECK-POSTLINK-O-NEXT: Running pass: ConstantMergePass ; CHECK-POSTLINK-O-NEXT: Running pass: CGProfilePass -; CHECK-POSTLINK-O-NEXT: Running analysis: BlockFrequencyAnalysis -; CHECK-POSTLINK-O-NEXT: Running analysis: BranchProbabilityAnalysis ; CHECK-POSTLINK-O-NEXT: Running pass: RelLookupTableConverterPass ; CHECK-EP-OPT-EARLY-NEXT: Running pass: NoOpModulePass ; CHECK-EP-OPT-LAST-NEXT: Running pass: NoOpModulePass _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits