TargetOptions: Look up frame-pointer attribute once (#146639)

Same as 07a86a525e, except in
ther other case here.
This commit is contained in:
Matt Arsenault
2025-07-02 20:09:20 +09:00
committed by GitHub
parent 35626e97d8
commit 585b41c2ec

View File

@@ -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);
}