Skip to content

Commit

Permalink
Merge pull request #17870 from JuliaLang/yyc/tests/llvm
Browse files Browse the repository at this point in the history
Fix compilation on LLVM 4.0
  • Loading branch information
yuyichao authored Aug 8, 2016
2 parents 174dc5f + b299235 commit a141ccf
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 12 deletions.
27 changes: 17 additions & 10 deletions src/jitlayers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ void JuliaOJIT::DebugObjectRegistrar::operator()(ObjectLinkingLayerBase::ObjSetH
auto NameOrError = Symbol.getName();
assert(NameOrError);
auto Name = NameOrError.get();
orc::JITSymbol Sym = JIT.CompileLayer.findSymbolIn(H, Name, true);
auto Sym = JIT.CompileLayer.findSymbolIn(H, Name, true);
assert(Sym);
// note: calling getAddress here eagerly finalizes H
// as an alternative, we could store the JITSymbol instead
Expand Down Expand Up @@ -507,18 +507,25 @@ void JuliaOJIT::addModule(std::unique_ptr<Module> M)
// TODO: consider moving the FunctionMover resolver here
// Step 0: ObjectLinkingLayer has checked whether it is in the current module
// Step 1: See if it's something known to the ExecutionEngine
if (auto Sym = findSymbol(Name, true))
return RuntimeDyld::SymbolInfo(Sym.getAddress(),
Sym.getFlags());
if (auto Sym = findSymbol(Name, true)) {
#ifdef LLVM40
// `findSymbol` already eagerly resolved the address
// return it directly.
return Sym;
#else
return RuntimeDyld::SymbolInfo(Sym.getAddress(),
Sym.getFlags());
#endif
}
// Step 2: Search the program symbols
if (uint64_t addr = SectionMemoryManager::getSymbolAddressInProcess(Name))
return RuntimeDyld::SymbolInfo(addr, JITSymbolFlags::Exported);
return JL_SymbolInfo(addr, JITSymbolFlags::Exported);
#ifdef _OS_LINUX_
if (uint64_t addr = resolve_atomic(Name.c_str()))
return RuntimeDyld::SymbolInfo(addr, JITSymbolFlags::Exported);
return JL_SymbolInfo(addr, JITSymbolFlags::Exported);
#endif
// Return failure code
return RuntimeDyld::SymbolInfo(nullptr);
return JL_SymbolInfo(nullptr);
},
[](const std::string &S) { return nullptr; }
);
Expand All @@ -536,7 +543,7 @@ void JuliaOJIT::removeModule(ModuleHandleT H)
CompileLayer.removeModuleSet(H);
}

orc::JITSymbol JuliaOJIT::findSymbol(const std::string &Name, bool ExportedSymbolsOnly)
JL_JITSymbol JuliaOJIT::findSymbol(const std::string &Name, bool ExportedSymbolsOnly)
{
void *Addr = nullptr;
if (ExportedSymbolsOnly) {
Expand All @@ -546,10 +553,10 @@ orc::JITSymbol JuliaOJIT::findSymbol(const std::string &Name, bool ExportedSymbo
// Step 2: Search all previously emitted symbols
if (Addr == nullptr)
Addr = LocalSymbolTable[Name];
return orc::JITSymbol((uintptr_t)Addr, JITSymbolFlags::Exported);
return JL_JITSymbol((uintptr_t)Addr, JITSymbolFlags::Exported);
}

orc::JITSymbol JuliaOJIT::findUnmangledSymbol(const std::string Name)
JL_JITSymbol JuliaOJIT::findUnmangledSymbol(const std::string Name)
{
return findSymbol(getMangledName(Name), true);
}
Expand Down
14 changes: 12 additions & 2 deletions src/jitlayers.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,17 @@ extern PassManager *jl_globalPM;

#ifdef LLVM35
#include <llvm/Target/TargetMachine.h>
#endif

#ifdef LLVM40
typedef JITSymbol JL_JITSymbol;
// The type that is similar to SymbolInfo on LLVM 4.0 is actually
// `JITEvaluatedSymbol`. However, we only use this type when a JITSymbol
// is expected.
typedef JITSymbol JL_SymbolInfo;
#else
typedef orc::JITSymbol JL_JITSymbol;
typedef RuntimeDyld::SymbolInfo JL_SymbolInfo;
#endif

extern "C" {
Expand Down Expand Up @@ -184,8 +194,8 @@ class JuliaOJIT {
void *getPointerToGlobalIfAvailable(const GlobalValue *GV);
void addModule(std::unique_ptr<Module> M);
void removeModule(ModuleHandleT H);
orc::JITSymbol findSymbol(const std::string &Name, bool ExportedSymbolsOnly);
orc::JITSymbol findUnmangledSymbol(const std::string Name);
JL_JITSymbol findSymbol(const std::string &Name, bool ExportedSymbolsOnly);
JL_JITSymbol findUnmangledSymbol(const std::string Name);
uint64_t getGlobalValueAddress(const std::string &Name);
uint64_t getFunctionAddress(const std::string &Name);
Function *FindFunctionNamed(const std::string &Name);
Expand Down

0 comments on commit a141ccf

Please sign in to comment.