summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-08-19 15:43:33 +0000
committerChris Lattner <sabre@nondot.org>2002-08-19 15:43:33 +0000
commit5ec216b5feba44f67e19fba27c4cf2b051f8bfde (patch)
tree67127b08912d65e9d91f66931ac78c703ddbef87 /llvm/lib
parent8f3acc6fde259b7b0613d8a8eaeaaf8fe99fd191 (diff)
downloadbcm5719-llvm-5ec216b5feba44f67e19fba27c4cf2b051f8bfde.tar.gz
bcm5719-llvm-5ec216b5feba44f67e19fba27c4cf2b051f8bfde.zip
Fix the -time-passes option to not print NaN when there is zero execution time
llvm-svn: 3382
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/VMCore/Pass.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/llvm/lib/VMCore/Pass.cpp b/llvm/lib/VMCore/Pass.cpp
index 106d70b31aa..28244518df7 100644
--- a/llvm/lib/VMCore/Pass.cpp
+++ b/llvm/lib/VMCore/Pass.cpp
@@ -122,13 +122,20 @@ void TimeRecord::passEnd(const TimeRecord &T) {
MaxRSS = std::max(MaxRSS, RSSTemp);
}
+static void printVal(double Val, double Total) {
+ if (Total < 1e-7) // Avoid dividing by zero...
+ fprintf(stderr, " ----- ");
+ else
+ fprintf(stderr, " %7.4f (%5.1f%%)", Val, Val*100/Total);
+}
+
void TimeRecord::print(const char *PassName, const TimeRecord &Total) const {
- fprintf(stderr,
- " %7.4f (%5.1f%%) %7.4f (%5.1f%%) %7.4f (%5.1f%%) %7.4f (%5.1f%%) ",
- UserTime , UserTime *100/Total.UserTime,
- SystemTime, SystemTime*100/Total.SystemTime,
- UserTime+SystemTime, (UserTime+SystemTime)*100/(Total.UserTime+Total.SystemTime),
- Elapsed , Elapsed *100/Total.Elapsed);
+ printVal(UserTime, Total.UserTime);
+ printVal(SystemTime, Total.SystemTime);
+ printVal(UserTime+SystemTime, Total.UserTime+Total.SystemTime);
+ printVal(Elapsed, Total.Elapsed);
+
+ fprintf(stderr, " ");
if (Total.MaxRSS)
std::cerr << MaxRSS << "\t";
OpenPOWER on IntegriCloud