================
@@ -1030,6 +1036,12 @@ 
PassBuilder::buildModuleSimplificationPipeline(OptimizationLevel Level,
       Phase != ThinOrFullLTOPhase::ThinLTOPostLink)
     MPM.addPass(SampleProfileProbePass(TM));
 
+  // Instrument function entry and exit before all inlining.
+  if (!isLTOPostLink(Phase)) {
+    MPM.addPass(createModuleToFunctionPassAdaptor(
----------------
pasko wrote:

I tried this, and all non-pipeline tests pass. Though in my local FDO+ThinLTO 
reproducer I saw this causes `__cyg_profile_func_enter_bare` to be inserted 
multiple times per toplevel function.

This behaviour surprised me. The bare instrumentation does not move with the 
change. Is removing the module to function pass adaptor making something easier 
to inline later on?

I'd like to investigate, but I am afraid I'll need some clues :)

The change:
```
diff --git a/llvm/lib/Passes/PassBuilderPipelines.cpp 
b/llvm/lib/Passes/PassBuilderPipelines.cpp
index 3a7634f90c07..cae340a19fb6 100644
--- a/llvm/lib/Passes/PassBuilderPipelines.cpp
+++ b/llvm/lib/Passes/PassBuilderPipelines.cpp
@@ -397,11 +397,6 @@ static bool isLTOPreLink(ThinOrFullLTOPhase Phase) {
          Phase == ThinOrFullLTOPhase::FullLTOPreLink;
 }
 
-static bool isLTOPostLink(ThinOrFullLTOPhase Phase) {
-  return Phase == ThinOrFullLTOPhase::ThinLTOPostLink ||
-         Phase == ThinOrFullLTOPhase::FullLTOPostLink;
-}
-
 // TODO: Investigate the cost/benefit of tail call elimination on debugging.
 FunctionPassManager
 PassBuilder::buildO1FunctionSimplificationPipeline(OptimizationLevel Level,
@@ -1039,12 +1034,6 @@ 
PassBuilder::buildModuleSimplificationPipeline(OptimizationLevel Level,
       Phase != ThinOrFullLTOPhase::ThinLTOPostLink)
     MPM.addPass(SampleProfileProbePass(TM));
 
-  // Instrument function entry and exit before all inlining.
-  if (!isLTOPostLink(Phase)) {
-    MPM.addPass(createModuleToFunctionPassAdaptor(
-        EntryExitInstrumenterPass(/*PostInlining=*/false)));
-  }
-
   bool HasSampleProfile = PGOOpt && (PGOOpt->Action == PGOOptions::SampleUse);
 
   // In ThinLTO mode, when flattened profile is used, all the available
@@ -1081,6 +1070,9 @@ 
PassBuilder::buildModuleSimplificationPipeline(OptimizationLevel Level,
     MPM.addPass(CoroEarlyPass());
 
     FunctionPassManager EarlyFPM;
+    if (Phase != ThinOrFullLTOPhase::FullLTOPostLink) {
+      EarlyFPM.addPass(EntryExitInstrumenterPass(/*PostInlining=*/false));
+    }
     // Lower llvm.expect to metadata before attempting transforms.
     // Compare/branch metadata may alter the behavior of passes like
     // SimplifyCFG.
```

https://github.com/llvm/llvm-project/pull/92171
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to