[llvm] 07a86a5 - CodeGen: Look up frame-pointer attribute once (#142902)

via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 8 07:03:56 PDT 2025


Author: Matt Arsenault
Date: 2025-06-08T23:03:52+09:00
New Revision: 07a86a525ea2f85ade9e224c200f0311fec9e433

URL: https://github.com/llvm/llvm-project/commit/07a86a525ea2f85ade9e224c200f0311fec9e433
DIFF: https://github.com/llvm/llvm-project/commit/07a86a525ea2f85ade9e224c200f0311fec9e433.diff

LOG: CodeGen: Look up frame-pointer attribute once (#142902)

Instead of pre-checking if the frame-pointer attribute is present,
just query the attribute and see if it's valid.

Added: 
    

Modified: 
    llvm/lib/CodeGen/TargetOptionsImpl.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/TargetOptionsImpl.cpp b/llvm/lib/CodeGen/TargetOptionsImpl.cpp
index 01ffaed585ea1..def325efd5445 100644
--- a/llvm/lib/CodeGen/TargetOptionsImpl.cpp
+++ b/llvm/lib/CodeGen/TargetOptionsImpl.cpp
@@ -24,9 +24,10 @@ using namespace llvm;
 bool TargetOptions::DisableFramePointerElim(const MachineFunction &MF) const {
   const Function &F = MF.getFunction();
 
-  if (!F.hasFnAttribute("frame-pointer"))
+  Attribute FPAttr = F.getFnAttribute("frame-pointer");
+  if (!FPAttr.isValid())
     return false;
-  StringRef FP = F.getFnAttribute("frame-pointer").getValueAsString();
+  StringRef FP = FPAttr.getValueAsString();
   if (FP == "all")
     return true;
   if (FP == "non-leaf")


        


More information about the llvm-commits mailing list