[PATCH] D111411: [AArch64] Async unwind - function prologues

Momchil Velikov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 7 02:20:45 PDT 2022


chill added a comment.

In D111411#3733063 <https://reviews.llvm.org/D111411#3733063>, @smeenai wrote:

> Sorry for the late comment; I'm catching up on the async unwind changes as part of our LLVM 15 upgrade.
>
> From the description of this change and https://discourse.llvm.org/t/rfc-asynchronous-unwind-tables-attribute/59282, it seems like the extra directives being omitted should only be required for asynchronous unwind tables. I was wondering why the emission of the extra directives in this diff wasn't guarded by a check for async unwind tables in that case. E.g. https://godbolt.org/z/h4ceMe5ja shows Clang 15 emitting an extra `.cfi_def_cfa_offset` vs. Clang 14, even with `-fno-asynchronous-unwind-tables`. I don't think the size overhead is too significant for us, but I was wondering why that emission wasn't guarded by a check for async unwind tables.

It's just for simplicity -  unwind info emission in prologues is the same and suitable for synchronous and asynchronous unwind tables. IMHO, the benefit is not worth the engineering effort, but
I certainly wouldn't object against it.

That said, I would suggest a good general strategy would be for the prologue/epilogue emission functions to output the most detailed information available, which could
then be optimised by follow-up passes, depending on specific use cases (and extra command line options) - for example, a release/production build of an application
which uses no C++ exceptions could have its unwind tables stripped down only to the bare minimum, required by a profiler to obtain a stack trace - basically removing
any mention of callee-saved registers and retaining only information about frame pointer, return address and CFA offset.

> I was also curious about the long-term plans here. https://godbolt.org/z/jnoc8YvKz shows that the `.cfi_offset` directives for saved registers are emitted together at the end of the prolog, vs. right after the instruction which saves the registers. Will that also be changing eventually for async unwind tables, or is that considered unnecessary?

That's deliberate and I don't have plans to change it. Having unwind instructions grouped together saves quite a lot of unwind tables space, because you don't need a `DW_CFA_advance_loc`  
between `DW_CFA_offset`s. and as long as no callee-saved register is modified before its `.cfi_offset` you can obtain its value from the register itself.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D111411/new/

https://reviews.llvm.org/D111411



More information about the llvm-commits mailing list