forked from OSchip/llvm-project
[JITLink] Fix the show-timers option on llvm-jitlink.
No longer constantly shows times (even when -show-times=false). When shown, times are now correctly grouped. llvm-svn: 370951
This commit is contained in:
parent
e4526330b3
commit
200415c6dc
|
@ -609,6 +609,15 @@ Expected<int> runEntryPoint(Session &S, JITEvaluatedSymbol EntryPoint) {
|
||||||
return EntryPointPtr(EntryPointArgs.size() - 1, EntryPointArgs.data());
|
return EntryPointPtr(EntryPointArgs.size() - 1, EntryPointArgs.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct JITLinkTimers {
|
||||||
|
TimerGroup JITLinkTimers{"llvm-jitlink timers",
|
||||||
|
"timers for llvm-jitlink phases"};
|
||||||
|
Timer LoadObjectsTimer{
|
||||||
|
"load", "time to load/add object files to llvm-jitlink", JITLinkTimers};
|
||||||
|
Timer LinkTimer{"link", "time to link object files", JITLinkTimers};
|
||||||
|
Timer RunTimer{"run", "time to execute jitlink'd code", JITLinkTimers};
|
||||||
|
};
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
InitLLVM X(argc, argv);
|
InitLLVM X(argc, argv);
|
||||||
|
|
||||||
|
@ -619,6 +628,10 @@ int main(int argc, char *argv[]) {
|
||||||
cl::ParseCommandLineOptions(argc, argv, "llvm jitlink tool");
|
cl::ParseCommandLineOptions(argc, argv, "llvm jitlink tool");
|
||||||
ExitOnErr.setBanner(std::string(argv[0]) + ": ");
|
ExitOnErr.setBanner(std::string(argv[0]) + ": ");
|
||||||
|
|
||||||
|
/// If timers are enabled, create a JITLinkTimers instance.
|
||||||
|
std::unique_ptr<JITLinkTimers> Timers =
|
||||||
|
ShowTimes ? std::make_unique<JITLinkTimers>() : nullptr;
|
||||||
|
|
||||||
Session S(getFirstFileTriple());
|
Session S(getFirstFileTriple());
|
||||||
|
|
||||||
ExitOnErr(sanitizeArguments(S));
|
ExitOnErr(sanitizeArguments(S));
|
||||||
|
@ -627,23 +640,16 @@ int main(int argc, char *argv[]) {
|
||||||
ExitOnErr(loadProcessSymbols(S));
|
ExitOnErr(loadProcessSymbols(S));
|
||||||
ExitOnErr(loadDylibs());
|
ExitOnErr(loadDylibs());
|
||||||
|
|
||||||
TimerGroup JITLinkTimers("llvm-jitlink timers",
|
|
||||||
"timers for llvm-jitlink phases");
|
|
||||||
|
|
||||||
{
|
{
|
||||||
Timer LoadObjectsTimer(
|
TimeRegion TR(Timers ? &Timers->LoadObjectsTimer : nullptr);
|
||||||
"load", "time to load/add object files to llvm-jitlink", JITLinkTimers);
|
|
||||||
LoadObjectsTimer.startTimer();
|
|
||||||
ExitOnErr(loadObjects(S));
|
ExitOnErr(loadObjects(S));
|
||||||
LoadObjectsTimer.stopTimer();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JITEvaluatedSymbol EntryPoint = 0;
|
JITEvaluatedSymbol EntryPoint = 0;
|
||||||
{
|
{
|
||||||
Timer LinkTimer("link", "time to link object files", JITLinkTimers);
|
TimeRegion TR(Timers ? &Timers->LinkTimer : nullptr);
|
||||||
LinkTimer.startTimer();
|
|
||||||
EntryPoint = ExitOnErr(getMainEntryPoint(S));
|
EntryPoint = ExitOnErr(getMainEntryPoint(S));
|
||||||
LinkTimer.stopTimer();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ShowAddrs)
|
if (ShowAddrs)
|
||||||
|
@ -658,14 +664,9 @@ int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
int Result = 0;
|
int Result = 0;
|
||||||
{
|
{
|
||||||
Timer RunTimer("run", "time to execute jitlink'd code", JITLinkTimers);
|
TimeRegion TR(Timers ? &Timers->RunTimer : nullptr);
|
||||||
RunTimer.startTimer();
|
|
||||||
Result = ExitOnErr(runEntryPoint(S, EntryPoint));
|
Result = ExitOnErr(runEntryPoint(S, EntryPoint));
|
||||||
RunTimer.stopTimer();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ShowTimes)
|
|
||||||
JITLinkTimers.print(dbgs());
|
|
||||||
|
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue