Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(245)

Side by Side Diff: src/IceCfg.cpp

Issue 1784243006: Subzero: Improve the use of timers. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Code review changes Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/IceCfg.h ('k') | src/IceCompiler.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===- subzero/src/IceCfg.cpp - Control flow graph implementation ---------===// 1 //===- subzero/src/IceCfg.cpp - Control flow graph implementation ---------===//
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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 constexpr Variable *Void = nullptr; 180 constexpr Variable *Void = nullptr;
181 constexpr bool HasTailCall = false; 181 constexpr bool HasTailCall = false;
182 auto *Call = 182 auto *Call =
183 InstCall::create(this, NumArgs, Void, ProfileSummarySym, HasTailCall); 183 InstCall::create(this, NumArgs, Void, ProfileSummarySym, HasTailCall);
184 getEntryNode()->getInsts().push_front(Call); 184 getEntryNode()->getInsts().push_front(Call);
185 } 185 }
186 186
187 void Cfg::translate() { 187 void Cfg::translate() {
188 if (hasError()) 188 if (hasError())
189 return; 189 return;
190 // FunctionTimer conditionally pushes/pops a TimerMarker if TimeEachFunction
191 // is enabled.
192 std::unique_ptr<TimerMarker> FunctionTimer;
193 if (BuildDefs::dump()) { 190 if (BuildDefs::dump()) {
194 const IceString &TimingFocusOn = 191 const IceString &TimingFocusOn =
195 getContext()->getFlags().getTimingFocusOn(); 192 getContext()->getFlags().getTimingFocusOn();
196 const IceString &Name = getFunctionName(); 193 const IceString &Name = getFunctionName();
197 if (TimingFocusOn == "*" || TimingFocusOn == Name) { 194 if (TimingFocusOn == "*" || TimingFocusOn == Name) {
198 setFocusedTiming(); 195 setFocusedTiming();
199 getContext()->resetTimer(GlobalContext::TSK_Default); 196 getContext()->resetTimer(GlobalContext::TSK_Default);
200 getContext()->setTimerName(GlobalContext::TSK_Default, Name); 197 getContext()->setTimerName(GlobalContext::TSK_Default, Name);
201 } 198 }
202 if (getContext()->getFlags().getTimeEachFunction())
203 FunctionTimer.reset(new TimerMarker(
204 getContext()->getTimerID(GlobalContext::TSK_Funcs, Name),
205 getContext(), GlobalContext::TSK_Funcs));
206 if (isVerbose(IceV_Status)) { 199 if (isVerbose(IceV_Status)) {
207 getContext()->getStrDump() << ">>>Translating " 200 getContext()->getStrDump() << ">>>Translating "
208 << getFunctionNameAndSize() << "\n"; 201 << getFunctionNameAndSize() << "\n";
209 } 202 }
210 } 203 }
204 TimerMarker T_func(getContext(), getFunctionName());
211 TimerMarker T(TimerStack::TT_translate, this); 205 TimerMarker T(TimerStack::TT_translate, this);
212 206
213 dump("Initial CFG"); 207 dump("Initial CFG");
214 208
215 if (getContext()->getFlags().getEnableBlockProfile()) { 209 if (getContext()->getFlags().getEnableBlockProfile()) {
216 profileBlocks(); 210 profileBlocks();
217 // TODO(jpp): this is fragile, at best. Figure out a better way of 211 // TODO(jpp): this is fragile, at best. Figure out a better way of
218 // detecting exit functions. 212 // detecting exit functions.
219 if (GlobalContext::matchSymbolName(getFunctionName(), "exit")) { 213 if (GlobalContext::matchSymbolName(getFunctionName(), "exit")) {
220 addCallToProfileSummary(); 214 addCallToProfileSummary();
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 Insts.push_front(Def); 560 Insts.push_front(Def);
567 Alloca->setDeleted(); 561 Alloca->setDeleted();
568 } 562 }
569 // Allocate the fixed area in the function prolog. 563 // Allocate the fixed area in the function prolog.
570 getTarget()->reserveFixedAllocaArea(TotalSize, CombinedAlignment); 564 getTarget()->reserveFixedAllocaArea(TotalSize, CombinedAlignment);
571 } break; 565 } break;
572 } 566 }
573 } 567 }
574 568
575 void Cfg::processAllocas(bool SortAndCombine) { 569 void Cfg::processAllocas(bool SortAndCombine) {
570 TimerMarker _(TimerStack::TT_alloca, this);
576 const uint32_t StackAlignment = getTarget()->getStackAlignment(); 571 const uint32_t StackAlignment = getTarget()->getStackAlignment();
577 CfgNode *EntryNode = getEntryNode(); 572 CfgNode *EntryNode = getEntryNode();
578 // LLVM enforces power of 2 alignment. 573 // LLVM enforces power of 2 alignment.
579 assert(llvm::isPowerOf2_32(StackAlignment)); 574 assert(llvm::isPowerOf2_32(StackAlignment));
580 // Determine if there are large alignment allocations in the entry block or 575 // Determine if there are large alignment allocations in the entry block or
581 // dynamic allocations (variable size in the entry block). 576 // dynamic allocations (variable size in the entry block).
582 bool HasLargeAlignment = false; 577 bool HasLargeAlignment = false;
583 bool HasDynamicAllocation = false; 578 bool HasDynamicAllocation = false;
584 for (Inst &Instr : EntryNode->getInsts()) { 579 for (Inst &Instr : EntryNode->getInsts()) {
585 if (auto *Alloca = llvm::dyn_cast<InstAlloca>(&Instr)) { 580 if (auto *Alloca = llvm::dyn_cast<InstAlloca>(&Instr)) {
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after
1076 1071
1077 size_t Cfg::getTotalMemoryMB() { 1072 size_t Cfg::getTotalMemoryMB() {
1078 constexpr size_t OneMB = 1024 * 1024; 1073 constexpr size_t OneMB = 1024 * 1024;
1079 using ArbitraryType = int; 1074 using ArbitraryType = int;
1080 // CfgLocalAllocator draws from the same memory pool regardless of allocated 1075 // CfgLocalAllocator draws from the same memory pool regardless of allocated
1081 // object type, so pick an arbitrary type for the template parameter. 1076 // object type, so pick an arbitrary type for the template parameter.
1082 return CfgLocalAllocator<ArbitraryType>().current()->getTotalMemory() / OneMB; 1077 return CfgLocalAllocator<ArbitraryType>().current()->getTotalMemory() / OneMB;
1083 } 1078 }
1084 1079
1085 // Dumps the IR with an optional introductory message. 1080 // Dumps the IR with an optional introductory message.
1086 void Cfg::dump(const IceString &Message) { 1081 void Cfg::dump(const char *Message) {
1087 if (!BuildDefs::dump()) 1082 if (!BuildDefs::dump())
1088 return; 1083 return;
1089 if (!isVerbose()) 1084 if (!isVerbose())
1090 return; 1085 return;
1091 OstreamLocker L(Ctx); 1086 OstreamLocker L(Ctx);
1092 Ostream &Str = Ctx->getStrDump(); 1087 Ostream &Str = Ctx->getStrDump();
1093 if (!Message.empty()) 1088 if (Message[0])
1094 Str << "================ " << Message << " ================\n"; 1089 Str << "================ " << Message << " ================\n";
1095 if (isVerbose(IceV_Mem)) { 1090 if (isVerbose(IceV_Mem)) {
1096 Str << "Memory size = " << getTotalMemoryMB() << " MB\n"; 1091 Str << "Memory size = " << getTotalMemoryMB() << " MB\n";
1097 } 1092 }
1098 setCurrentNode(getEntryNode()); 1093 setCurrentNode(getEntryNode());
1099 // Print function name+args 1094 // Print function name+args
1100 if (isVerbose(IceV_Instructions)) { 1095 if (isVerbose(IceV_Instructions)) {
1101 Str << "define "; 1096 Str << "define ";
1102 if (getInternal() && !Ctx->getFlags().getDisableInternal()) 1097 if (getInternal() && !Ctx->getFlags().getDisableInternal())
1103 Str << "internal "; 1098 Str << "internal ";
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1143 } 1138 }
1144 } 1139 }
1145 // Print each basic block 1140 // Print each basic block
1146 for (CfgNode *Node : Nodes) 1141 for (CfgNode *Node : Nodes)
1147 Node->dump(this); 1142 Node->dump(this);
1148 if (isVerbose(IceV_Instructions)) 1143 if (isVerbose(IceV_Instructions))
1149 Str << "}\n"; 1144 Str << "}\n";
1150 } 1145 }
1151 1146
1152 } // end of namespace Ice 1147 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceCfg.h ('k') | src/IceCompiler.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698