OLD | NEW |
1 //===- subzero/src/IceGlobalContext.cpp - Global context defs -------------===// | 1 //===- subzero/src/IceGlobalContext.cpp - Global context 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 // This file defines aspects of the compilation that persist across | 10 // This file defines aspects of the compilation that persist across |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 | 107 |
108 GlobalContext::GlobalContext(Ostream *OsDump, Ostream *OsEmit, | 108 GlobalContext::GlobalContext(Ostream *OsDump, Ostream *OsEmit, |
109 ELFStreamer *ELFStr, VerboseMask Mask, | 109 ELFStreamer *ELFStr, VerboseMask Mask, |
110 TargetArch Arch, OptLevel Opt, | 110 TargetArch Arch, OptLevel Opt, |
111 IceString TestPrefix, const ClFlags &Flags) | 111 IceString TestPrefix, const ClFlags &Flags) |
112 : StrDump(OsDump), StrEmit(OsEmit), VMask(Mask), | 112 : StrDump(OsDump), StrEmit(OsEmit), VMask(Mask), |
113 ConstPool(new ConstantPool()), Arch(Arch), Opt(Opt), | 113 ConstPool(new ConstantPool()), Arch(Arch), Opt(Opt), |
114 TestPrefix(TestPrefix), Flags(Flags), HasEmittedFirstMethod(false), | 114 TestPrefix(TestPrefix), Flags(Flags), HasEmittedFirstMethod(false), |
115 RNG(""), ObjectWriter() { | 115 RNG(""), ObjectWriter() { |
116 // Pre-register built-in stack names. | 116 // Pre-register built-in stack names. |
117 newTimerStackID("Total across all functions"); | 117 if (ALLOW_DUMP) { |
118 newTimerStackID("Per-function summary"); | 118 newTimerStackID("Total across all functions"); |
| 119 newTimerStackID("Per-function summary"); |
| 120 } |
119 if (Flags.UseELFWriter) { | 121 if (Flags.UseELFWriter) { |
120 ObjectWriter.reset(new ELFObjectWriter(*this, *ELFStr)); | 122 ObjectWriter.reset(new ELFObjectWriter(*this, *ELFStr)); |
121 } | 123 } |
122 } | 124 } |
123 | 125 |
124 // Scan a string for S[0-9A-Z]*_ patterns and replace them with | 126 // Scan a string for S[0-9A-Z]*_ patterns and replace them with |
125 // S<num>_ where <num> is the next base-36 value. If a type name | 127 // S<num>_ where <num> is the next base-36 value. If a type name |
126 // legitimately contains that pattern, then the substitution will be | 128 // legitimately contains that pattern, then the substitution will be |
127 // made in error and most likely the link will fail. In this case, | 129 // made in error and most likely the link will fail. In this case, |
128 // the test classes can be rewritten not to use that pattern, which is | 130 // the test classes can be rewritten not to use that pattern, which is |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 // prefix. | 216 // prefix. |
215 IceString GlobalContext::mangleName(const IceString &Name) const { | 217 IceString GlobalContext::mangleName(const IceString &Name) const { |
216 // An already-nested name like foo::bar() gets pushed down one | 218 // An already-nested name like foo::bar() gets pushed down one |
217 // level, making it equivalent to Prefix::foo::bar(). | 219 // level, making it equivalent to Prefix::foo::bar(). |
218 // _ZN3foo3barExyz ==> _ZN6Prefix3foo3barExyz | 220 // _ZN3foo3barExyz ==> _ZN6Prefix3foo3barExyz |
219 // A non-nested but mangled name like bar() gets nested, making it | 221 // A non-nested but mangled name like bar() gets nested, making it |
220 // equivalent to Prefix::bar(). | 222 // equivalent to Prefix::bar(). |
221 // _Z3barxyz ==> ZN6Prefix3barExyz | 223 // _Z3barxyz ==> ZN6Prefix3barExyz |
222 // An unmangled, extern "C" style name, gets a simple prefix: | 224 // An unmangled, extern "C" style name, gets a simple prefix: |
223 // bar ==> Prefixbar | 225 // bar ==> Prefixbar |
224 if (getTestPrefix().empty()) | 226 if (!ALLOW_DUMP || getTestPrefix().empty()) |
225 return Name; | 227 return Name; |
226 | 228 |
227 unsigned PrefixLength = getTestPrefix().length(); | 229 unsigned PrefixLength = getTestPrefix().length(); |
228 ManglerVector NameBase(1 + Name.length()); | 230 ManglerVector NameBase(1 + Name.length()); |
229 const size_t BufLen = 30 + Name.length() + PrefixLength; | 231 const size_t BufLen = 30 + Name.length() + PrefixLength; |
230 ManglerVector NewName(BufLen); | 232 ManglerVector NewName(BufLen); |
231 uint32_t BaseLength = 0; // using uint32_t due to sscanf format string | 233 uint32_t BaseLength = 0; // using uint32_t due to sscanf format string |
232 | 234 |
233 int ItemsParsed = sscanf(Name.c_str(), "_ZN%s", NameBase.data()); | 235 int ItemsParsed = sscanf(Name.c_str(), "_ZN%s", NameBase.data()); |
234 if (ItemsParsed == 1) { | 236 if (ItemsParsed == 1) { |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 return Var; | 433 return Var; |
432 } | 434 } |
433 | 435 |
434 TimerIdT GlobalContext::getTimerID(TimerStackIdT StackID, | 436 TimerIdT GlobalContext::getTimerID(TimerStackIdT StackID, |
435 const IceString &Name) { | 437 const IceString &Name) { |
436 assert(StackID < Timers.size()); | 438 assert(StackID < Timers.size()); |
437 return Timers[StackID].getTimerID(Name); | 439 return Timers[StackID].getTimerID(Name); |
438 } | 440 } |
439 | 441 |
440 TimerStackIdT GlobalContext::newTimerStackID(const IceString &Name) { | 442 TimerStackIdT GlobalContext::newTimerStackID(const IceString &Name) { |
| 443 if (!ALLOW_DUMP) |
| 444 return 0; |
441 TimerStackIdT NewID = Timers.size(); | 445 TimerStackIdT NewID = Timers.size(); |
442 Timers.push_back(TimerStack(Name)); | 446 Timers.push_back(TimerStack(Name)); |
443 return NewID; | 447 return NewID; |
444 } | 448 } |
445 | 449 |
446 void GlobalContext::pushTimer(TimerIdT ID, TimerStackIdT StackID) { | 450 void GlobalContext::pushTimer(TimerIdT ID, TimerStackIdT StackID) { |
447 assert(StackID < Timers.size()); | 451 assert(StackID < Timers.size()); |
448 Timers[StackID].push(ID); | 452 Timers[StackID].push(ID); |
449 } | 453 } |
450 | 454 |
(...skipping 27 matching lines...) Expand all Loading... |
478 } | 482 } |
479 | 483 |
480 void GlobalContext::dumpTimers(TimerStackIdT StackID, bool DumpCumulative) { | 484 void GlobalContext::dumpTimers(TimerStackIdT StackID, bool DumpCumulative) { |
481 if (!ALLOW_DUMP) | 485 if (!ALLOW_DUMP) |
482 return; | 486 return; |
483 assert(Timers.size() > StackID); | 487 assert(Timers.size() > StackID); |
484 Timers[StackID].dump(getStrDump(), DumpCumulative); | 488 Timers[StackID].dump(getStrDump(), DumpCumulative); |
485 } | 489 } |
486 | 490 |
487 TimerMarker::TimerMarker(TimerIdT ID, const Cfg *Func) | 491 TimerMarker::TimerMarker(TimerIdT ID, const Cfg *Func) |
488 : ID(ID), Ctx(Func->getContext()), | 492 : ID(ID), Ctx(Func->getContext()), Active(false) { |
489 Active(Func->getFocusedTiming() || Ctx->getFlags().SubzeroTimingEnabled) { | 493 if (ALLOW_DUMP) { |
490 if (Active) | 494 Active = Func->getFocusedTiming() || Ctx->getFlags().SubzeroTimingEnabled; |
491 Ctx->pushTimer(ID); | 495 if (Active) |
| 496 Ctx->pushTimer(ID); |
| 497 } |
492 } | 498 } |
493 | 499 |
494 } // end of namespace Ice | 500 } // end of namespace Ice |
OLD | NEW |