[CodeGen] [WinException] Only produce handler data at the end of the function if...
authorMartin Storsjö <martin@martin.st>
Thu, 10 Sep 2020 10:33:00 +0000 (13:33 +0300)
committerMartin Storsjö <martin@martin.st>
Mon, 21 Sep 2020 20:42:59 +0000 (23:42 +0300)
commit36c64af9d7f97414d48681b74352c9684077259b
treec0dd701564a4c9dc0bccd1bdc5b275505d263190
parent4d85444b317a00a3e15da63cdb693d272c99a0cc
[CodeGen] [WinException] Only produce handler data at the end of the function if needed

If we are going to write handler data (that is written as variable
length data following after the unwind info in .xdata), we need to
emit the handler data immediately, but for cases where no such
info is going to be written, skip emitting it right away. (Unwind
info for all remaining functions that hasn't gotten it emitted
directly is emitted at the end.)

This does slightly change the ordering of sections (triggering a
bunch of updates to DebugInfo/COFF tests), but the change should be
benign.

This also matches GCC's assembly output, which doesn't output
.seh_handlerdata unless it actually is needed.

For ARM64, the unwind info can be packed into the runtime function
entry itself (leaving no data in the .xdata section at all), but
that can only be done if there's no follow-on data in the .xdata
section. If emission of the unwind info is triggered via
EmitWinEHHandlerData (or the .seh_handlerdata directive), which
implicitly switches to the .xdata section, there's a chance of the
caller wanting to pass further data there, so the packed format
can't be used in that case.

Differential Revision: https://reviews.llvm.org/D87448
24 files changed:
llvm/lib/CodeGen/AsmPrinter/WinException.cpp
llvm/test/CodeGen/AArch64/win64-jumptable.ll
llvm/test/CodeGen/AArch64/wineh1.mir
llvm/test/CodeGen/X86/avx512-intel-ocl.ll
llvm/test/CodeGen/X86/avx512-regcall-Mask.ll
llvm/test/CodeGen/X86/avx512-regcall-NoMask.ll
llvm/test/CodeGen/X86/break-false-dep.ll
llvm/test/CodeGen/X86/conditional-tailcall-pgso.ll
llvm/test/CodeGen/X86/conditional-tailcall.ll
llvm/test/CodeGen/X86/gnu-seh-nolpads.ll
llvm/test/CodeGen/X86/mingw-comdats.ll
llvm/test/CodeGen/X86/mixed-ptr-sizes.ll
llvm/test/CodeGen/X86/musttail-varargs.ll
llvm/test/CodeGen/X86/no-sse-win64.ll
llvm/test/CodeGen/X86/win64-jumptable.ll
llvm/test/CodeGen/X86/win64_frame.ll
llvm/test/DebugInfo/COFF/defer-complete-type.ll
llvm/test/DebugInfo/COFF/enum-co.ll
llvm/test/DebugInfo/COFF/global_visibility.ll
llvm/test/DebugInfo/COFF/type-quals.ll
llvm/test/DebugInfo/COFF/types-basic.ll
llvm/test/DebugInfo/COFF/types-data-members.ll
llvm/test/DebugInfo/COFF/types-method-ref-qualifiers.ll
llvm/test/DebugInfo/COFF/types-recursive-struct.ll