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

Side by Side Diff: src/IceCfgNode.cpp

Issue 1337113008: Subzero: Don't contract an empty node that branches to itself. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Add a test Created 5 years, 3 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 | « no previous file | tests_lit/llvm2ice_tests/contract.ll » ('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/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 /// \file 10 /// \file
(...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after
741 return; 741 return;
742 Inst *Branch = nullptr; 742 Inst *Branch = nullptr;
743 for (Inst &I : Insts) { 743 for (Inst &I : Insts) {
744 if (I.isDeleted()) 744 if (I.isDeleted())
745 continue; 745 continue;
746 if (I.isUnconditionalBranch()) 746 if (I.isUnconditionalBranch())
747 Branch = &I; 747 Branch = &I;
748 else if (!I.isRedundantAssign()) 748 else if (!I.isRedundantAssign())
749 return; 749 return;
750 } 750 }
751 assert(OutEdges.size() == 1);
752 // Don't try to delete a self-loop.
753 if (OutEdges[0] == this)
754 return;
755
751 Branch->setDeleted(); 756 Branch->setDeleted();
752 assert(OutEdges.size() == 1);
753 CfgNode *Successor = OutEdges.front(); 757 CfgNode *Successor = OutEdges.front();
754 // Repoint all this node's in-edges to this node's successor, unless 758 // Repoint all this node's in-edges to this node's successor, unless
755 // this node's successor is actually itself (in which case the 759 // this node's successor is actually itself (in which case the
756 // statement "OutEdges.front()->InEdges.push_back(Pred)" could 760 // statement "OutEdges.front()->InEdges.push_back(Pred)" could
757 // invalidate the iterator over this->InEdges). 761 // invalidate the iterator over this->InEdges).
758 if (Successor != this) { 762 if (Successor != this) {
759 for (CfgNode *Pred : InEdges) { 763 for (CfgNode *Pred : InEdges) {
760 for (CfgNode *&I : Pred->OutEdges) { 764 for (CfgNode *&I : Pred->OutEdges) {
761 if (I == this) { 765 if (I == this) {
762 I = Successor; 766 I = Successor;
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after
1283 InstIntrinsicCall *Inst = InstIntrinsicCall::create( 1287 InstIntrinsicCall *Inst = InstIntrinsicCall::create(
1284 Func, 5, Func->makeVariable(IceType_i64), RMWI64Name, Info->Info); 1288 Func, 5, Func->makeVariable(IceType_i64), RMWI64Name, Info->Info);
1285 Inst->addArg(AtomicRMWOp); 1289 Inst->addArg(AtomicRMWOp);
1286 Inst->addArg(Counter); 1290 Inst->addArg(Counter);
1287 Inst->addArg(One); 1291 Inst->addArg(One);
1288 Inst->addArg(OrderAcquireRelease); 1292 Inst->addArg(OrderAcquireRelease);
1289 Insts.push_front(Inst); 1293 Insts.push_front(Inst);
1290 } 1294 }
1291 1295
1292 } // end of namespace Ice 1296 } // end of namespace Ice
OLDNEW
« no previous file with comments | « no previous file | tests_lit/llvm2ice_tests/contract.ll » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698