This commit is contained in:
kobalicek 2015-02-28 00:36:50 +01:00
parent fa1f8346e2
commit bac4a2b14c
2 changed files with 12 additions and 3 deletions

View File

@ -266,6 +266,7 @@ struct X86Test_JumpUnreachable1 : public X86Test {
c.bind(L_7);
c.add(v0, v1);
c.align(kAlignCode, 16);
c.bind(L_1);
c.ret();
c.endFunc();

View File

@ -270,6 +270,8 @@ Error Context::resolveCellOffsets() {
// ============================================================================
Error Context::removeUnreachableCode() {
Compiler* compiler = getCompiler();
PodList<Node*>::Link* link = _unreachableList.getFirst();
Node* stop = getStop();
@ -284,10 +286,16 @@ Error Context::removeUnreachableCode() {
node = node->getNext();
} while (node != stop);
// Remove.
// Remove unreachable nodes that are neither informative nor directives.
if (node != first) {
Node* last = (node != NULL) ? node->getPrev() : getCompiler()->getLastNode();
getCompiler()->removeNodes(first, last);
Node* end = node;
node = first;
do {
Node* next = node->getNext();
if (!node->isInformative() && node->getType() != kNodeTypeAlign)
compiler->removeNode(node);
node = next;
} while (node != end);
}
}