33
33
#include " llvm/Support/MemoryBuffer.h"
34
34
#include " llvm/Support/TargetRegistry.h"
35
35
#include " llvm/Support/TargetSelect.h"
36
+ #include " llvm/Support/Timer.h"
36
37
37
38
#include < list>
38
39
#include < string>
@@ -94,6 +95,10 @@ static cl::opt<bool> ShowSizes(
94
95
cl::desc (" Show sizes pre- and post-dead stripping, and allocations" ),
95
96
cl::init(false ));
96
97
98
+ static cl::opt<bool > ShowTimes (" show-times" ,
99
+ cl::desc (" Show times for llvm-jitlink phases" ),
100
+ cl::init(false ));
101
+
97
102
static cl::opt<bool > ShowRelocatedSectionContents (
98
103
" show-relocated-section-contents" ,
99
104
cl::desc (" show section contents after fixups have been applied" ),
@@ -622,9 +627,25 @@ int main(int argc, char *argv[]) {
622
627
ExitOnErr (loadProcessSymbols (S));
623
628
ExitOnErr (loadDylibs ());
624
629
625
- ExitOnErr (loadObjects (S));
630
+ TimerGroup JITLinkTimers;
631
+ // ("llvm-jitlink timers",
632
+ // "timers for llvm-jitlink phases");
626
633
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
+ }
628
649
629
650
if (ShowAddrs)
630
651
S.dumpSessionInfo (outs ());
@@ -636,5 +657,16 @@ int main(int argc, char *argv[]) {
636
657
if (NoExec)
637
658
return 0 ;
638
659
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;
640
672
}
0 commit comments