[clang] [llvm] [InstrPGO] Instrument sampling profile based cold function (PR #109837)

via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 24 10:32:23 PDT 2024


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff f4042077e2e3946ee35c1df8cab8237de6086480 b693ff3c33dcf21c1343d9d3432b1d7410a8b579 --extensions cpp -- clang/lib/Driver/ToolChain.cpp clang/lib/Driver/ToolChains/Clang.cpp llvm/lib/Passes/PassBuilderPipelines.cpp llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index 85e9e02ca8..26123bbf00 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -653,14 +653,15 @@ static void addPGOAndCoverageFlags(const ToolChain &TC, Compilation &C,
           Args.getLastArg(options::OPT_fprofile_sample_cold_function,
                           options::OPT_fprofile_sample_cold_function_EQ)) {
     SmallString<128> Path;
-    if (SampleColdArg->getOption().matches(options::OPT_fprofile_sample_cold_function_EQ))
+    if (SampleColdArg->getOption().matches(
+            options::OPT_fprofile_sample_cold_function_EQ))
       Path.append(SampleColdArg->getValue());
-    else 
+    else
       Path.append("default_%m.profraw");
 
     CmdArgs.push_back("-mllvm");
     CmdArgs.push_back(Args.MakeArgString(
-        Twine("--instrument-sample-cold-function-path=") + Path));    
+        Twine("--instrument-sample-cold-function-path=") + Path));
   }
 
   Arg *PGOGenArg = nullptr;
diff --git a/llvm/lib/Passes/PassBuilderPipelines.cpp b/llvm/lib/Passes/PassBuilderPipelines.cpp
index 5d1d8480b1..0514d17db2 100644
--- a/llvm/lib/Passes/PassBuilderPipelines.cpp
+++ b/llvm/lib/Passes/PassBuilderPipelines.cpp
@@ -1125,8 +1125,9 @@ PassBuilder::buildModuleSimplificationPipeline(OptimizationLevel Level,
       // removed.
       MPM.addPass(
           PGOIndirectCallPromotion(true /* IsInLTO */, true /* SamplePGO */));
-    
-    if (InstrumentSampleColdFuncPath.getNumOccurrences() && Phase != ThinOrFullLTOPhase::ThinLTOPostLink) {
+
+    if (InstrumentSampleColdFuncPath.getNumOccurrences() &&
+        Phase != ThinOrFullLTOPhase::ThinLTOPostLink) {
       assert(!InstrumentSampleColdFuncPath.empty() &&
              "File path is requeired for instrumentation generation");
       InstrumentColdFunction = true;

``````````

</details>


https://github.com/llvm/llvm-project/pull/109837


More information about the cfe-commits mailing list