Skip to content

Commit

Permalink
Simplify addOrReplaceDefinition
Browse files Browse the repository at this point in the history
Calling getSymbolAddress will force symbol emission, which is not
needed if the intent is to replace it.
  • Loading branch information
hahnjo authored and jenkins committed Jul 3, 2024
1 parent c201269 commit 3e59d62
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions lib/Interpreter/IncrementalJIT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -642,12 +642,6 @@ JITTargetAddress
IncrementalJIT::addOrReplaceDefinition(StringRef Name,
JITTargetAddress KnownAddr) {

void* Symbol = getSymbolAddress(Name, /*IncludeFromHost=*/true);

// Nothing to define, we are redefining the same function. FIXME: Diagnose.
if (Symbol && (JITTargetAddress)Symbol == KnownAddr)
return KnownAddr;

// Let's inject it
bool Inserted;
SymbolMap::iterator It;
Expand All @@ -658,9 +652,7 @@ IncrementalJIT::addOrReplaceDefinition(StringRef Name,

JITDylib& DyLib = Jit->getMainJITDylib();
// We want to replace a symbol with a custom provided one.
if (Symbol && KnownAddr)
// The symbol be in the DyLib or in-process.
llvm::consumeError(DyLib.remove({It->first}));
llvm::consumeError(DyLib.remove({It->first}));

if (Error Err = DyLib.define(absoluteSymbols({*It}))) {
logAllUnhandledErrors(std::move(Err), errs(),
Expand Down

0 comments on commit 3e59d62

Please sign in to comment.