Index: src/IceCfgNode.cpp |
diff --git a/src/IceCfgNode.cpp b/src/IceCfgNode.cpp |
index 9e3f23adf634394616a2804d6da7f79530490304..f06e6312fbfa6341ea4688b5803fcda367767cb4 100644 |
--- a/src/IceCfgNode.cpp |
+++ b/src/IceCfgNode.cpp |
@@ -852,10 +852,16 @@ void CfgNode::contractIfEmpty() { |
else if (!I.isRedundantAssign()) |
return; |
} |
+ // Make sure there is actually a successor to repoint in-edges to. |
+ if (OutEdges.empty()) |
+ return; |
assert(OutEdges.size() == 1); |
// Don't try to delete a self-loop. |
if (OutEdges[0] == this) |
return; |
+ // Make sure the node actually contains (ends with) an unconditional branch. |
+ if (Branch == nullptr) |
+ return; |
Branch->setDeleted(); |
CfgNode *Successor = OutEdges.front(); |