Skip to content

Commit 6fd3960

Browse files
committedAug 27, 2019
[JITLink] Add timers and -show-times option to llvm-jitlink.
The timers track time spent loading objects, linking, and (if applicable) running JIT-link'd code. llvm-svn: 370075
1 parent c48f1f6 commit 6fd3960

File tree

1 file changed

+35
-3
lines changed

1 file changed

+35
-3
lines changed
 

‎llvm/tools/llvm-jitlink/llvm-jitlink.cpp

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include "llvm/Support/MemoryBuffer.h"
3434
#include "llvm/Support/TargetRegistry.h"
3535
#include "llvm/Support/TargetSelect.h"
36+
#include "llvm/Support/Timer.h"
3637

3738
#include <list>
3839
#include <string>
@@ -94,6 +95,10 @@ static cl::opt<bool> ShowSizes(
9495
cl::desc("Show sizes pre- and post-dead stripping, and allocations"),
9596
cl::init(false));
9697

98+
static cl::opt<bool> ShowTimes("show-times",
99+
cl::desc("Show times for llvm-jitlink phases"),
100+
cl::init(false));
101+
97102
static cl::opt<bool> ShowRelocatedSectionContents(
98103
"show-relocated-section-contents",
99104
cl::desc("show section contents after fixups have been applied"),
@@ -622,9 +627,25 @@ int main(int argc, char *argv[]) {
622627
ExitOnErr(loadProcessSymbols(S));
623628
ExitOnErr(loadDylibs());
624629

625-
ExitOnErr(loadObjects(S));
630+
TimerGroup JITLinkTimers;
631+
// ("llvm-jitlink timers",
632+
// "timers for llvm-jitlink phases");
626633

627-
auto EntryPoint = ExitOnErr(getMainEntryPoint(S));
634+
{
635+
Timer LoadObjectsTimer(
636+
"load", "time to load/add object files to llvm-jitlink", JITLinkTimers);
637+
LoadObjectsTimer.startTimer();
638+
ExitOnErr(loadObjects(S));
639+
LoadObjectsTimer.stopTimer();
640+
}
641+
642+
JITEvaluatedSymbol EntryPoint = 0;
643+
{
644+
Timer LinkTimer("link", "time to link object files", JITLinkTimers);
645+
LinkTimer.startTimer();
646+
EntryPoint = ExitOnErr(getMainEntryPoint(S));
647+
LinkTimer.stopTimer();
648+
}
628649

629650
if (ShowAddrs)
630651
S.dumpSessionInfo(outs());
@@ -636,5 +657,16 @@ int main(int argc, char *argv[]) {
636657
if (NoExec)
637658
return 0;
638659

639-
return ExitOnErr(runEntryPoint(S, EntryPoint));
660+
int Result = 0;
661+
{
662+
Timer RunTimer("run", "time to execute jitlink'd code", JITLinkTimers);
663+
RunTimer.startTimer();
664+
Result = ExitOnErr(runEntryPoint(S, EntryPoint));
665+
RunTimer.stopTimer();
666+
}
667+
668+
if (ShowTimes)
669+
JITLinkTimers.print(dbgs());
670+
671+
return Result;
640672
}

0 commit comments

Comments
 (0)
Please sign in to comment.