As discussed in PR 97902 we'd need an option that disables all optimizations that may affect the generation of a frame pointer.
Something like, -fneed-frame-pointer, -fforce-frame-pointer or -fgenerate-frame-pointer.
I vote for -fforce-frame-pointer.
-fforce-frame-pointer should disable 1. Tail call. 2. Inlining. Should inlining be totally disabled? Which inlining should be disabled? What do do with static inline and extern inline? 3. Frame pointer optimization. 4. Anything else?
Note always_inline inlining cannot be disabled. Should it disable function splitting and IPA transforms that require thunks? Thus any transform that might add or remove a frame? Even if the thunk might use a tailcall?
About the IPA passes, it's likely quite close to -flive-patching=inline-only-static what we want here.
I assume this isn't just about forcing a function to set up a frame pointer: I assume we also need the function to set up the frame pointer at the earliest opportunity and keep it valid for as long as possible. This means (at least) that: * We need to disable shrink-wrapping of the frame pointer * There needs to be a full scheduling barrier after the frame pointer has been set up and before it is torn down So I don't think this is just about disabling optimisations (unless perhaps we disable scheduling completely). It seems like an entirely new mode that will involve new code.