From 1aa71f8679e439db651c06e8e68ef21e6deffa93 Mon Sep 17 00:00:00 2001 From: "Peter S. Housel" Date: Wed, 25 May 2022 17:04:01 -0700 Subject: [ORC][ORC_RT] Integrate ORC platforms with LLJIT and lli This change enables integrating orc::LLJIT with the ORCv2 platforms (MachOPlatform and ELFNixPlatform) and the compiler-rt orc runtime. Changes include: - Adding SPS wrapper functions for the orc runtime's dlfcn emulation functions, allowing initialization and deinitialization to be invoked by LLJIT. - Changing the LLJIT code generation default to add UseInitArray so that .init_array constructors are generated for ELF platforms. - Integrating the ORCv2 Platforms into lli, and adding a PlatformSupport implementation to the LLJIT instance used by lli which implements initialization and deinitialization by calling the new wrapper functions in the runtime. Reviewed By: lhames Differential Revision: https://reviews.llvm.org/D126492 --- llvm/lib/ExecutionEngine/Orc/ELFNixPlatform.cpp | 4 ++++ llvm/lib/ExecutionEngine/Orc/JITTargetMachineBuilder.cpp | 1 + llvm/lib/ExecutionEngine/Orc/MachOPlatform.cpp | 4 ++++ 3 files changed, 9 insertions(+) (limited to 'llvm/lib/ExecutionEngine/Orc') diff --git a/llvm/lib/ExecutionEngine/Orc/ELFNixPlatform.cpp b/llvm/lib/ExecutionEngine/Orc/ELFNixPlatform.cpp index 0185a9d..730e193 100644 --- a/llvm/lib/ExecutionEngine/Orc/ELFNixPlatform.cpp +++ b/llvm/lib/ExecutionEngine/Orc/ELFNixPlatform.cpp @@ -263,6 +263,10 @@ ELFNixPlatform::standardRuntimeUtilityAliases() { static const std::pair StandardRuntimeUtilityAliases[] = { {"__orc_rt_run_program", "__orc_rt_elfnix_run_program"}, + {"__orc_rt_jit_dlerror", "__orc_rt_elfnix_jit_dlerror"}, + {"__orc_rt_jit_dlopen", "__orc_rt_elfnix_jit_dlopen"}, + {"__orc_rt_jit_dlclose", "__orc_rt_elfnix_jit_dlclose"}, + {"__orc_rt_jit_dlsym", "__orc_rt_elfnix_jit_dlsym"}, {"__orc_rt_log_error", "__orc_rt_log_error_to_stderr"}}; return ArrayRef>( diff --git a/llvm/lib/ExecutionEngine/Orc/JITTargetMachineBuilder.cpp b/llvm/lib/ExecutionEngine/Orc/JITTargetMachineBuilder.cpp index 0fbf79b..c60f4b3 100644 --- a/llvm/lib/ExecutionEngine/Orc/JITTargetMachineBuilder.cpp +++ b/llvm/lib/ExecutionEngine/Orc/JITTargetMachineBuilder.cpp @@ -19,6 +19,7 @@ JITTargetMachineBuilder::JITTargetMachineBuilder(Triple TT) : TT(std::move(TT)) { Options.EmulatedTLS = true; Options.ExplicitEmulatedTLS = true; + Options.UseInitArray = true; } Expected JITTargetMachineBuilder::detectHost() { diff --git a/llvm/lib/ExecutionEngine/Orc/MachOPlatform.cpp b/llvm/lib/ExecutionEngine/Orc/MachOPlatform.cpp index b2de83a..d5274b0 100644 --- a/llvm/lib/ExecutionEngine/Orc/MachOPlatform.cpp +++ b/llvm/lib/ExecutionEngine/Orc/MachOPlatform.cpp @@ -302,6 +302,10 @@ MachOPlatform::standardRuntimeUtilityAliases() { static const std::pair StandardRuntimeUtilityAliases[] = { {"___orc_rt_run_program", "___orc_rt_macho_run_program"}, + {"___orc_rt_jit_dlerror", "___orc_rt_macho_jit_dlerror"}, + {"___orc_rt_jit_dlopen", "___orc_rt_macho_jit_dlopen"}, + {"___orc_rt_jit_dlclose", "___orc_rt_macho_jit_dlclose"}, + {"___orc_rt_jit_dlsym", "___orc_rt_macho_jit_dlsym"}, {"___orc_rt_log_error", "___orc_rt_log_error_to_stderr"}}; return ArrayRef>( -- cgit v1.1