[PATCH] D107569: [ORC] Emit i386 indirections for 32-bit processes on x86_64 hosts
Stefan Gränitz via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 5 07:24:20 PDT 2021
sgraenitz created this revision.
sgraenitz added reviewers: mgorny, lhames.
Herald added subscribers: pengfei, hiraditya.
sgraenitz requested review of this revision.
Herald added a project: LLVM.
The ORC ABI determines the machine instructions emitted for compiler-generated indirections. We use the target triple to select the right ABI, but the triple detection does not respect the process bitness. Thus, ORC emitted x86_64 instructions instead of i386 ones for 32-bit processes on x86_64 hosts. This caused segfaults in two tests as reported with https://llvm.org/PR51292.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D107569
Files:
llvm/cmake/modules/HandleLLVMOptions.cmake
llvm/lib/ExecutionEngine/Orc/IndirectionUtils.cpp
llvm/lib/ExecutionEngine/Orc/LazyReexports.cpp
Index: llvm/lib/ExecutionEngine/Orc/LazyReexports.cpp
===================================================================
--- llvm/lib/ExecutionEngine/Orc/LazyReexports.cpp
+++ llvm/lib/ExecutionEngine/Orc/LazyReexports.cpp
@@ -132,12 +132,16 @@
return LocalLazyCallThroughManager::Create<OrcMips64>(ES, ErrorHandlerAddr);
case Triple::x86_64:
+#if defined(LLVM_BUILD_32_BITS)
+ return LocalLazyCallThroughManager::Create<OrcI386>(ES, ErrorHandlerAddr);
+#else
if (T.getOS() == Triple::OSType::Win32)
return LocalLazyCallThroughManager::Create<OrcX86_64_Win32>(
ES, ErrorHandlerAddr);
else
return LocalLazyCallThroughManager::Create<OrcX86_64_SysV>(
ES, ErrorHandlerAddr);
+#endif
}
}
Index: llvm/lib/ExecutionEngine/Orc/IndirectionUtils.cpp
===================================================================
--- llvm/lib/ExecutionEngine/Orc/IndirectionUtils.cpp
+++ llvm/lib/ExecutionEngine/Orc/IndirectionUtils.cpp
@@ -148,6 +148,10 @@
}
case Triple::x86_64: {
+#if defined(LLVM_BUILD_32_BITS)
+ typedef orc::LocalJITCompileCallbackManager<orc::OrcI386> CCMgrT;
+ return CCMgrT::Create(ES, ErrorHandlerAddress);
+#else
if (T.getOS() == Triple::OSType::Win32) {
typedef orc::LocalJITCompileCallbackManager<orc::OrcX86_64_Win32> CCMgrT;
return CCMgrT::Create(ES, ErrorHandlerAddress);
@@ -155,8 +159,8 @@
typedef orc::LocalJITCompileCallbackManager<orc::OrcX86_64_SysV> CCMgrT;
return CCMgrT::Create(ES, ErrorHandlerAddress);
}
+#endif
}
-
}
}
@@ -202,6 +206,11 @@
};
case Triple::x86_64:
+#if defined(LLVM_BUILD_32_BITS)
+ return []() {
+ return std::make_unique<orc::LocalIndirectStubsManager<orc::OrcI386>>();
+ };
+#else
if (T.getOS() == Triple::OSType::Win32) {
return [](){
return std::make_unique<
@@ -213,8 +222,8 @@
orc::LocalIndirectStubsManager<orc::OrcX86_64_SysV>>();
};
}
-
- }
+#endif
+ }
}
Constant* createIRTypedAddress(FunctionType &FT, JITTargetAddress Addr) {
Index: llvm/cmake/modules/HandleLLVMOptions.cmake
===================================================================
--- llvm/cmake/modules/HandleLLVMOptions.cmake
+++ llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -365,6 +365,7 @@
# FIXME: CMAKE_SIZEOF_VOID_P is still 8
add_definitions(-D_LARGEFILE_SOURCE)
add_definitions(-D_FILE_OFFSET_BITS=64)
+ add_definitions(-DLLVM_BUILD_32_BITS)
endif( LLVM_BUILD_32_BITS )
endif( CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT WIN32 )
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D107569.364460.patch
Type: text/x-patch
Size: 2625 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210805/83a976b6/attachment.bin>
More information about the llvm-commits
mailing list