mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-25 13:24:46 +00:00
[Orc] Add a new JITSymbol constructor to build a symbol from an existing address.
This constructor is more efficient for symbols that have already been emitted, since it avoids the construction/execution of a std::function. Update the ObjectLinkingLayer to use this new constructor where possible. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229973 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -213,16 +213,27 @@ public:
|
||||
/// given object set.
|
||||
JITSymbol findSymbolIn(ObjSetHandleT H, StringRef Name,
|
||||
bool ExportedSymbolsOnly) {
|
||||
if (auto Addr = H->getSymbolAddress(Name, ExportedSymbolsOnly))
|
||||
return JITSymbol(
|
||||
[this, Addr, H](){
|
||||
if (H->NeedsFinalization()) {
|
||||
H->Finalize();
|
||||
if (NotifyFinalized)
|
||||
NotifyFinalized(H);
|
||||
}
|
||||
return Addr;
|
||||
});
|
||||
if (auto Addr = H->getSymbolAddress(Name, ExportedSymbolsOnly)) {
|
||||
if (!H->NeedsFinalization()) {
|
||||
// If this instance has already been finalized then we can just return
|
||||
// the address.
|
||||
return JITSymbol(Addr);
|
||||
} else {
|
||||
// If this instance needs finalization return a functor that will do it.
|
||||
// The functor still needs to double-check whether finalization is
|
||||
// required, in case someone else finalizes this set before the functor
|
||||
// is called.
|
||||
return JITSymbol(
|
||||
[this, Addr, H]() {
|
||||
if (H->NeedsFinalization()) {
|
||||
H->Finalize();
|
||||
if (NotifyFinalized)
|
||||
NotifyFinalized(H);
|
||||
}
|
||||
return Addr;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
Reference in New Issue
Block a user