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

Side by Side Diff: src/IceCfgNode.cpp

Issue 1147023007: Subzero: Basic Block Profiler. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Adds a $ to the profiler generated labels. Created 5 years, 6 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
OLDNEW
1 //===- subzero/src/IceCfgNode.cpp - Basic block (node) implementation -----===// 1 //===- subzero/src/IceCfgNode.cpp - Basic block (node) 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 // This file implements the CfgNode class, including the complexities 10 // This file implements the CfgNode class, including the complexities
11 // of instruction insertion and in-edge calculation. 11 // of instruction insertion and in-edge calculation.
12 // 12 //
13 //===----------------------------------------------------------------------===// 13 //===----------------------------------------------------------------------===//
14 14
15 #include "assembler.h" 15 #include "assembler.h"
16 #include "IceCfg.h" 16 #include "IceCfg.h"
17 #include "IceCfgNode.h" 17 #include "IceCfgNode.h"
18 #include "IceGlobalInits.h"
18 #include "IceInst.h" 19 #include "IceInst.h"
19 #include "IceLiveness.h" 20 #include "IceLiveness.h"
20 #include "IceOperand.h" 21 #include "IceOperand.h"
21 #include "IceTargetLowering.h" 22 #include "IceTargetLowering.h"
22 23
23 namespace Ice { 24 namespace Ice {
24 25
25 CfgNode::CfgNode(Cfg *Func, SizeT LabelNumber) 26 CfgNode::CfgNode(Cfg *Func, SizeT LabelNumber)
26 : Func(Func), Number(LabelNumber), NameIndex(Cfg::IdentifierIndexInvalid), 27 : Func(Func), Number(LabelNumber), NameIndex(Cfg::IdentifierIndexInvalid),
27 HasReturn(false), NeedsPlacement(false), InstCountEstimate(0) {} 28 HasReturn(false), NeedsPlacement(false), InstCountEstimate(0) {}
(...skipping 1208 matching lines...) Expand 10 before | Expand all | Expand 10 after
1236 for (CfgNode *I : OutEdges) { 1237 for (CfgNode *I : OutEdges) {
1237 if (!First) 1238 if (!First)
1238 Str << ", "; 1239 Str << ", ";
1239 First = false; 1240 First = false;
1240 Str << "%" << I->getName(); 1241 Str << "%" << I->getName();
1241 } 1242 }
1242 Str << "\n"; 1243 Str << "\n";
1243 } 1244 }
1244 } 1245 }
1245 1246
1247 void CfgNode::profileExecutionCount(VariableDeclaration *Var) {
1248 constexpr char RMW_I64[] = "llvm.nacl.atomic.rmw.i64";
1249
1250 GlobalContext *Context = Func->getContext();
1251
1252 bool BadIntrinsic = false;
1253 const Intrinsics::FullIntrinsicInfo *Info =
1254 Context->getIntrinsicsInfo().find(RMW_I64, BadIntrinsic);
1255 assert(!BadIntrinsic);
1256 assert(Info != nullptr);
1257
1258 Operand *RMWI64Name = Context->getConstantExternSym(RMW_I64);
1259 Constant *Counter = Context->getConstantExternSym(Var->getName());
1260 Constant *AtomicRMWOp = Context->getConstantInt32(Intrinsics::AtomicAdd);
1261 Constant *One = Context->getConstantInt64(1);
1262 Constant *OrderAcquireRelease =
1263 Context->getConstantInt32(Intrinsics::MemoryOrderAcquireRelease);
1264
1265 InstIntrinsicCall *Inst = InstIntrinsicCall::create(
1266 Func, 5, Func->makeVariable(IceType_i64), RMWI64Name, Info->Info);
1267 Inst->addArg(AtomicRMWOp);
1268 Inst->addArg(Counter);
1269 Inst->addArg(One);
1270 Inst->addArg(OrderAcquireRelease);
1271 Insts.push_front(Inst);
1272 }
1273
1246 } // end of namespace Ice 1274 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceCfgNode.h ('k') | src/IceClFlags.h » ('j') | src/IceGlobalContext.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698