Commit 1921fba6 by Jim Stichnoth

Subzero: Don't contract an empty node that branches to itself.

parent f977f715
......@@ -748,8 +748,12 @@ void CfgNode::contractIfEmpty() {
else if (!I.isRedundantAssign())
return;
}
Branch->setDeleted();
assert(OutEdges.size() == 1);
// Don't try to delete a self-loop.
if (OutEdges[0] == this)
return;
Branch->setDeleted();
CfgNode *Successor = OutEdges.front();
// Repoint all this node's in-edges to this node's successor, unless
// this node's successor is actually itself (in which case the
......
; This tests that an empty node pointing to itself is not contracted.
; https://code.google.com/p/nativeclient/issues/detail?id=4307
;
; RUN: %p2i -i %s --filetype=obj --disassemble --args -O2 \
; RUN: | FileCheck %s
define void @SimpleBranch() {
label0:
br label %label2
label1:
br label %label1
label2:
br label %label1
}
; CHECK-LABEL: SimpleBranch
; CHECK-NEXT: jmp 0 <SimpleBranch>
; CHECK-NEXT: hlt
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment