forked from OSchip/llvm-project
[llvm-jitlink] Print session report even if entry-point lookup errors out.
This commit is contained in:
parent
4c1b65e7bc
commit
e8e7581fb1
|
@ -1941,6 +1941,36 @@ static Expected<JITEvaluatedSymbol> getOrcRuntimeEntryPoint(Session &S) {
|
|||
return S.ES.lookup(S.JDSearchOrder, S.ES.intern(RuntimeEntryPoint));
|
||||
}
|
||||
|
||||
static Expected<JITEvaluatedSymbol> getEntryPoint(Session &S) {
|
||||
JITEvaluatedSymbol EntryPoint;
|
||||
|
||||
// Find the entry-point function unconditionally, since we want to force
|
||||
// it to be materialized to collect stats.
|
||||
if (auto EP = getMainEntryPoint(S))
|
||||
EntryPoint = *EP;
|
||||
else
|
||||
return EP.takeError();
|
||||
LLVM_DEBUG({
|
||||
dbgs() << "Using entry point \"" << EntryPointName
|
||||
<< "\": " << formatv("{0:x16}", EntryPoint.getAddress()) << "\n";
|
||||
});
|
||||
|
||||
// If we're running with the ORC runtime then replace the entry-point
|
||||
// with the __orc_rt_run_program symbol.
|
||||
if (!OrcRuntime.empty()) {
|
||||
if (auto EP = getOrcRuntimeEntryPoint(S))
|
||||
EntryPoint = *EP;
|
||||
else
|
||||
return EP.takeError();
|
||||
LLVM_DEBUG({
|
||||
dbgs() << "(called via __orc_rt_run_program_wrapper at "
|
||||
<< formatv("{0:x16}", EntryPoint.getAddress()) << ")\n";
|
||||
});
|
||||
}
|
||||
|
||||
return EntryPoint;
|
||||
}
|
||||
|
||||
static Expected<int> runWithRuntime(Session &S, ExecutorAddr EntryPointAddr) {
|
||||
StringRef DemangledEntryPoint = EntryPointName;
|
||||
const auto &TT = S.ES.getExecutorProcessControl().getTargetTriple();
|
||||
|
@ -2002,48 +2032,31 @@ int main(int argc, char *argv[]) {
|
|||
if (ShowInitialExecutionSessionState)
|
||||
S->ES.dump(outs());
|
||||
|
||||
JITEvaluatedSymbol EntryPoint = nullptr;
|
||||
Expected<JITEvaluatedSymbol> EntryPoint(nullptr);
|
||||
{
|
||||
ExpectedAsOutParameter<JITEvaluatedSymbol> _(&EntryPoint);
|
||||
TimeRegion TR(Timers ? &Timers->LinkTimer : nullptr);
|
||||
// Find the entry-point function unconditionally, since we want to force
|
||||
// it to be materialized to collect stats.
|
||||
if (auto EP = getMainEntryPoint(*S))
|
||||
EntryPoint = *EP;
|
||||
else {
|
||||
reportLLVMJITLinkError(EP.takeError());
|
||||
exit(1);
|
||||
}
|
||||
LLVM_DEBUG({
|
||||
dbgs() << "Using entry point \"" << EntryPointName
|
||||
<< "\": " << formatv("{0:x16}", EntryPoint.getAddress()) << "\n";
|
||||
});
|
||||
|
||||
// If we're running with the ORC runtime then replace the entry-point
|
||||
// with the __orc_rt_run_program symbol.
|
||||
if (!OrcRuntime.empty()) {
|
||||
if (auto EP = getOrcRuntimeEntryPoint(*S))
|
||||
EntryPoint = *EP;
|
||||
else {
|
||||
reportLLVMJITLinkError(EP.takeError());
|
||||
exit(1);
|
||||
}
|
||||
LLVM_DEBUG({
|
||||
dbgs() << "(called via __orc_rt_run_program_wrapper at "
|
||||
<< formatv("{0:x16}", EntryPoint.getAddress()) << ")\n";
|
||||
});
|
||||
}
|
||||
EntryPoint = getEntryPoint(*S);
|
||||
}
|
||||
|
||||
// Print any reports regardless of whether we succeeded or failed.
|
||||
if (ShowEntryExecutionSessionState)
|
||||
S->ES.dump(outs());
|
||||
|
||||
if (ShowAddrs)
|
||||
S->dumpSessionInfo(outs());
|
||||
|
||||
ExitOnErr(runChecks(*S));
|
||||
|
||||
dumpSessionStats(*S);
|
||||
|
||||
if (!EntryPoint) {
|
||||
if (Timers)
|
||||
Timers->JITLinkTG.printAll(errs());
|
||||
reportLLVMJITLinkError(EntryPoint.takeError());
|
||||
exit(1);
|
||||
}
|
||||
|
||||
ExitOnErr(runChecks(*S));
|
||||
|
||||
if (NoExec)
|
||||
return 0;
|
||||
|
||||
|
@ -2053,16 +2066,19 @@ int main(int argc, char *argv[]) {
|
|||
TimeRegion TR(Timers ? &Timers->RunTimer : nullptr);
|
||||
if (!OrcRuntime.empty())
|
||||
Result =
|
||||
ExitOnErr(runWithRuntime(*S, ExecutorAddr(EntryPoint.getAddress())));
|
||||
ExitOnErr(runWithRuntime(*S, ExecutorAddr(EntryPoint->getAddress())));
|
||||
else
|
||||
Result = ExitOnErr(
|
||||
runWithoutRuntime(*S, ExecutorAddr(EntryPoint.getAddress())));
|
||||
runWithoutRuntime(*S, ExecutorAddr(EntryPoint->getAddress())));
|
||||
}
|
||||
|
||||
// Destroy the session.
|
||||
ExitOnErr(S->ES.endSession());
|
||||
S.reset();
|
||||
|
||||
if (Timers)
|
||||
Timers->JITLinkTG.printAll(errs());
|
||||
|
||||
// If the executing code set a test result override then use that.
|
||||
if (UseTestResultOverride)
|
||||
Result = TestResultOverride;
|
||||
|
|
Loading…
Reference in New Issue