Reapply "[ORC] Enable JIT support for the compact-unwind frame..." with fixes.
This reapplies4f0325873f(and follow up patches26fc07d5d8,a001cc0e6c,c9bc242e38, andfd174f0ff3), which were reverted in212cdc9a37to investigate bot failures (e.g. https://lab.llvm.org/buildbot/#/builders/108/builds/8502) The fix to address the bot failures was landed ind0052ebbe2. This patch also restricts construction of the UnwindInfoManager object to Apple platforms (as it won't be used on other platforms).
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
// clang-format off
|
||||
// UNSUPPORTED: system-aix
|
||||
// XFAIL for arm and arm64, or running on Windows.
|
||||
// XFAIL: target=arm{{.*}}, system-windows
|
||||
// XFAIL for arm, or running on Windows.
|
||||
// XFAIL: target=arm-{{.*}}, target=armv{{.*}}, system-windows
|
||||
// RUN: cat %s | clang-repl | FileCheck %s
|
||||
|
||||
// Incompatible with msan. It passes with -O3 but fail -Oz. Interpreter
|
||||
|
||||
@@ -557,6 +557,12 @@ Error MachOPlatformRuntimeState::registerObjectPlatformSections(
|
||||
return make_error<StringError>(ErrStream.str());
|
||||
}
|
||||
|
||||
ORC_RT_DEBUG({
|
||||
printdbg(" UnwindInfo: %s, UseCallbackStyleUnwindInfo: %s\n",
|
||||
UnwindInfo ? "true" : "false",
|
||||
UseCallbackStyleUnwindInfo ? "true" : "false");
|
||||
});
|
||||
|
||||
if (UnwindInfo && UseCallbackStyleUnwindInfo) {
|
||||
ORC_RT_DEBUG({
|
||||
printdbg(" Registering new-style unwind info for:\n"
|
||||
|
||||
@@ -1204,8 +1204,13 @@ private:
|
||||
|
||||
JITDylib(ExecutionSession &ES, std::string Name);
|
||||
|
||||
std::pair<AsynchronousSymbolQuerySet, std::shared_ptr<SymbolDependenceMap>>
|
||||
IL_removeTracker(ResourceTracker &RT);
|
||||
struct RemoveTrackerResult {
|
||||
AsynchronousSymbolQuerySet QueriesToFail;
|
||||
std::shared_ptr<SymbolDependenceMap> FailedSymbols;
|
||||
std::vector<std::unique_ptr<MaterializationUnit>> DefunctMUs;
|
||||
};
|
||||
|
||||
RemoveTrackerResult IL_removeTracker(ResourceTracker &RT);
|
||||
|
||||
void transferTracker(ResourceTracker &DstRT, ResourceTracker &SrcRT);
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "llvm/ExecutionEngine/Orc/Shared/TargetProcessControlTypes.h"
|
||||
#include "llvm/ExecutionEngine/Orc/Shared/WrapperFunctionUtils.h"
|
||||
#include "llvm/ExecutionEngine/Orc/SymbolStringPool.h"
|
||||
#include "llvm/ExecutionEngine/Orc/TargetProcess/UnwindInfoManager.h"
|
||||
#include "llvm/ExecutionEngine/Orc/TaskDispatch.h"
|
||||
#include "llvm/Support/DynamicLibrary.h"
|
||||
#include "llvm/Support/MSVCErrorWorkarounds.h"
|
||||
@@ -507,6 +508,9 @@ private:
|
||||
SymbolLookupCompleteFn F) override;
|
||||
|
||||
std::unique_ptr<jitlink::JITLinkMemoryManager> OwnedMemMgr;
|
||||
#ifdef __APPLE__
|
||||
std::unique_ptr<UnwindInfoManager> UnwindInfoMgr;
|
||||
#endif // __APPLE__
|
||||
char GlobalManglingPrefix = 0;
|
||||
};
|
||||
|
||||
|
||||
@@ -88,6 +88,15 @@ using SPSRunAsMainSignature = int64_t(shared::SPSExecutorAddr,
|
||||
using SPSRunAsVoidFunctionSignature = int32_t(shared::SPSExecutorAddr);
|
||||
using SPSRunAsIntFunctionSignature = int32_t(shared::SPSExecutorAddr, int32_t);
|
||||
} // end namespace rt
|
||||
|
||||
namespace rt_alt {
|
||||
extern const char *UnwindInfoManagerInstanceName;
|
||||
extern const char *UnwindInfoManagerFindSectionsHelperName;
|
||||
extern const char *UnwindInfoManagerEnableWrapperName;
|
||||
extern const char *UnwindInfoManagerDisableWrapperName;
|
||||
extern const char *UnwindInfoManagerRegisterActionName;
|
||||
extern const char *UnwindInfoManagerDeregisterActionName;
|
||||
} // end namespace rt_alt
|
||||
} // end namespace orc
|
||||
} // end namespace llvm
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ tablegen(LLVM COFFOptions.inc -gen-opt-parser-defs)
|
||||
add_public_tablegen_target(JITLinkTableGen)
|
||||
|
||||
add_llvm_component_library(LLVMJITLink
|
||||
CompactUnwindSupport.cpp
|
||||
DWARFRecordSectionSplitter.cpp
|
||||
EHFrameSupport.cpp
|
||||
JITLink.cpp
|
||||
|
||||
@@ -733,121 +733,5 @@ Error MachOLinkGraphBuilder::graphifyCStringSection(
|
||||
return Error::success();
|
||||
}
|
||||
|
||||
Error CompactUnwindSplitter::operator()(LinkGraph &G) {
|
||||
auto *CUSec = G.findSectionByName(CompactUnwindSectionName);
|
||||
if (!CUSec)
|
||||
return Error::success();
|
||||
|
||||
if (!G.getTargetTriple().isOSBinFormatMachO())
|
||||
return make_error<JITLinkError>(
|
||||
"Error linking " + G.getName() +
|
||||
": compact unwind splitting not supported on non-macho target " +
|
||||
G.getTargetTriple().str());
|
||||
|
||||
unsigned CURecordSize = 0;
|
||||
unsigned PersonalityEdgeOffset = 0;
|
||||
unsigned LSDAEdgeOffset = 0;
|
||||
switch (G.getTargetTriple().getArch()) {
|
||||
case Triple::aarch64:
|
||||
case Triple::x86_64:
|
||||
// 64-bit compact-unwind record format:
|
||||
// Range start: 8 bytes.
|
||||
// Range size: 4 bytes.
|
||||
// CU encoding: 4 bytes.
|
||||
// Personality: 8 bytes.
|
||||
// LSDA: 8 bytes.
|
||||
CURecordSize = 32;
|
||||
PersonalityEdgeOffset = 16;
|
||||
LSDAEdgeOffset = 24;
|
||||
break;
|
||||
default:
|
||||
return make_error<JITLinkError>(
|
||||
"Error linking " + G.getName() +
|
||||
": compact unwind splitting not supported on " +
|
||||
G.getTargetTriple().getArchName());
|
||||
}
|
||||
|
||||
std::vector<Block *> OriginalBlocks(CUSec->blocks().begin(),
|
||||
CUSec->blocks().end());
|
||||
LLVM_DEBUG({
|
||||
dbgs() << "In " << G.getName() << " splitting compact unwind section "
|
||||
<< CompactUnwindSectionName << " containing "
|
||||
<< OriginalBlocks.size() << " initial blocks...\n";
|
||||
});
|
||||
|
||||
while (!OriginalBlocks.empty()) {
|
||||
auto *B = OriginalBlocks.back();
|
||||
OriginalBlocks.pop_back();
|
||||
|
||||
if (B->getSize() == 0) {
|
||||
LLVM_DEBUG({
|
||||
dbgs() << " Skipping empty block at "
|
||||
<< formatv("{0:x16}", B->getAddress()) << "\n";
|
||||
});
|
||||
continue;
|
||||
}
|
||||
|
||||
unsigned NumBlocks = B->getSize() / CURecordSize;
|
||||
|
||||
LLVM_DEBUG({
|
||||
dbgs() << " Splitting block at " << formatv("{0:x16}", B->getAddress())
|
||||
<< " into " << NumBlocks << " compact unwind record(s)\n";
|
||||
});
|
||||
|
||||
if (B->getSize() % CURecordSize)
|
||||
return make_error<JITLinkError>(
|
||||
"Error splitting compact unwind record in " + G.getName() +
|
||||
": block at " + formatv("{0:x}", B->getAddress()) + " has size " +
|
||||
formatv("{0:x}", B->getSize()) +
|
||||
" (not a multiple of CU record size of " +
|
||||
formatv("{0:x}", CURecordSize) + ")");
|
||||
|
||||
auto Blocks =
|
||||
G.splitBlock(*B, map_range(seq(1U, NumBlocks), [=](Edge::OffsetT Idx) {
|
||||
return Idx * CURecordSize;
|
||||
}));
|
||||
|
||||
for (auto *CURec : Blocks) {
|
||||
bool AddedKeepAlive = false;
|
||||
|
||||
for (auto &E : CURec->edges()) {
|
||||
if (E.getOffset() == 0) {
|
||||
LLVM_DEBUG({
|
||||
dbgs() << " Updating compact unwind record at "
|
||||
<< CURec->getAddress() << " to point to "
|
||||
<< (E.getTarget().hasName() ? *E.getTarget().getName()
|
||||
: StringRef())
|
||||
<< " (at " << E.getTarget().getAddress() << ")\n";
|
||||
});
|
||||
|
||||
if (E.getTarget().isExternal())
|
||||
return make_error<JITLinkError>(
|
||||
"Error adding keep-alive edge for compact unwind record at " +
|
||||
formatv("{0:x}", CURec->getAddress()) + ": target " +
|
||||
*E.getTarget().getName() + " is an external symbol");
|
||||
auto &TgtBlock = E.getTarget().getBlock();
|
||||
auto &CURecSym =
|
||||
G.addAnonymousSymbol(*CURec, 0, CURecordSize, false, false);
|
||||
TgtBlock.addEdge(Edge::KeepAlive, 0, CURecSym, 0);
|
||||
AddedKeepAlive = true;
|
||||
} else if (E.getOffset() != PersonalityEdgeOffset &&
|
||||
E.getOffset() != LSDAEdgeOffset)
|
||||
return make_error<JITLinkError>(
|
||||
"Unexpected edge at offset " + formatv("{0:x}", E.getOffset()) +
|
||||
" in compact unwind record at " +
|
||||
formatv("{0:x}", CURec->getAddress()));
|
||||
}
|
||||
|
||||
if (!AddedKeepAlive)
|
||||
return make_error<JITLinkError>(
|
||||
"Error adding keep-alive edge for compact unwind record at " +
|
||||
formatv("{0:x}", CURec->getAddress()) +
|
||||
": no outgoing target edge at offset 0");
|
||||
}
|
||||
}
|
||||
|
||||
return Error::success();
|
||||
}
|
||||
|
||||
} // end namespace jitlink
|
||||
} // end namespace llvm
|
||||
|
||||
@@ -236,17 +236,6 @@ private:
|
||||
StringMap<SectionParserFunction> CustomSectionParserFunctions;
|
||||
};
|
||||
|
||||
/// A pass to split up __LD,__compact_unwind sections.
|
||||
class CompactUnwindSplitter {
|
||||
public:
|
||||
CompactUnwindSplitter(StringRef CompactUnwindSectionName)
|
||||
: CompactUnwindSectionName(CompactUnwindSectionName) {}
|
||||
Error operator()(LinkGraph &G);
|
||||
|
||||
private:
|
||||
StringRef CompactUnwindSectionName;
|
||||
};
|
||||
|
||||
} // end namespace jitlink
|
||||
} // end namespace llvm
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "llvm/ExecutionEngine/JITLink/DWARFRecordSectionSplitter.h"
|
||||
#include "llvm/ExecutionEngine/JITLink/aarch64.h"
|
||||
|
||||
#include "CompactUnwindSupport.h"
|
||||
#include "DefineExternalSectionStartAndEndSymbols.h"
|
||||
#include "MachOLinkGraphBuilder.h"
|
||||
|
||||
@@ -625,6 +626,27 @@ static Error applyPACSigningToModInitPointers(LinkGraph &G) {
|
||||
return Error::success();
|
||||
}
|
||||
|
||||
struct CompactUnwindTraits_MachO_arm64
|
||||
: public CompactUnwindTraits<CompactUnwindTraits_MachO_arm64,
|
||||
/* PointerSize = */ 8> {
|
||||
// FIXME: Reinstate once we no longer need the MSVC workaround. See
|
||||
// FIXME for CompactUnwindTraits in CompactUnwindSupport.h.
|
||||
// constexpr static size_t PointerSize = 8;
|
||||
|
||||
constexpr static endianness Endianness = endianness::little;
|
||||
|
||||
constexpr static uint32_t EncodingModeMask = 0x0f000000;
|
||||
|
||||
using GOTManager = aarch64::GOTTableManager;
|
||||
|
||||
static bool encodingSpecifiesDWARF(uint32_t Encoding) {
|
||||
constexpr uint32_t DWARFMode = 0x03000000;
|
||||
return (Encoding & EncodingModeMask) == DWARFMode;
|
||||
}
|
||||
|
||||
static bool encodingCannotBeMerged(uint32_t Encoding) { return false; }
|
||||
};
|
||||
|
||||
void link_MachO_arm64(std::unique_ptr<LinkGraph> G,
|
||||
std::unique_ptr<JITLinkContext> Ctx) {
|
||||
|
||||
@@ -637,16 +659,21 @@ void link_MachO_arm64(std::unique_ptr<LinkGraph> G,
|
||||
else
|
||||
Config.PrePrunePasses.push_back(markAllSymbolsLive);
|
||||
|
||||
// Add compact unwind splitter pass.
|
||||
Config.PrePrunePasses.push_back(
|
||||
CompactUnwindSplitter("__LD,__compact_unwind"));
|
||||
|
||||
// Add eh-frame passes.
|
||||
// FIXME: Prune eh-frames for which compact-unwind is available once
|
||||
// we support compact-unwind registration with libunwind.
|
||||
Config.PrePrunePasses.push_back(createEHFrameSplitterPass_MachO_arm64());
|
||||
Config.PrePrunePasses.push_back(createEHFrameEdgeFixerPass_MachO_arm64());
|
||||
|
||||
// Create a compact-unwind manager for use in passes below.
|
||||
auto CompactUnwindMgr =
|
||||
std::make_shared<CompactUnwindManager<CompactUnwindTraits_MachO_arm64>>(
|
||||
"__LD,__compact_unwind", "__TEXT,__unwind_info",
|
||||
"__TEXT,__eh_frame");
|
||||
|
||||
// Add compact unwind prepare pass.
|
||||
Config.PrePrunePasses.push_back([CompactUnwindMgr](LinkGraph &G) {
|
||||
return CompactUnwindMgr->prepareForPrune(G);
|
||||
});
|
||||
|
||||
// Resolve any external section start / end symbols.
|
||||
Config.PostAllocationPasses.push_back(
|
||||
createDefineExternalSectionStartAndEndSymbolsPass(
|
||||
@@ -663,6 +690,16 @@ void link_MachO_arm64(std::unique_ptr<LinkGraph> G,
|
||||
Config.PreFixupPasses.push_back(
|
||||
aarch64::lowerPointer64AuthEdgesToSigningFunction);
|
||||
}
|
||||
|
||||
// Reserve unwind-info space.
|
||||
Config.PostPrunePasses.push_back([CompactUnwindMgr](LinkGraph &G) {
|
||||
return CompactUnwindMgr->processAndReserveUnwindInfo(G);
|
||||
});
|
||||
|
||||
// Translate compact-unwind to unwind-info.
|
||||
Config.PreFixupPasses.push_back([CompactUnwindMgr](LinkGraph &G) {
|
||||
return CompactUnwindMgr->writeUnwindInfo(G);
|
||||
});
|
||||
}
|
||||
|
||||
if (auto Err = Ctx->modifyPassConfig(*G, Config))
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "llvm/ExecutionEngine/JITLink/DWARFRecordSectionSplitter.h"
|
||||
#include "llvm/ExecutionEngine/JITLink/x86_64.h"
|
||||
|
||||
#include "CompactUnwindSupport.h"
|
||||
#include "DefineExternalSectionStartAndEndSymbols.h"
|
||||
#include "MachOLinkGraphBuilder.h"
|
||||
|
||||
@@ -500,26 +501,56 @@ Expected<std::unique_ptr<LinkGraph>> createLinkGraphFromMachOObject_x86_64(
|
||||
.buildGraph();
|
||||
}
|
||||
|
||||
struct CompactUnwindTraits_MachO_x86_64
|
||||
: public CompactUnwindTraits<CompactUnwindTraits_MachO_x86_64,
|
||||
/* PointerSize = */ 8> {
|
||||
// FIXME: Reinstate once we no longer need the MSVC workaround. See
|
||||
// FIXME for CompactUnwindTraits in CompactUnwindSupport.h.
|
||||
// constexpr static size_t PointerSize = 8;
|
||||
|
||||
constexpr static endianness Endianness = endianness::little;
|
||||
|
||||
constexpr static uint32_t EncodingModeMask = 0x0f000000;
|
||||
|
||||
using GOTManager = x86_64::GOTTableManager;
|
||||
|
||||
static bool encodingSpecifiesDWARF(uint32_t Encoding) {
|
||||
constexpr uint32_t DWARFMode = 0x04000000;
|
||||
return (Encoding & EncodingModeMask) == DWARFMode;
|
||||
}
|
||||
|
||||
static bool encodingCannotBeMerged(uint32_t Encoding) {
|
||||
constexpr uint32_t StackIndirectMode = 0x03000000;
|
||||
return (Encoding & EncodingModeMask) == StackIndirectMode;
|
||||
}
|
||||
};
|
||||
|
||||
void link_MachO_x86_64(std::unique_ptr<LinkGraph> G,
|
||||
std::unique_ptr<JITLinkContext> Ctx) {
|
||||
|
||||
PassConfiguration Config;
|
||||
|
||||
if (Ctx->shouldAddDefaultTargetPasses(G->getTargetTriple())) {
|
||||
// Add eh-frame passes.
|
||||
Config.PrePrunePasses.push_back(createEHFrameSplitterPass_MachO_x86_64());
|
||||
Config.PrePrunePasses.push_back(createEHFrameEdgeFixerPass_MachO_x86_64());
|
||||
|
||||
// Add compact unwind splitter pass.
|
||||
Config.PrePrunePasses.push_back(
|
||||
CompactUnwindSplitter("__LD,__compact_unwind"));
|
||||
|
||||
// Add a mark-live pass.
|
||||
if (auto MarkLive = Ctx->getMarkLivePass(G->getTargetTriple()))
|
||||
Config.PrePrunePasses.push_back(std::move(MarkLive));
|
||||
else
|
||||
Config.PrePrunePasses.push_back(markAllSymbolsLive);
|
||||
|
||||
// Add eh-frame passes.
|
||||
Config.PrePrunePasses.push_back(createEHFrameSplitterPass_MachO_x86_64());
|
||||
Config.PrePrunePasses.push_back(createEHFrameEdgeFixerPass_MachO_x86_64());
|
||||
|
||||
// Create a compact-unwind manager for use in passes below.
|
||||
auto CompactUnwindMgr = std::make_shared<
|
||||
CompactUnwindManager<CompactUnwindTraits_MachO_x86_64>>(
|
||||
"__LD,__compact_unwind", "__TEXT,__unwind_info", "__TEXT,__eh_frame");
|
||||
|
||||
// Add compact unwind prepare pass.
|
||||
Config.PrePrunePasses.push_back([CompactUnwindMgr](LinkGraph &G) {
|
||||
return CompactUnwindMgr->prepareForPrune(G);
|
||||
});
|
||||
|
||||
// Resolve any external section start / end symbols.
|
||||
Config.PostAllocationPasses.push_back(
|
||||
createDefineExternalSectionStartAndEndSymbolsPass(
|
||||
@@ -528,6 +559,16 @@ void link_MachO_x86_64(std::unique_ptr<LinkGraph> G,
|
||||
// Add an in-place GOT/Stubs pass.
|
||||
Config.PostPrunePasses.push_back(buildGOTAndStubs_MachO_x86_64);
|
||||
|
||||
// Reserve space for unwind-info.
|
||||
Config.PostPrunePasses.push_back([CompactUnwindMgr](LinkGraph &G) {
|
||||
return CompactUnwindMgr->processAndReserveUnwindInfo(G);
|
||||
});
|
||||
|
||||
// Translate compact-unwind to unwind-info.
|
||||
Config.PreFixupPasses.push_back([CompactUnwindMgr](LinkGraph &G) {
|
||||
return CompactUnwindMgr->writeUnwindInfo(G);
|
||||
});
|
||||
|
||||
// Add GOT/Stubs optimizer pass.
|
||||
Config.PreFixupPasses.push_back(x86_64::optimizeGOTAndStubAccesses);
|
||||
}
|
||||
|
||||
@@ -57,6 +57,7 @@ add_llvm_component_library(LLVMOrcJIT
|
||||
ExecutorProcessControl.cpp
|
||||
TaskDispatch.cpp
|
||||
ThreadSafeModule.cpp
|
||||
UnwindInfoRegistrationPlugin.cpp
|
||||
RedirectionManager.cpp
|
||||
JITLinkRedirectableSymbolManager.cpp
|
||||
ReOptimizeLayer.cpp
|
||||
|
||||
@@ -33,6 +33,9 @@ irManglingOptionsFromTargetOptions(const TargetOptions &Opts) {
|
||||
|
||||
/// Compile a Module to an ObjectFile.
|
||||
Expected<SimpleCompiler::CompileResult> SimpleCompiler::operator()(Module &M) {
|
||||
if (M.getDataLayout().isDefault())
|
||||
M.setDataLayout(TM.createDataLayout());
|
||||
|
||||
CompileResult CachedObject = tryToLoadFromObjectCache(M);
|
||||
if (CachedObject)
|
||||
return std::move(CachedObject);
|
||||
|
||||
@@ -1251,9 +1251,7 @@ JITDylib::JITDylib(ExecutionSession &ES, std::string Name)
|
||||
LinkOrder.push_back({this, JITDylibLookupFlags::MatchAllSymbols});
|
||||
}
|
||||
|
||||
std::pair<JITDylib::AsynchronousSymbolQuerySet,
|
||||
std::shared_ptr<SymbolDependenceMap>>
|
||||
JITDylib::IL_removeTracker(ResourceTracker &RT) {
|
||||
JITDylib::RemoveTrackerResult JITDylib::IL_removeTracker(ResourceTracker &RT) {
|
||||
// Note: Should be called under the session lock.
|
||||
assert(State != Closed && "JD is defunct");
|
||||
|
||||
@@ -1292,7 +1290,10 @@ JITDylib::IL_removeTracker(ResourceTracker &RT) {
|
||||
SymbolsToFail.push_back(Sym);
|
||||
}
|
||||
|
||||
auto Result = ES.IL_failSymbols(*this, std::move(SymbolsToFail));
|
||||
auto [QueriesToFail, FailedSymbols] =
|
||||
ES.IL_failSymbols(*this, std::move(SymbolsToFail));
|
||||
|
||||
std::vector<std::unique_ptr<MaterializationUnit>> DefunctMUs;
|
||||
|
||||
// Removed symbols should be taken out of the table altogether.
|
||||
for (auto &Sym : SymbolsToRemove) {
|
||||
@@ -1302,7 +1303,12 @@ JITDylib::IL_removeTracker(ResourceTracker &RT) {
|
||||
// Remove Materializer if present.
|
||||
if (I->second.hasMaterializerAttached()) {
|
||||
// FIXME: Should this discard the symbols?
|
||||
UnmaterializedInfos.erase(Sym);
|
||||
auto J = UnmaterializedInfos.find(Sym);
|
||||
assert(J != UnmaterializedInfos.end() &&
|
||||
"Symbol table indicates MU present, but no UMI record");
|
||||
if (J->second->MU)
|
||||
DefunctMUs.push_back(std::move(J->second->MU));
|
||||
UnmaterializedInfos.erase(J);
|
||||
} else {
|
||||
assert(!UnmaterializedInfos.count(Sym) &&
|
||||
"Symbol has materializer attached");
|
||||
@@ -1313,7 +1319,8 @@ JITDylib::IL_removeTracker(ResourceTracker &RT) {
|
||||
|
||||
shrinkMaterializationInfoMemory();
|
||||
|
||||
return Result;
|
||||
return {std::move(QueriesToFail), std::move(FailedSymbols),
|
||||
std::move(DefunctMUs)};
|
||||
}
|
||||
|
||||
void JITDylib::transferTracker(ResourceTracker &DstRT, ResourceTracker &SrcRT) {
|
||||
@@ -2180,16 +2187,17 @@ Error ExecutionSession::removeResourceTracker(ResourceTracker &RT) {
|
||||
});
|
||||
std::vector<ResourceManager *> CurrentResourceManagers;
|
||||
|
||||
JITDylib::AsynchronousSymbolQuerySet QueriesToFail;
|
||||
std::shared_ptr<SymbolDependenceMap> FailedSymbols;
|
||||
JITDylib::RemoveTrackerResult R;
|
||||
|
||||
runSessionLocked([&] {
|
||||
CurrentResourceManagers = ResourceManagers;
|
||||
RT.makeDefunct();
|
||||
std::tie(QueriesToFail, FailedSymbols) =
|
||||
RT.getJITDylib().IL_removeTracker(RT);
|
||||
R = RT.getJITDylib().IL_removeTracker(RT);
|
||||
});
|
||||
|
||||
// Release any defunct MaterializationUnits.
|
||||
R.DefunctMUs.clear();
|
||||
|
||||
Error Err = Error::success();
|
||||
|
||||
auto &JD = RT.getJITDylib();
|
||||
@@ -2197,9 +2205,9 @@ Error ExecutionSession::removeResourceTracker(ResourceTracker &RT) {
|
||||
Err = joinErrors(std::move(Err),
|
||||
L->handleRemoveResources(JD, RT.getKeyUnsafe()));
|
||||
|
||||
for (auto &Q : QueriesToFail)
|
||||
Q->handleFailed(
|
||||
make_error<FailedToMaterialize>(getSymbolStringPool(), FailedSymbols));
|
||||
for (auto &Q : R.QueriesToFail)
|
||||
Q->handleFailed(make_error<FailedToMaterialize>(getSymbolStringPool(),
|
||||
R.FailedSymbols));
|
||||
|
||||
return Err;
|
||||
}
|
||||
|
||||
@@ -45,6 +45,7 @@ SelfExecutorProcessControl::SelfExecutorProcessControl(
|
||||
this->DylibMgr = this;
|
||||
this->JDI = {ExecutorAddr::fromPtr(jitDispatchViaWrapperFunctionManager),
|
||||
ExecutorAddr::fromPtr(this)};
|
||||
|
||||
if (this->TargetTriple.isOSBinFormatMachO())
|
||||
GlobalManglingPrefix = '_';
|
||||
|
||||
@@ -52,6 +53,12 @@ SelfExecutorProcessControl::SelfExecutorProcessControl(
|
||||
ExecutorAddr::fromPtr(&llvm_orc_registerEHFrameSectionWrapper);
|
||||
this->BootstrapSymbols[rt::DeregisterEHFrameSectionWrapperName] =
|
||||
ExecutorAddr::fromPtr(&llvm_orc_deregisterEHFrameSectionWrapper);
|
||||
|
||||
#ifdef __APPLE__
|
||||
this->UnwindInfoMgr = UnwindInfoManager::TryCreate();
|
||||
if (this->UnwindInfoMgr)
|
||||
this->UnwindInfoMgr->addBootstrapSymbols(this->BootstrapSymbols);
|
||||
#endif // __APPLE__
|
||||
}
|
||||
|
||||
Expected<std::unique_ptr<SelfExecutorProcessControl>>
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "llvm/ExecutionEngine/Orc/ObjectTransformLayer.h"
|
||||
#include "llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h"
|
||||
#include "llvm/ExecutionEngine/Orc/TargetProcess/RegisterEHFrames.h"
|
||||
#include "llvm/ExecutionEngine/Orc/UnwindInfoRegistrationPlugin.h"
|
||||
#include "llvm/ExecutionEngine/SectionMemoryManager.h"
|
||||
#include "llvm/IR/GlobalVariable.h"
|
||||
#include "llvm/IR/IRBuilder.h"
|
||||
@@ -1220,12 +1221,28 @@ Expected<JITDylibSP> setUpGenericLLVMIRPlatform(LLJIT &J) {
|
||||
|
||||
if (auto *OLL = dyn_cast<ObjectLinkingLayer>(&J.getObjLinkingLayer())) {
|
||||
|
||||
auto &ES = J.getExecutionSession();
|
||||
if (auto EHFrameRegistrar = EPCEHFrameRegistrar::Create(ES))
|
||||
OLL->addPlugin(std::make_unique<EHFrameRegistrationPlugin>(
|
||||
ES, std::move(*EHFrameRegistrar)));
|
||||
else
|
||||
return EHFrameRegistrar.takeError();
|
||||
bool CompactUnwindInfoSupported = false;
|
||||
|
||||
// Enable compact-unwind support if possible.
|
||||
if (J.getTargetTriple().isOSDarwin() ||
|
||||
J.getTargetTriple().isOSBinFormatMachO()) {
|
||||
if (auto UIRP = UnwindInfoRegistrationPlugin::Create(
|
||||
J.getIRCompileLayer(), PlatformJD)) {
|
||||
CompactUnwindInfoSupported = true;
|
||||
OLL->addPlugin(std::move(*UIRP));
|
||||
} else
|
||||
consumeError(UIRP.takeError());
|
||||
}
|
||||
|
||||
// Otherwise fall back to standard unwind registration.
|
||||
if (!CompactUnwindInfoSupported) {
|
||||
auto &ES = J.getExecutionSession();
|
||||
if (auto EHFrameRegistrar = EPCEHFrameRegistrar::Create(ES))
|
||||
OLL->addPlugin(std::make_unique<EHFrameRegistrationPlugin>(
|
||||
ES, std::move(*EHFrameRegistrar)));
|
||||
else
|
||||
return EHFrameRegistrar.takeError();
|
||||
}
|
||||
}
|
||||
|
||||
J.setPlatformSupport(
|
||||
|
||||
@@ -64,5 +64,19 @@ const char *RunAsIntFunctionWrapperName =
|
||||
"__llvm_orc_bootstrap_run_as_int_function_wrapper";
|
||||
|
||||
} // end namespace rt
|
||||
namespace rt_alt {
|
||||
const char *UnwindInfoManagerInstanceName =
|
||||
"orc_rt_alt_UnwindInfoManager_Instance";
|
||||
const char *UnwindInfoManagerFindSectionsHelperName =
|
||||
"orc_rt_alt_UnwindInfoManager_findSectionsHelper";
|
||||
const char *UnwindInfoManagerEnableWrapperName =
|
||||
"orc_rt_alt_UnwindInfoManager_enable";
|
||||
const char *UnwindInfoManagerDisableWrapperName =
|
||||
"orc_rt_alt_UnwindInfoManager_disable";
|
||||
const char *UnwindInfoManagerRegisterActionName =
|
||||
"orc_rt_alt_UnwindInfoManager_register";
|
||||
const char *UnwindInfoManagerDeregisterActionName =
|
||||
"orc_rt_alt_UnwindInfoManager_deregister";
|
||||
} // end namespace rt_alt
|
||||
} // end namespace orc
|
||||
} // end namespace llvm
|
||||
|
||||
@@ -20,6 +20,7 @@ add_llvm_component_library(LLVMOrcTargetProcess
|
||||
SimpleExecutorMemoryManager.cpp
|
||||
SimpleRemoteEPCServer.cpp
|
||||
TargetExecutionUtils.cpp
|
||||
UnwindInfoManager.cpp
|
||||
|
||||
ADDITIONAL_HEADER_DIRS
|
||||
${LLVM_MAIN_INCLUDE_DIR}/llvm/ExecutionEngine/Orc
|
||||
|
||||
Reference in New Issue
Block a user