From 32810ec3416c24f7e1c3467b485a2b4474389ecf Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Mon, 24 Mar 2014 10:36:42 -0700 Subject: apply switch-related phi changes after illegal phis were erased --- lib/Target/JSBackend/ExpandI64.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/Target/JSBackend/ExpandI64.cpp b/lib/Target/JSBackend/ExpandI64.cpp index 9929033169..1fbf0ddebd 100644 --- a/lib/Target/JSBackend/ExpandI64.cpp +++ b/lib/Target/JSBackend/ExpandI64.cpp @@ -1096,7 +1096,14 @@ bool ExpandI64::runOnModule(Module &M) { PN->dropAllReferences(); } - // Apply basic block changes to phis, now that phis are all processed + // Delete instructions which were replaced. We do this after the full walk + // of the instructions so that all uses are replaced first. + while (!Dead.empty()) { + Instruction *D = Dead.pop_back_val(); + D->eraseFromParent(); + } + + // Apply basic block changes to phis, now that phis are all processed (and illegal phis erased) for (unsigned i = 0; i < PhiBlockChanges.size(); i++) { PhiBlockChange &Change = PhiBlockChanges[i]; for (BasicBlock::iterator I = Change.DD->begin(); I != Change.DD->end(); ++I) { @@ -1108,13 +1115,6 @@ bool ExpandI64::runOnModule(Module &M) { } } - // Delete instructions which were replaced. We do this after the full walk - // of the instructions so that all uses are replaced first. - while (!Dead.empty()) { - Instruction *D = Dead.pop_back_val(); - D->eraseFromParent(); - } - // We only visited blocks found by a DFS walk from the entry, so we haven't // visited any unreachable blocks, and they may still contain illegal // instructions at this point. Being unreachable, they can simply be deleted. -- cgit v1.2.3-18-g5258