[llvm] [Option] Mark getLastArg(NoClaim) as noinline. (PR #157163)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 5 12:05:46 PDT 2025


https://github.com/fhahn created https://github.com/llvm/llvm-project/pull/157163

After https://github.com/llvm/llvm-project/pull/156730, getLastArg(NoClaim) are now just below the inlining threshold and inlining them causes +0.44% code size increase for Clang and a corresponding compile-time increase without helping compile-time.

Mark them as noinline to recover the original codesize.

http://llvm-compile-time-tracker.com/compare.php?from=a271d07488a85ce677674bbe8101b10efff58c95&to=3b7b312476da2a2b1fd44815532edf9987da337e&stat=instructions:u

>From a1db9f2451ad3b036e1615808e46f745edb5c8d6 Mon Sep 17 00:00:00 2001
From: Florian Hahn <flo at fhahn.com>
Date: Fri, 5 Sep 2025 13:18:42 +0100
Subject: [PATCH] [Option] Mark getLastArg(NoClaim) as noinline.

After https://github.com/llvm/llvm-project/pull/156730,
getLastArg(NoClaim) are now just below the inlining threshold and
inlining them causes +0.44% code size increase for Clang and a
corresponding compile-time increase without helping compile-time.

Mark them as noinline to recover the original codesize.

http://llvm-compile-time-tracker.com/compare.php?from=a271d07488a85ce677674bbe8101b10efff58c95&to=3b7b312476da2a2b1fd44815532edf9987da337e&stat=instructions:u
---
 llvm/include/llvm/Option/ArgList.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/llvm/include/llvm/Option/ArgList.h b/llvm/include/llvm/Option/ArgList.h
index 313164bc29689..1d316633027cf 100644
--- a/llvm/include/llvm/Option/ArgList.h
+++ b/llvm/include/llvm/Option/ArgList.h
@@ -254,7 +254,7 @@ class ArgList {
 
   /// Return the last argument matching \p Id, or null.
   template<typename ...OptSpecifiers>
-  Arg *getLastArg(OptSpecifiers ...Ids) const {
+  LLVM_ATTRIBUTE_NOINLINE Arg * getLastArg(OptSpecifiers ...Ids) const  {
     Arg *Res = nullptr;
     for (Arg *A : filtered(Ids...)) {
       Res = A;
@@ -266,7 +266,7 @@ class ArgList {
   /// Return the last argument matching \p Id, or null. Do not "claim" the
   /// option (don't mark it as having been used).
   template<typename ...OptSpecifiers>
-  Arg *getLastArgNoClaim(OptSpecifiers ...Ids) const {
+  LLVM_ATTRIBUTE_NOINLINE Arg * getLastArgNoClaim(OptSpecifiers ...Ids) const {
     for (Arg *A : filtered_reverse(Ids...))
       return A;
     return nullptr;



More information about the llvm-commits mailing list