From 585b41c2ecc0bf72b9956b86f1b19e21ff02259d Mon Sep 17 00:00:00 2001 From: Matt Arsenault Date: Wed, 2 Jul 2025 20:09:20 +0900 Subject: [PATCH] TargetOptions: Look up frame-pointer attribute once (#146639) 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 def325efd544..5eb86e740ff7 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(FP) + return StringSwitch(FPAttr.getValueAsString()) .Cases("all", "non-leaf", "reserved", true) .Case("none", false); }