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

Unified Diff: src/IceCfgNode.cpp

Issue 1847423003: Replace constant conditional branches by unconditional branches (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Code review fixes Created 4 years, 8 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/IceCfgNode.h ('k') | src/IceInst.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/IceCfgNode.cpp
diff --git a/src/IceCfgNode.cpp b/src/IceCfgNode.cpp
index 9fc6634af6eaff164f17b3aed4385c44fbe7b104..45979362c2fa867e54047fb4f3ca8fb2d338ae37 100644
--- a/src/IceCfgNode.cpp
+++ b/src/IceCfgNode.cpp
@@ -84,11 +84,13 @@ void CfgNode::computeSuccessors() {
OutEdges = Insts.rbegin()->getTerminatorEdges();
}
-// Validate each Phi instruction in the node with respect to control flow. For
-// every phi argument, its label must appear in the predecessor list. For each
-// predecessor, there must be a phi argument with that label. We don't check
-// that phi arguments with the same label have the same value.
-void CfgNode::validatePhis() {
+// Ensure each Phi instruction in the node is consistent with respect to control
+// flow. For each predecessor, there must be a phi argument with that label.
+// For every phi argument, its label must appear in the predecessor list or the
+// value must be zero. The latter allows us to remove some dead control flow
Jim Stichnoth 2016/04/04 15:50:31 I suggest this change of the "For every phi argume
sehr 2016/04/04 17:06:41 Done.
+// without a major rework of the phi nodes. We don't check that phi arguments
Jim Stichnoth 2016/04/04 15:50:31 I prefer "phi instruction" over "phi node", but yo
sehr 2016/04/04 17:06:41 Done.
+// with the same label have the same value.
+void CfgNode::enforcePhiConsistency() {
for (Inst &Instr : Phis) {
auto *Phi = llvm::cast<InstPhi>(&Instr);
// We do a simple O(N^2) algorithm to check for consistency. Even so, it
@@ -106,8 +108,11 @@ void CfgNode::validatePhis() {
break;
}
}
- if (!Found)
- llvm::report_fatal_error("Phi error: label for bad incoming edge");
+ if (!Found) {
+ // Predecessor was unreachable, so if (impossibly) the control flow
+ // enters from that predecessor, the value should be zero.
+ Phi->clearOperandForTarget(Label);
+ }
}
for (CfgNode *InNode : getInEdges()) {
bool Found = false;
« no previous file with comments | « src/IceCfgNode.h ('k') | src/IceInst.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698