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

Unified Diff: src/IceOperand.cpp

Issue 680733002: Subzero: Allow delaying Phi lowering until after register allocation. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Fix vector const undef lowering for phis. Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/IceOperand.h ('k') | src/IceRegAlloc.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/IceOperand.cpp
diff --git a/src/IceOperand.cpp b/src/IceOperand.cpp
index a2ee8f4af3cd598406a1c3902c733b569daccfc1..4b55737952668c79c9170a4a0f0622bde283d126 100644
--- a/src/IceOperand.cpp
+++ b/src/IceOperand.cpp
@@ -320,38 +320,63 @@ void VariablesMetadata::init(MetadataKind TrackingKind) {
.markUse(Kind, NoInst, EntryNode, IsFromDef, IsImplicit);
}
- for (CfgNode *Node : Func->getNodes()) {
- for (Inst *I : Node->getInsts()) {
- if (I->isDeleted())
- continue;
- if (InstFakeKill *Kill = llvm::dyn_cast<InstFakeKill>(I)) {
- // A FakeKill instruction indicates certain Variables (usually
- // physical scratch registers) are redefined, so we register
- // them as defs.
- for (SizeT SrcNum = 0; SrcNum < I->getSrcSize(); ++SrcNum) {
- Variable *Var = llvm::cast<Variable>(I->getSrc(SrcNum));
- SizeT VarNum = Var->getIndex();
- assert(VarNum < Metadata.size());
- Metadata[VarNum].markDef(Kind, Kill, Node);
- }
- continue; // no point in executing the rest
- }
- if (Variable *Dest = I->getDest()) {
- SizeT DestNum = Dest->getIndex();
- assert(DestNum < Metadata.size());
- Metadata[DestNum].markDef(Kind, I, Node);
+ for (CfgNode *Node : Func->getNodes())
+ addNode(Node);
+}
+
+void VariablesMetadata::addNode(CfgNode *Node) {
+ if (Func->getNumVariables() >= Metadata.size())
+ Metadata.resize(Func->getNumVariables());
+
+ for (InstPhi *I : Node->getPhis()) {
+ if (I->isDeleted())
+ continue;
+ if (Variable *Dest = I->getDest()) {
+ SizeT DestNum = Dest->getIndex();
+ assert(DestNum < Metadata.size());
+ Metadata[DestNum].markDef(Kind, I, Node);
+ }
+ for (SizeT SrcNum = 0; SrcNum < I->getSrcSize(); ++SrcNum) {
+ if (const Variable *Var = llvm::dyn_cast<Variable>(I->getSrc(SrcNum))) {
+ SizeT VarNum = Var->getIndex();
+ assert(VarNum < Metadata.size());
+ const bool IsFromDef = false;
+ const bool IsImplicit = false;
+ Metadata[VarNum].markUse(Kind, I, Node, IsFromDef, IsImplicit);
}
+ }
+ }
+
+ for (Inst *I : Node->getInsts()) {
+ if (I->isDeleted())
+ continue;
+ if (InstFakeKill *Kill = llvm::dyn_cast<InstFakeKill>(I)) {
+ // A FakeKill instruction indicates certain Variables (usually
+ // physical scratch registers) are redefined, so we register
+ // them as defs.
for (SizeT SrcNum = 0; SrcNum < I->getSrcSize(); ++SrcNum) {
- Operand *Src = I->getSrc(SrcNum);
- SizeT NumVars = Src->getNumVars();
- for (SizeT J = 0; J < NumVars; ++J) {
- const Variable *Var = Src->getVar(J);
- SizeT VarNum = Var->getIndex();
- assert(VarNum < Metadata.size());
- const bool IsFromDef = false;
- const bool IsImplicit = false;
- Metadata[VarNum].markUse(Kind, I, Node, IsFromDef, IsImplicit);
- }
+ Variable *Var = llvm::cast<Variable>(I->getSrc(SrcNum));
+ SizeT VarNum = Var->getIndex();
+ assert(VarNum < Metadata.size());
+ Metadata[VarNum].markDef(Kind, Kill, Node);
+ }
+ continue; // no point in executing the rest
+ }
+ if (Variable *Dest = I->getDest()) {
+ SizeT DestNum = Dest->getIndex();
+ assert(DestNum < Metadata.size());
+ Metadata[DestNum].markDef(Kind, I, Node);
+ }
+ for (SizeT SrcNum = 0; SrcNum < I->getSrcSize(); ++SrcNum) {
+ Operand *Src = I->getSrc(SrcNum);
+ SizeT NumVars = Src->getNumVars();
+ for (SizeT J = 0; J < NumVars; ++J) {
+ const Variable *Var = Src->getVar(J);
+ SizeT VarNum = Var->getIndex();
+ assert(VarNum < Metadata.size());
+ const bool IsFromDef = false;
+ const bool IsImplicit = false;
+ Metadata[VarNum].markUse(Kind, I, Node, IsFromDef, IsImplicit);
}
}
}
« no previous file with comments | « src/IceOperand.h ('k') | src/IceRegAlloc.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698