[ORC][ORC-RT][ELF] Move selection of eh-frame registration APIs into orc-rt.
authorLang Hames <lhames@gmail.com>
Thu, 6 Apr 2023 04:14:45 +0000 (04:14 +0000)
committerLang Hames <lhames@gmail.com>
Thu, 6 Apr 2023 16:31:55 +0000 (16:31 +0000)
commitcd3f2749ed156492f8d50bad7055a0d68b9bea05
tree2e74811299996b167ce3c2b0510563aa9b65ed4c
parent915b74549e757134d28ee44c5a75dcf394b1b5bd
[ORC][ORC-RT][ELF] Move selection of eh-frame registration APIs into orc-rt.

ORC's ELF platform support prefers the newer libunwind registration functions
(__unw_add_dynamic_eh_frame_section, __unw_remove_dynamic_eh_frame_section) when
they're available, and falls back to the older registration functions
(__register_frame, __deregister_frame) when they're not.

Until now the choice of registration functions has been made on the controller
side in ELFNixPlatform: The platform JITDylib was searched for the registration
functions and aliases set depending on which ones were found. This patch drops
that selection logic from ELFNixPlatform and instead uses weak imports of the
registration functions in elfnix_platform.cpp to identify which ones are
available and choose which ones to use.

This has a few small benefits:
(1) The registration functions don't need to be defined in the same JITDylib as
the ORC runtime -- it's sufficient for them to be defined in a JITDylib that the
ORC runtime's JITDylib links against.

(2) THe elfnix_platfrom code is more readable, as we don't have to dig into
ELFNixPlatform.cpp on the controller side to discover the definition of the
registration aliases.

(3) We may save a separate round-trip to look up the registration APIs (the
lookup will be folded into the ordinary external symbol lookup when linking the
runtime).
compiler-rt/lib/orc/elfnix_platform.cpp
llvm/lib/ExecutionEngine/Orc/ELFNixPlatform.cpp