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