Rename addSymbol to match what it does and remove redundant params.

This commit is contained in:
Vassil Vassilev 2022-03-25 22:00:52 +00:00 committed by jenkins
parent a804b3d9eb
commit 8115be39be
5 changed files with 20 additions and 24 deletions

View File

@ -319,9 +319,12 @@ IncrementalExecutor::installLazyFunctionCreator(LazyFunctionCreatorFunc_t fp)
m_lazyFuncCreator.push_back(fp);
}
void IncrementalExecutor::addSymbol(const char* Name, void* Addr,
bool Jit) const {
m_JIT->addDefinition(Name, llvm::pointerToJITTargetAddress(Addr), Jit);
void IncrementalExecutor::replaceSymbol(const char* Name, void* Addr) const {
assert(Addr);
// FIXME: Look at the registration of at_quick_exit and uncomment.
// assert(m_JIT->getSymbolAddress(Name, /*IncludeHostSymbols*/true) &&
// "The symbol must exist");
m_JIT->addOrReplaceDefinition(Name, llvm::pointerToJITTargetAddress(Addr));
}
void* IncrementalExecutor::getAddressOfGlobal(llvm::StringRef symbolName,

View File

@ -193,7 +193,7 @@ namespace cling {
///\brief Runs a wrapper function.
ExecutionResult executeWrapper(llvm::StringRef function,
Value* returnValue = 0) const;
///\brief Adds a symbol (function) to the execution engine.
///\brief Replaces a symbol (function) to the execution engine.
///
/// Allows runtime declaration of a function passing its pointer for being
/// used by JIT generated code.
@ -201,10 +201,7 @@ namespace cling {
/// @param[in] Name - The name of the symbol as required by the
/// linker (mangled if needed)
/// @param[in] Address - The function pointer to register
/// @param[in] JIT - Add to the JIT injected symbol table
/// @returns true if the symbol is successfully registered, false otherwise.
///
void addSymbol(const char* Name, void* Address, bool JIT = false) const;
void replaceSymbol(const char* Name, void* Address) const;
///\brief Tells the execution to run all registered atexit functions once.
///

View File

@ -131,10 +131,8 @@ llvm::Error IncrementalJIT::removeModule(const Transaction& T) {
return llvm::Error::success();
}
JITTargetAddress IncrementalJIT::addDefinition(StringRef LinkerMangledName,
JITTargetAddress KnownAddr,
bool AcceptExisting) {
void* Symbol = getSymbolAddress(LinkerMangledName, /*ExcludeFromHost=*/false);
JITTargetAddress IncrementalJIT::addOrReplaceDefinition(StringRef LinkerMangledName,
JITTargetAddress KnownAddr) {
// Nothing to define, we are redefining the same function. FIXME: Diagnose.
if (Symbol && (JITTargetAddress)Symbol == KnownAddr)

View File

@ -66,11 +66,9 @@ public:
/// should include symbols from the host process or not.
void* getSymbolAddress(llvm::StringRef Name, bool ExcludeHostSymbols);
/// Inject a symbol with a known address. Collisions will cause an error
/// unless AcceptExisting = true.
llvm::JITTargetAddress addDefinition(llvm::StringRef LinkerMangledName,
llvm::JITTargetAddress KnownAddr,
bool AcceptExisting = false);
/// Inject a symbol with a known address.
llvm::JITTargetAddress addOrReplaceDefinition(llvm::StringRef LinkerMangledName,
llvm::JITTargetAddress KnownAddr);
llvm::Error runCtors() const {
return Jit->initialize(Jit->getMainJITDylib());

View File

@ -327,7 +327,7 @@ namespace cling {
if (!Addr) {
cling::errs() << "Replaced symbol " << Sym << " cannot be found in JIT!\n";
} else {
m_Executor->addSymbol(Sym.str().c_str(), Addr, true);
m_Executor->replaceSymbol(Sym.str().c_str(), Addr);
}
}
}
@ -537,10 +537,10 @@ namespace cling {
if (!SyntaxOnly) {
// Override the native symbols now, before anything can be emitted.
m_Executor->addSymbol("__cxa_atexit",
utils::FunctionToVoidPtr(&local_cxa_atexit), true);
m_Executor->replaceSymbol("__cxa_atexit",
utils::FunctionToVoidPtr(&local_cxa_atexit));
// __dso_handle is inserted for the link phase, as macro is useless then
m_Executor->addSymbol("__dso_handle", this, true);
m_Executor->replaceSymbol("__dso_handle", this);
#ifdef _MSC_VER
// According to the PE Format spec, in "The .tls Section"
@ -551,13 +551,13 @@ namespace cling {
// array is at the offset of 0x2C from the beginning of TEB. This
// behavior is Intel x86-specific.
static const unsigned long _tls_array = 0x2C;
m_Executor->addSymbol("_tls_array", (void *)&_tls_array, true);
m_Executor->replaceSymbol("_tls_array", (void *)&_tls_array);
#endif
#ifdef CLING_WIN_SEH_EXCEPTIONS
// Windows C++ SEH handler
m_Executor->addSymbol("_CxxThrowException",
utils::FunctionToVoidPtr(&platform::ClingRaiseSEHException), true);
m_Executor->replaceSymbol("_CxxThrowException",
utils::FunctionToVoidPtr(&platform::ClingRaiseSEHException));
#endif
}