-TimingInfo *TimingInfo::create() {
- return EnableTiming ? new TimingInfo() : 0;
-}
-
-void TimingInfo::passStarted(Pass *P) {
- TimingData[P].passStart(getTimeRecord());
-}
-void TimingInfo::passEnded(Pass *P) {
- TimingData[P].passEnd(getTimeRecord());
-}
-void TimeRecord::sum(const TimeRecord &TR) {
- Elapsed += TR.Elapsed;
- UserTime += TR.UserTime;
- SystemTime += TR.SystemTime;
- MaxRSS += TR.MaxRSS;
-}
-
-// TimingDtor - Print out information about timing information
-TimingInfo::~TimingInfo() {
- // Iterate over all of the data, converting it into the dual of the data map,
- // so that the data is sorted by amount of time taken, instead of pointer.
- //
- std::vector<std::pair<TimeRecord, Pass*> > Data;
- TimeRecord Total;
- for (std::map<Pass*, TimeRecord>::iterator I = TimingData.begin(),
- E = TimingData.end(); I != E; ++I)
- // Throw out results for "grouping" pass managers...
- if (!dynamic_cast<AnalysisResolver*>(I->first)) {
- Data.push_back(std::make_pair(I->second, I->first));
- Total.sum(I->second);
- }
-
- // Sort the data by time as the primary key, in reverse order...
- std::sort(Data.begin(), Data.end(),
- std::greater<std::pair<TimeRecord, Pass*> >());
-
- // Print out timing header...
- std::cerr << std::string(79, '=') << "\n"
- << " ... Pass execution timing report ...\n"
- << std::string(79, '=') << "\n Total Execution Time: "
- << (Total.UserTime+Total.SystemTime) << " seconds ("
- << Total.Elapsed << " wall clock)\n\n ---User Time--- "
- << "--System Time-- --User+System-- ---Wall Time---";
-
- if (Total.MaxRSS)
- std::cerr << " ---Mem---";
- std::cerr << " --- Pass Name ---\n";
+bool llvm::TimePassesIsEnabled = false;
+static cl::opt<bool,true>
+EnableTiming("time-passes", cl::location(TimePassesIsEnabled),
+ cl::desc("Time each pass, printing elapsed time for each on exit"));