Revert "[CodeGen] [WinException] Only produce handler data at the end of the function...
authorHans Wennborg <hans@chromium.org>
Tue, 3 Nov 2020 12:01:55 +0000 (13:01 +0100)
committerHans Wennborg <hans@chromium.org>
Tue, 3 Nov 2020 12:12:10 +0000 (13:12 +0100)
commitcbf25fbed5b46ec47e3ce2799ed9095f2f18ea8f
tree4489a833c3fed0522224136c7a45fa7f6da5324a
parentb397795f1a2f9e25669fe030dc3836f35e2e725e
Revert "[CodeGen] [WinException] Only produce handler data at the end of the function if needed"

This caused an explosion in ICF times during linking on Windows when libfuzzer
instrumentation is enabled. For a small binary we see ICF time go from ~0 to
~10 s. For a large binary it goes from ~1 s to forevert (I gave up after 30
minutes).

See comment on the code review.

> 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

This reverts commit 36c64af9d7f97414d48681b74352c9684077259b.
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