[clang] [llvm] [clang][Inliner] Add opt-in inliner hints for lambdas and main-file functions (PR #228074)

via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 1 06:32:49 PDT 2026


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 origin/main HEAD --extensions cpp -- clang/test/CodeGenCXX/inline-origin-hints.cpp clang/lib/CodeGen/CodeGenModule.cpp llvm/lib/Analysis/InlineCost.cpp --diff_from_common_commit
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

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

``````````diff
diff --git a/llvm/lib/Analysis/InlineCost.cpp b/llvm/lib/Analysis/InlineCost.cpp
index 53bcde650..f1e0fbbf4 100644
--- a/llvm/lib/Analysis/InlineCost.cpp
+++ b/llvm/lib/Analysis/InlineCost.cpp
@@ -188,9 +188,9 @@ static cl::opt<bool> UseClangHints(
     "inline-use-clang-hints", cl::Hidden, cl::init(false),
     cl::desc("Use clang's lambda/main-file hints to raise thresholds"));
 
-static cl::opt<int> ClangHintsLambdaBonus(
-    "clang-hints-lambda-bonus", cl::Hidden, cl::init(500),
-    cl::desc("Threshold bonus for lambdas"));
+static cl::opt<int>
+    ClangHintsLambdaBonus("clang-hints-lambda-bonus", cl::Hidden, cl::init(500),
+                          cl::desc("Threshold bonus for lambdas"));
 
 static cl::opt<int> ClangHintsMainFileTemplateBonus(
     "clang-hints-main-file-template-bonus", cl::Hidden, cl::init(150),
@@ -1276,11 +1276,11 @@ public:
 // original dead.
 static bool isSoleCallToLocalFunction(const CallBase &CB,
                                       const Function &Callee) {
-  bool Local = Callee.hasLocalLinkage() ||
-               (UseClangHints && ClangHintsLocalLambdas &&
-                Callee.hasLinkOnceODRLinkage() &&
-                Callee.hasFnAttribute("clang-lambda") &&
-                Callee.hasFnAttribute("clang-main-file"));
+  bool Local =
+      Callee.hasLocalLinkage() || (UseClangHints && ClangHintsLocalLambdas &&
+                                   Callee.hasLinkOnceODRLinkage() &&
+                                   Callee.hasFnAttribute("clang-lambda") &&
+                                   Callee.hasFnAttribute("clang-main-file"));
   return Local && Callee.hasOneLiveUse() && &Callee == CB.getCalledFunction();
 }
 

``````````

</details>


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


More information about the cfe-commits mailing list