From 2f50744fe723b48389ed1f30e8f3e73217a66f9e Mon Sep 17 00:00:00 2001 From: Lang Hames Date: Thu, 2 Apr 2015 05:28:10 +0000 Subject: [PATCH] [Orc] Fix local-linkage handling in the CompileOnDemand layer. llvm-svn: 233895 --- llvm/lib/ExecutionEngine/Orc/IndirectionUtils.cpp | 4 ++-- llvm/test/ExecutionEngine/OrcLazy/private_linkage.ll | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 llvm/test/ExecutionEngine/OrcLazy/private_linkage.ll diff --git a/llvm/lib/ExecutionEngine/Orc/IndirectionUtils.cpp b/llvm/lib/ExecutionEngine/Orc/IndirectionUtils.cpp index 8cf490f34cb3..74766450e8c4 100644 --- a/llvm/lib/ExecutionEngine/Orc/IndirectionUtils.cpp +++ b/llvm/lib/ExecutionEngine/Orc/IndirectionUtils.cpp @@ -54,7 +54,7 @@ void partition(Module &M, const ModulePartitionMap &PMap) { if (KVPair.second.count(&Orig)) { copyGVInitializer(New, Orig, VMap); } - if (New.getLinkage() == GlobalValue::PrivateLinkage) { + if (New.hasLocalLinkage()) { New.setLinkage(GlobalValue::ExternalLinkage); New.setVisibility(GlobalValue::HiddenVisibility); } @@ -64,7 +64,7 @@ void partition(Module &M, const ModulePartitionMap &PMap) { [&](Function &New, const Function &Orig, ValueToValueMapTy &VMap) { if (KVPair.second.count(&Orig)) copyFunctionBody(New, Orig, VMap); - if (New.getLinkage() == GlobalValue::InternalLinkage) { + if (New.hasLocalLinkage()) { New.setLinkage(GlobalValue::ExternalLinkage); New.setVisibility(GlobalValue::HiddenVisibility); } diff --git a/llvm/test/ExecutionEngine/OrcLazy/private_linkage.ll b/llvm/test/ExecutionEngine/OrcLazy/private_linkage.ll new file mode 100644 index 000000000000..11813dd97760 --- /dev/null +++ b/llvm/test/ExecutionEngine/OrcLazy/private_linkage.ll @@ -0,0 +1,12 @@ +; RUN: lli -jit-kind=orc-lazy %s + +define private void @_ZL3foov() { +entry: + ret void +} + +define i32 @main(i32 %argc, i8** nocapture readnone %argv) { +entry: + tail call void @_ZL3foov() + ret i32 0 +}