Messages in this thread | | | From | Florian Weimer <> | Subject | Re: [PATCH v2 1/3] compiler_types: Introduce the Clang __preserve_most function attribute | Date | Tue, 08 Aug 2023 13:41:05 +0200 |
| |
* Peter Zijlstra:
> Now, the problem with __preserve_most is that it makes it really easy to > deviate from this pattern, you can trivially write a function that is > not a trivial wrapper and then does not show up on unwind. This might > indeed be a problem.
Backtrace generation shouldn't be impacted by a compiler implementation of __preserve_most__. If unwinding implies restoring register contents, the question becomes whether the unwinder can be taught to do this natively. For .eh_frame/PT_GNU_EH_FRAME-based unwinders and __preserve_most__, I think that's true because they already support custom ABIs (and GCC uses them for local functions). In other cases, if the unwinder does not support the extra registers, then it might still be possible to compensate for that via code generation (e.g., setjmp won't be __preserve_most__, so the compiler would have to preserve register contents by other means, also accounting for the returns-twice nature, likewise for exception handling landing pads).
But __preserve_all__ is a completely different beast. I *think* it is possible to do this with helpers (state size, state save, state restore) and strategically placed restores after returns-twice functions and the like, but people disagree. This has come up before in the context of the s390x vector ABI and the desire to add new callee-saved registers. We just couldn't make that work at the time. On the other hand, __preserve_all__ goes into the other direction (opt-in of extra saves), so it may be conceptually easier.
Thanks, Florian
| |