Make IncrementalExecutor::replaceSymbol() take IR names:
Previously, one needed to pass linker-mangled names, which exposes details that clients of IncrementalExecutor should not have to deal with. Instead, use the IR name and do the linker-mangling in IncrementalJIT::addOrReplaceDefinition(). This fixes the lack of static destruction on macOS, visible e.g. in the test failure of roottest/cling/staticinit/ROOT-7775.
This commit is contained in:
parent
76d96e317f
commit
13b4be1603
@ -197,8 +197,7 @@ namespace cling {
|
||||
/// Allows runtime declaration of a function passing its pointer for being
|
||||
/// used by JIT generated code.
|
||||
///
|
||||
/// @param[in] Name - The name of the symbol as required by the
|
||||
/// linker (mangled if needed)
|
||||
/// @param[in] Name - The name of the symbol as known by the IR.
|
||||
/// @param[in] Address - The function pointer to register
|
||||
void replaceSymbol(const char* Name, void* Address) const;
|
||||
|
||||
|
@ -152,14 +152,26 @@ llvm::Error IncrementalJIT::removeModule(const Transaction& T) {
|
||||
return llvm::Error::success();
|
||||
}
|
||||
|
||||
JITTargetAddress IncrementalJIT::addOrReplaceDefinition(StringRef LinkerMangledName,
|
||||
JITTargetAddress
|
||||
IncrementalJIT::addOrReplaceDefinition(StringRef Name,
|
||||
JITTargetAddress KnownAddr) {
|
||||
void* Symbol = getSymbolAddress(LinkerMangledName, /*IncludeFromHost=*/true);
|
||||
|
||||
void* Symbol = getSymbolAddress(Name, /*IncludeFromHost=*/true);
|
||||
|
||||
// Nothing to define, we are redefining the same function. FIXME: Diagnose.
|
||||
if (Symbol && (JITTargetAddress)Symbol == KnownAddr)
|
||||
return KnownAddr;
|
||||
|
||||
llvm::SmallString<128> LinkerMangledName;
|
||||
char LinkerPrefix = this->TM->createDataLayout().getGlobalPrefix();
|
||||
bool HasLinkerPrefix = LinkerPrefix != '\0';
|
||||
if (HasLinkerPrefix && Name.front() == LinkerPrefix) {
|
||||
LinkerMangledName.assign(1, LinkerPrefix);
|
||||
LinkerMangledName.append(Name);
|
||||
} else {
|
||||
LinkerMangledName.assign(Name);
|
||||
}
|
||||
|
||||
// Let's inject it
|
||||
bool Inserted;
|
||||
SymbolMap::iterator It;
|
||||
|
@ -74,8 +74,9 @@ public:
|
||||
/// should include symbols from the host process (via dlsym) or not.
|
||||
void* getSymbolAddress(llvm::StringRef Name, bool IncludeHostSymbols);
|
||||
|
||||
/// Inject a symbol with a known address.
|
||||
llvm::JITTargetAddress addOrReplaceDefinition(llvm::StringRef LinkerMangledName,
|
||||
/// Inject a symbol with a known address. Name is not linker mangled, i.e.
|
||||
/// as known by the IR.
|
||||
llvm::JITTargetAddress addOrReplaceDefinition(llvm::StringRef Name,
|
||||
llvm::JITTargetAddress KnownAddr);
|
||||
|
||||
llvm::Error runCtors() const {
|
||||
|
Loading…
Reference in New Issue
Block a user