[llvm] [llvm] Win x64 Unwind V2 1/n: Mark beginning and end of epilogs (PR #110024)
Pedro Miguel Justo via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 25 15:04:37 PDT 2024
pmsjt wrote:
EpilogV2 isn't publicly documented (yet) but there are a couple of high-level characteristics that I'll share to address some of the questions:
With the original ABI (V1) definition, when unwinding the stack, the original unwinder was forced to disassemble the instruction stream, conclude whether execution was in the epilog and, if yes, essentially emulate the instructions forward. UWOPs were only used for prolog and body. As a result of this, epilogs must follow some canonical format rules which the unwinder can detect and emulate.
EpilogV2's goal is to enable stack unwinding without having to access the instruction stream, but in a backward compatible way. This means that functions compiled with EpilogV2 must still abide by the epilog canonical rules of V1, so an older unwinder (not V2 aware) can still do the right thing, by employing the old strategy to detect and emulate x86 instructions when in the epilog.
So, when the EpilogV2-aware unwinder encounters an EpilogV2-compiled function, it will be aware of the instruction offset of where the epilog starts. Then it will use the Prolog's UWOPs to unwind the epilog a) assuming symmetry and b) assuming that each UWOP is associated with a given instruction (length).
This means that, technically, EpilogV2 adds to the V1 list of the canonical rules for epilogs, making it even more restrictive. In practice, V1 was already so restrictive that V2 doesn't change the practical result much. In return, unwinding can be performed without accessing the code stream (which might have security or runtime implications) and operates exclusively on UWOPs instead for prolog, body and epilog.
https://github.com/llvm/llvm-project/pull/110024
More information about the llvm-commits
mailing list