[llvm] TargetOptions: Look up frame-pointer attribute once (PR #146639)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 1 23:11:11 PDT 2025
https://github.com/arsenm created https://github.com/llvm/llvm-project/pull/146639
Same as 07a86a525ea2f85ade9e224c200f0311fec9e433, except in
ther other case here.
>From 1070f6ac468b6b3b81913aeecc8910919bf24f49 Mon Sep 17 00:00:00 2001
From: Matt Arsenault <Matthew.Arsenault at amd.com>
Date: Wed, 2 Jul 2025 15:03:20 +0900
Subject: [PATCH] TargetOptions: Look up frame-pointer attribute once
Same as 07a86a525ea2f85ade9e224c200f0311fec9e433, except in
ther other case here.
---
llvm/lib/CodeGen/TargetOptionsImpl.cpp | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/llvm/lib/CodeGen/TargetOptionsImpl.cpp b/llvm/lib/CodeGen/TargetOptionsImpl.cpp
index def325efd5445..5eb86e740ff7c 100644
--- a/llvm/lib/CodeGen/TargetOptionsImpl.cpp
+++ b/llvm/lib/CodeGen/TargetOptionsImpl.cpp
@@ -39,12 +39,11 @@ bool TargetOptions::DisableFramePointerElim(const MachineFunction &MF) const {
bool TargetOptions::FramePointerIsReserved(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();
- return StringSwitch<bool>(FP)
+ return StringSwitch<bool>(FPAttr.getValueAsString())
.Cases("all", "non-leaf", "reserved", true)
.Case("none", false);
}
More information about the llvm-commits
mailing list