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.
This commit is contained in:
Matt Arsenault
2025-06-08 23:03:52 +09:00
committed by GitHub
parent 3fc216bc3b
commit 07a86a525e

View File

@@ -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")