[llvm] r370951 - [JITLink] Fix the show-timers option on llvm-jitlink.
Lang Hames via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 4 11:38:29 PDT 2019
Author: lhames
Date: Wed Sep 4 11:38:29 2019
New Revision: 370951
URL: http://llvm.org/viewvc/llvm-project?rev=370951&view=rev
Log:
[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.
Modified:
llvm/trunk/tools/llvm-jitlink/llvm-jitlink.cpp
Modified: llvm/trunk/tools/llvm-jitlink/llvm-jitlink.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-jitlink/llvm-jitlink.cpp?rev=370951&r1=370950&r2=370951&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-jitlink/llvm-jitlink.cpp (original)
+++ llvm/trunk/tools/llvm-jitlink/llvm-jitlink.cpp Wed Sep 4 11:38:29 2019
@@ -609,6 +609,15 @@ Expected<int> runEntryPoint(Session &S,
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[]) {
InitLLVM X(argc, argv);
@@ -619,6 +628,10 @@ int main(int argc, char *argv[]) {
cl::ParseCommandLineOptions(argc, argv, "llvm jitlink tool");
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());
ExitOnErr(sanitizeArguments(S));
@@ -627,23 +640,16 @@ int main(int argc, char *argv[]) {
ExitOnErr(loadProcessSymbols(S));
ExitOnErr(loadDylibs());
- TimerGroup JITLinkTimers("llvm-jitlink timers",
- "timers for llvm-jitlink phases");
{
- Timer LoadObjectsTimer(
- "load", "time to load/add object files to llvm-jitlink", JITLinkTimers);
- LoadObjectsTimer.startTimer();
+ TimeRegion TR(Timers ? &Timers->LoadObjectsTimer : nullptr);
ExitOnErr(loadObjects(S));
- LoadObjectsTimer.stopTimer();
}
JITEvaluatedSymbol EntryPoint = 0;
{
- Timer LinkTimer("link", "time to link object files", JITLinkTimers);
- LinkTimer.startTimer();
+ TimeRegion TR(Timers ? &Timers->LinkTimer : nullptr);
EntryPoint = ExitOnErr(getMainEntryPoint(S));
- LinkTimer.stopTimer();
}
if (ShowAddrs)
@@ -658,14 +664,9 @@ int main(int argc, char *argv[]) {
int Result = 0;
{
- Timer RunTimer("run", "time to execute jitlink'd code", JITLinkTimers);
- RunTimer.startTimer();
+ TimeRegion TR(Timers ? &Timers->RunTimer : nullptr);
Result = ExitOnErr(runEntryPoint(S, EntryPoint));
- RunTimer.stopTimer();
}
- if (ShowTimes)
- JITLinkTimers.print(dbgs());
-
return Result;
}
More information about the llvm-commits
mailing list