| OLD | NEW |
| 1 //===- subzero/src/IceTimerTree.cpp - Pass timer defs ---------------------===// | 1 //===- subzero/src/IceTimerTree.cpp - Pass timer defs ---------------------===// |
| 2 // | 2 // |
| 3 // The Subzero Code Generator | 3 // The Subzero Code Generator |
| 4 // | 4 // |
| 5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
| 6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
| 7 // | 7 // |
| 8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
| 9 /// | 9 /// |
| 10 /// \file | 10 /// \file |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 CurIndex = getChildIndex(CurIndex, Index); | 135 CurIndex = getChildIndex(CurIndex, Index); |
| 136 } | 136 } |
| 137 assert(CurIndex); // shouldn't be the sentinel node | 137 assert(CurIndex); // shouldn't be the sentinel node |
| 138 return CurIndex; | 138 return CurIndex; |
| 139 } | 139 } |
| 140 | 140 |
| 141 // Pushes a new marker onto the timer stack. | 141 // Pushes a new marker onto the timer stack. |
| 142 void TimerStack::push(TimerIdT ID) { | 142 void TimerStack::push(TimerIdT ID) { |
| 143 if (!BuildDefs::dump()) | 143 if (!BuildDefs::dump()) |
| 144 return; | 144 return; |
| 145 const bool UpdateCounts = false; | 145 constexpr bool UpdateCounts = false; |
| 146 update(UpdateCounts); | 146 update(UpdateCounts); |
| 147 StackTop = getChildIndex(StackTop, ID); | 147 StackTop = getChildIndex(StackTop, ID); |
| 148 assert(StackTop); | 148 assert(StackTop); |
| 149 } | 149 } |
| 150 | 150 |
| 151 // Pops the top marker from the timer stack. Validates via assert() that the | 151 // Pops the top marker from the timer stack. Validates via assert() that the |
| 152 // expected marker is popped. | 152 // expected marker is popped. |
| 153 void TimerStack::pop(TimerIdT ID) { | 153 void TimerStack::pop(TimerIdT ID) { |
| 154 if (!BuildDefs::dump()) | 154 if (!BuildDefs::dump()) |
| 155 return; | 155 return; |
| 156 const bool UpdateCounts = true; | 156 constexpr bool UpdateCounts = true; |
| 157 update(UpdateCounts); | 157 update(UpdateCounts); |
| 158 assert(StackTop); | 158 assert(StackTop); |
| 159 assert(Nodes[StackTop].Parent < StackTop); | 159 assert(Nodes[StackTop].Parent < StackTop); |
| 160 // Verify that the expected ID is being popped. | 160 // Verify that the expected ID is being popped. |
| 161 assert(Nodes[StackTop].Interior == ID); | 161 assert(Nodes[StackTop].Interior == ID); |
| 162 (void)ID; | 162 (void)ID; |
| 163 // Verify that the parent's child points to the current stack top. | 163 // Verify that the parent's child points to the current stack top. |
| 164 assert(Nodes[Nodes[StackTop].Parent].Children[ID] == StackTop); | 164 assert(Nodes[Nodes[StackTop].Parent].Children[ID] == StackTop); |
| 165 StackTop = Nodes[StackTop].Parent; | 165 StackTop = Nodes[StackTop].Parent; |
| 166 } | 166 } |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 MaxVal /= 10; | 246 MaxVal /= 10; |
| 247 } while (MaxVal); | 247 } while (MaxVal); |
| 248 snprintf(Buf, BufLen, "[%%%dlu] ", NumDigits); | 248 snprintf(Buf, BufLen, "[%%%dlu] ", NumDigits); |
| 249 } | 249 } |
| 250 | 250 |
| 251 } // end of anonymous namespace | 251 } // end of anonymous namespace |
| 252 | 252 |
| 253 void TimerStack::dump(Ostream &Str, bool DumpCumulative) { | 253 void TimerStack::dump(Ostream &Str, bool DumpCumulative) { |
| 254 if (!BuildDefs::dump()) | 254 if (!BuildDefs::dump()) |
| 255 return; | 255 return; |
| 256 const bool UpdateCounts = true; | 256 constexpr bool UpdateCounts = true; |
| 257 update(UpdateCounts); | 257 update(UpdateCounts); |
| 258 double TotalTime = LastTimestamp - FirstTimestamp; | 258 double TotalTime = LastTimestamp - FirstTimestamp; |
| 259 assert(TotalTime); | 259 assert(TotalTime); |
| 260 char FmtString[30], PrefixStr[30]; | 260 char FmtString[30], PrefixStr[30]; |
| 261 if (DumpCumulative) { | 261 if (DumpCumulative) { |
| 262 Str << Name << " - Cumulative times:\n"; | 262 Str << Name << " - Cumulative times:\n"; |
| 263 size_t MaxInternalCount = 0; | 263 size_t MaxInternalCount = 0; |
| 264 for (TimerTreeNode &Node : Nodes) | 264 for (TimerTreeNode &Node : Nodes) |
| 265 MaxInternalCount = std::max(MaxInternalCount, Node.UpdateCount); | 265 MaxInternalCount = std::max(MaxInternalCount, Node.UpdateCount); |
| 266 makePrintfFormatString(FmtString, llvm::array_lengthof(FmtString), | 266 makePrintfFormatString(FmtString, llvm::array_lengthof(FmtString), |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 dumpHelper(Str, FlatMap, TotalTime); | 301 dumpHelper(Str, FlatMap, TotalTime); |
| 302 Str << "Number of timer updates: " << StateChangeCount << "\n"; | 302 Str << "Number of timer updates: " << StateChangeCount << "\n"; |
| 303 } | 303 } |
| 304 | 304 |
| 305 double TimerStack::timestamp() { | 305 double TimerStack::timestamp() { |
| 306 // TODO: Implement in terms of std::chrono for C++11. | 306 // TODO: Implement in terms of std::chrono for C++11. |
| 307 return llvm::TimeRecord::getCurrentTime(false).getWallTime(); | 307 return llvm::TimeRecord::getCurrentTime(false).getWallTime(); |
| 308 } | 308 } |
| 309 | 309 |
| 310 } // end of namespace Ice | 310 } // end of namespace Ice |
| OLD | NEW |