[llvm] [llvm] Consistently respect `naked` fn attribute in `TargetFrameLowering::hasFP()` (PR #106014)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 28 08:37:43 PDT 2024
================
@@ -286,7 +286,11 @@ class TargetFrameLowering {
/// hasFP - Return true if the specified function should have a dedicated
/// frame pointer register. For most targets this is true only if the function
/// has variable sized allocas or if frame pointer elimination is disabled.
- virtual bool hasFP(const MachineFunction &MF) const = 0;
+ /// For all targets, this is false if the function has the naked attribute
+ /// since there is no prologue to set up the frame pointer.
+ bool hasFP(const MachineFunction &MF) const {
+ return !MF.getFunction().hasFnAttribute(Attribute::Naked) && hasFPImpl(MF);
----------------
arsenm wrote:
I'm not sure I like forcing it like this; maybe some weird target wants a frame pointer with naked functions?
Would it be much effort to update all targets to check this as a default base implementation? We could also put the other common cases in there like variable frame objects, I guess
https://github.com/llvm/llvm-project/pull/106014
More information about the llvm-commits
mailing list