[PATCH] D87448: [CodeGen] [WinException] Only produce handler data at the end of the function if needed

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 10 05:03:16 PDT 2020


mstorsjo created this revision.
mstorsjo added reviewers: efriedma, ssijaric, TomTan, rnk.
Herald added subscribers: hiraditya, kristof.beyls.
Herald added a project: LLVM.
mstorsjo requested review of this revision.

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.

This turned out to be the reason why D87371 <https://reviews.llvm.org/D87371> had no effect at all, as it forced `.seh_handlerdata` at the end of all functions. With this patch in place, D87371 <https://reviews.llvm.org/D87371> has got a small effect (but very few functions in practice end up matching).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87448

Files:
  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/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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D87448.290945.patch
Type: text/x-patch
Size: 24643 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200910/414e0f2f/attachment-0001.bin>


More information about the llvm-commits mailing list