llvm/lld/MachO
Nico Weber 86c8f395ae [lld/mac] Leave more room for thunks in thunk placement code
Fixes PR51578 in practice.

Currently there's only enough room for a single thunk, which for real-life code
isn't enough. The error case only happens when there are many branch statements
very close to each other (0 or 1 instructions apart), with the function at the
finalization barrier small.

There's a FIXME on what to do if we hit this case, but that suggestion sounds
complicated to me (see end of PR51578 comment 5 for why).

Instead, just leave more room for thunks. Chromium's unit_tests links fine with
room for 3 thunks. Leave room for 100, which should fix this for most cases in
practice.

There's little cost for leaving lots of room: This slop value only determines
when we finalize sections, and we insert thunks for forward jumps into
unfinalized sections. So leaving room means we'll need a few more thunks, but
the thunk jump range is 128 MiB while a single thunk is just 12 bytes.

For Chromium's unit_tests:
With a slop of   3: thunk calls = 355418, thunks = 10903
With a slop of 100: thunk calls = 355426, thunks = 10904

Chances are 100 is enough for all use cases we'll hit in practice, but even
bumping it to 1000 would probably be fine.

Differential Revision: https://reviews.llvm.org/D108930
2021-08-30 22:09:05 -04:00
..
Arch [lld/mac] Set branchRange a bit more carefully 2021-08-30 12:36:06 -04:00
CMakeLists.txt
ConcatOutputSection.cpp [lld/mac] Leave more room for thunks in thunk placement code 2021-08-30 22:09:05 -04:00
ConcatOutputSection.h
Config.h
Driver.cpp [lld-macho] Have -ObjC load archive members before symbol resolution 2021-08-26 18:52:07 -04:00
Driver.h [lld-macho] Refactor archive loading 2021-08-26 18:52:07 -04:00
DriverUtils.cpp [lld-macho] Refactor archive loading 2021-08-26 18:52:07 -04:00
Dwarf.cpp
Dwarf.h
ExportTrie.cpp
ExportTrie.h
ICF.cpp
ICF.h
InputFiles.cpp [lld-macho] Refactor archive loading 2021-08-26 18:52:07 -04:00
InputFiles.h [lld-macho] Refactor archive loading 2021-08-26 18:52:07 -04:00
InputSection.cpp
InputSection.h [lld-macho][nfc] Clean up InputSection constructors 2021-08-26 19:07:48 -04:00
LTO.cpp
LTO.h
MachOStructs.h
MapFile.cpp
MapFile.h
MarkLive.cpp
MarkLive.h
ObjC.cpp [lld-macho] Refactor archive loading 2021-08-26 18:52:07 -04:00
ObjC.h
Options.td
OutputSection.cpp
OutputSection.h
OutputSegment.cpp
OutputSegment.h
Relocations.cpp
Relocations.h
Symbols.cpp
Symbols.h
SymbolTable.cpp
SymbolTable.h
SyntheticSections.cpp
SyntheticSections.h
Target.cpp
Target.h [lld/mac] Set branchRange a bit more carefully 2021-08-30 12:36:06 -04:00
UnwindInfoSection.cpp [lld-macho] Fix unwind info personality size 2021-08-26 18:52:06 -04:00
UnwindInfoSection.h
Writer.cpp
Writer.h