Use assembler expressions to lay out the EH LSDA.
authorRafael Espindola <rafael.espindola@gmail.com>
Fri, 9 Feb 2018 17:00:25 +0000 (17:00 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Fri, 9 Feb 2018 17:00:25 +0000 (17:00 +0000)
commitd09b416943fec535f73950b0954e0fcd17719a75
tree9b193a55c6d4e422a146d77f11ac5a0ecf470dfe
parente7da136a74ac9073528327aa8364bad97156ba51
Use assembler expressions to lay out the EH LSDA.

Rely on the assembler to finalize the layout of the DWARF/Itanium
exception-handling LSDA. Rather than calculate the exact size of each
thing in the LSDA, use assembler directives:

    To emit the offset to the TTBase label:

.uleb128 .Lttbase0-.Lttbaseref0
.Lttbaseref0:

    To emit the size of the call site table:

.uleb128 .Lcst_end0-.Lcst_begin0
.Lcst_begin0:
... call site table entries ...
.Lcst_end0:

    To align the type info table:

... action table ...
.balign 4
.long _ZTIi
.long _ZTIl
.Lttbase0:

Using assembler directives simplifies the compiler and allows switching
the encoding of offsets in the call site table from udata4 to uleb128 for
a large code size savings. (This commit does not change the encoding.)

The combination of the uleb128 followed by a balign creates an unfortunate
dependency cycle that the assembler must sometimes resolve either by
padding an LEB or by inserting zero padding before the type table. See
PR35809 or GNU as bug 4029.

Patch by Ryan Prichard!

llvm-svn: 324749
16 files changed:
llvm/include/llvm/CodeGen/AsmPrinter.h
llvm/include/llvm/MC/MCObjectStreamer.h
llvm/include/llvm/MC/MCStreamer.h
llvm/lib/CodeGen/AsmPrinter/ARMException.cpp
llvm/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfException.h
llvm/lib/CodeGen/AsmPrinter/EHStreamer.cpp
llvm/lib/CodeGen/AsmPrinter/EHStreamer.h
llvm/lib/MC/MCAsmStreamer.cpp
llvm/lib/MC/MCObjectStreamer.cpp
llvm/lib/MC/MCStreamer.cpp
llvm/test/CodeGen/ARM/ehabi-handlerdata-nounwind.ll
llvm/test/CodeGen/ARM/ehabi-handlerdata.ll
llvm/test/CodeGen/X86/eh-unknown.ll
llvm/test/CodeGen/X86/patchpoint-invoke.ll
llvm/test/CodeGen/XCore/exception.ll