Simplify symbol overrides
There is no need to force symbol emission, get the address from the JIT, and then replace the symbol once more.
This commit is contained in:
parent
900be1d0e8
commit
c201269a09
@ -334,12 +334,10 @@ namespace cling {
|
||||
///
|
||||
///\param[in] NoRuntime - Don't include the runtime headers / gCling
|
||||
///\param[in] SyntaxOnly - In SyntaxOnly mode
|
||||
///\param[out] Globals - Global symbols that need to be emitted
|
||||
///
|
||||
///\returns The resulting Transation of initialization.
|
||||
///
|
||||
Transaction* Initialize(bool NoRuntime, bool SyntaxOnly,
|
||||
llvm::SmallVectorImpl<llvm::StringRef>& Globals);
|
||||
Transaction* Initialize(bool NoRuntime, bool SyntaxOnly);
|
||||
|
||||
///\ Shut down the interpreter runtime.
|
||||
///
|
||||
|
@ -327,8 +327,7 @@ namespace cling {
|
||||
setupCallbacks(*this, parentInterp);
|
||||
}
|
||||
|
||||
llvm::SmallVector<llvm::StringRef, 6> Syms;
|
||||
Initialize(noRuntime || m_Opts.NoRuntime, isInSyntaxOnlyMode(), Syms);
|
||||
Initialize(noRuntime || m_Opts.NoRuntime, isInSyntaxOnlyMode());
|
||||
|
||||
// Commit the transactions, now that gCling is set up. It is needed for
|
||||
// static initialization in these transactions through
|
||||
@ -336,24 +335,6 @@ namespace cling {
|
||||
for (auto&& I: IncrParserTransactions)
|
||||
m_IncrParser->commitTransaction(I);
|
||||
|
||||
// Now that the transactions have been commited, force symbol emission
|
||||
// and overrides.
|
||||
if (!isInSyntaxOnlyMode() && !m_Opts.CompilerOpts.CUDADevice) {
|
||||
for (const llvm::StringRef& Sym : Syms) {
|
||||
void* Addr = m_Executor->getPointerToGlobalFromJIT(Sym);
|
||||
#if defined(__linux__)
|
||||
// We need to look for the mangled name of at_quick_exit on linux.
|
||||
if (!Addr && Sym.equals("at_quick_exit"))
|
||||
Addr = m_Executor->getPointerToGlobalFromJIT("_Z13at_quick_exitPFvvE");
|
||||
#endif
|
||||
if (!Addr) {
|
||||
cling::errs() << "Replaced symbol " << Sym << " cannot be found in JIT!\n";
|
||||
} else {
|
||||
m_Executor->replaceSymbol(Sym.str().c_str(), Addr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_IncrParser->SetTransformers(parentInterp);
|
||||
|
||||
if (!TSCtx->getContext()) {
|
||||
@ -423,8 +404,7 @@ namespace cling {
|
||||
m_IncrParser.reset(nullptr);
|
||||
}
|
||||
|
||||
Transaction* Interpreter::Initialize(bool NoRuntime, bool SyntaxOnly,
|
||||
llvm::SmallVectorImpl<llvm::StringRef>& Globals) {
|
||||
Transaction* Interpreter::Initialize(bool NoRuntime, bool SyntaxOnly) {
|
||||
// The Initialize() function is called twice in CUDA mode. The first time
|
||||
// the host interpreter is initialized and the second time the device
|
||||
// interpreter is initialized. Without this if statement, a redefinition
|
||||
@ -521,7 +501,6 @@ namespace cling {
|
||||
<< " { return __cxa_atexit((void(*)(void*))f, 0, __dso_handle); }\n";
|
||||
else
|
||||
Strm << ";\n";
|
||||
Globals.push_back("at_quick_exit");
|
||||
}
|
||||
|
||||
#if defined(_WIN32)
|
||||
@ -539,7 +518,6 @@ namespace cling {
|
||||
" return f; }\n";
|
||||
else
|
||||
Strm << ";\n";
|
||||
Globals.push_back("__dllonexit");
|
||||
#if !defined(_M_CEE_PURE)
|
||||
Strm << Linkage << " " << Spec << " int (*_onexit("
|
||||
<< "int (" << Spec << " *f)()))()";
|
||||
@ -548,7 +526,6 @@ namespace cling {
|
||||
" return f; }\n";
|
||||
else
|
||||
Strm << ";\n";
|
||||
Globals.push_back("_onexit");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user