If there's no DWARF instructions, personality, or LSDA, I don't think
there's a need to emit a CU entry either. This canonicalization of
unwind info allows link-time code folding to fold more functions (since
functions with trivial unwind info are now obviously identical to
functions with the same code but with no unwind info).
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
If a function do not have unwind info, you cannot throw anything across the frame. That will be a very harsh behavior for any programmer who does not think about exception for all the code they use.
For example:
func call_back_throw() <--- with unwind info func library_code() <--- no dwarf, no LSDA func catch_site() <--- nope, cant catch anything
If you want to avoid unwind table, just have something like -fno-unwind-tables so they are nounwind in IR in the first place.
Oh, thanks for your example, I wasn't aware of that. Just to make sure I understand, if a function has an encoding of 0x0 in the final binary's __unwind_info, that means you cannot throw anything across the frame?
Also, the x86_64 MC backend is a lot more aggressive about omitting unwind info (https://discourse.llvm.org/t/does-it-make-sense-for-a-function-to-have-a-personality-lsda-if-it-has-no-other-unwind-info-mach-o/65490). Curious if you have thoughts on that. Is that a bug in x86_64, or does the arm64 unwinder work differently?
Oh, thanks for your example, I wasn't aware of that. Just to make sure I understand, if a function has an encoding of 0x0 in the final binary's __unwind_info, that means you cannot throw anything across the frame?
I am not an expert in the area but I would believe that is the case. You can dig through libunwind in llvm to see the implementation over there.
Also, the x86_64 MC backend is a lot more aggressive about omitting unwind info (https://discourse.llvm.org/t/does-it-make-sense-for-a-function-to-have-a-personality-lsda-if-it-has-no-other-unwind-info-mach-o/65490). Curious if you have thoughts on that. Is that a bug in x86_64, or does the arm64 unwinder work differently?
Looks like x86 backend emit __eh_frame instead?