[llvm] 498dd74 - [ORC] Honor linker private global prefix on symbol names.
Lang Hames via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 15 10:28:47 PDT 2020
Author: Lang Hames
Date: 2020-06-15T10:28:36-07:00
New Revision: 498dd745f55b1d38e6648f425dd9c0a42c52a4cf
URL: https://github.com/llvm/llvm-project/commit/498dd745f55b1d38e6648f425dd9c0a42c52a4cf
DIFF: https://github.com/llvm/llvm-project/commit/498dd745f55b1d38e6648f425dd9c0a42c52a4cf.diff
LOG: [ORC] Honor linker private global prefix on symbol names.
If a symbol name begins with the linker private global prefix (as
described by the DataLayout) then it should be treated as non-exported,
regardless of its LLVM IR visibility value.
Added:
Modified:
llvm/lib/ExecutionEngine/RuntimeDyld/JITSymbol.cpp
llvm/test/ExecutionEngine/OrcLazy/private_linkage.ll
Removed:
################################################################################
diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/JITSymbol.cpp b/llvm/lib/ExecutionEngine/RuntimeDyld/JITSymbol.cpp
index b445d3d49d7e..0f6f9efe1102 100644
--- a/llvm/lib/ExecutionEngine/RuntimeDyld/JITSymbol.cpp
+++ b/llvm/lib/ExecutionEngine/RuntimeDyld/JITSymbol.cpp
@@ -20,6 +20,8 @@
using namespace llvm;
JITSymbolFlags llvm::JITSymbolFlags::fromGlobalValue(const GlobalValue &GV) {
+ assert(GV.hasName() && "Can't get flags for anonymous symbol");
+
JITSymbolFlags Flags = JITSymbolFlags::None;
if (GV.hasWeakLinkage() || GV.hasLinkOnceLinkage())
Flags |= JITSymbolFlags::Weak;
@@ -34,6 +36,16 @@ JITSymbolFlags llvm::JITSymbolFlags::fromGlobalValue(const GlobalValue &GV) {
isa<Function>(cast<GlobalAlias>(GV).getAliasee()))
Flags |= JITSymbolFlags::Callable;
+ // Check for a linker-private-global-prefix on the symbol name, in which
+ // case it must be marked as non-exported.
+ if (auto *M = GV.getParent()) {
+ const auto &DL = M->getDataLayout();
+ StringRef LPGP = DL.getLinkerPrivateGlobalPrefix();
+ if (!LPGP.empty() && GV.getName().front() == '\01' &&
+ GV.getName().substr(1).startswith(LPGP))
+ Flags &= ~JITSymbolFlags::Exported;
+ }
+
return Flags;
}
diff --git a/llvm/test/ExecutionEngine/OrcLazy/private_linkage.ll b/llvm/test/ExecutionEngine/OrcLazy/private_linkage.ll
index 11813dd97760..c8f1531f3139 100644
--- a/llvm/test/ExecutionEngine/OrcLazy/private_linkage.ll
+++ b/llvm/test/ExecutionEngine/OrcLazy/private_linkage.ll
@@ -1,12 +1,18 @@
; RUN: lli -jit-kind=orc-lazy %s
-define private void @_ZL3foov() {
+define private void @foo() {
+entry:
+ ret void
+}
+
+define void @"\01l_bar"() {
entry:
ret void
}
define i32 @main(i32 %argc, i8** nocapture readnone %argv) {
entry:
- tail call void @_ZL3foov()
+ call void @foo()
+ call void @"\01l_bar"()
ret i32 0
}
More information about the llvm-commits
mailing list