Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 24 additions & 7 deletions interpreter/cling/lib/Interpreter/IncrementalJIT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,28 @@ using namespace llvm;
using namespace llvm::jitlink;
using namespace llvm::orc;

static LLVM_ATTRIBUTE_USED void linkComponents() {
errs() << "Linking in runtime functions\n"
<< (void*)&llvm_orc_registerJITLoaderPerfStart << '\n'
<< (void*)&llvm_orc_registerJITLoaderPerfEnd << '\n'
<< (void*)&llvm_orc_registerJITLoaderPerfImpl << '\n';
}

namespace {
static SymbolMap GetListOfPerfSymbols(const LLJIT& Jit) {
// ORC's perf support plugin looks up these runtime entry points through the
// process symbol table. In ROOT, the symbols will remain hidden inside
// libCling.so. Explicitly inject them into the JITDylib.
static const std::pair<const char*, const void*> NamePtrList[] = {
{"llvm_orc_registerJITLoaderPerfStart",
(void*)&llvm_orc_registerJITLoaderPerfStart},
{"llvm_orc_registerJITLoaderPerfEnd",
(void*)&llvm_orc_registerJITLoaderPerfEnd},
{"llvm_orc_registerJITLoaderPerfImpl",
(void*)&llvm_orc_registerJITLoaderPerfImpl},
};

SymbolMap PerfSymbols;
for (const auto& NamePtr : NamePtrList) {
PerfSymbols[Jit.mangleAndIntern(NamePtr.first)] = {
orc::ExecutorAddr::fromPtr(NamePtr.second), JITSymbolFlags::Exported};
}
return PerfSymbols;
}

// This could potentially be upstreamed, similar to enableDebuggerSupport()
Error enablePerfSupport(LLJIT& J) {
auto* ObjLinkingLayer =
Expand All @@ -66,6 +80,9 @@ namespace {
"Process symbols are not available",
inconvertibleErrorCode());

// Manually define the symbols
cantFail(ProcessSymsJD->define(absoluteSymbols(GetListOfPerfSymbols(J))));

auto& ES = J.getExecutionSession();
const auto& TT = J.getTargetTriple();

Expand Down
Loading