Bug 843518: IonMonkey: Run alias analysis when UCE removes dependency of an instruction, r=nmatsakis

This commit is contained in:
Hannes Verschore 2013-02-21 15:56:43 +01:00
parent 25122a53f6
commit 407104ef88
2 changed files with 20 additions and 5 deletions

View File

@ -7,6 +7,7 @@
#include "UnreachableCodeElimination.h"
#include "IonAnalysis.h"
#include "AliasAnalysis.h"
using namespace js;
using namespace ion;
@ -70,6 +71,13 @@ UnreachableCodeElimination::removeUnmarkedBlocksAndCleanup()
if (redundantPhis_ && !EliminatePhis(mir_, graph_, ConservativeObservability))
return false;
// Pass 4: Rerun alias analysis
if (rerunAliasAnalysis_) {
AliasAnalysis analysis(mir_, graph_);
if (!analysis.analyze())
return false;
}
return true;
}
@ -128,8 +136,13 @@ UnreachableCodeElimination::prunePointlessBranchesAndMarkReachableBlocks()
}
void
UnreachableCodeElimination::removeUsesFromUnmarkedBlocks(MDefinition *instr)
UnreachableCodeElimination::checkDependencyAndRemoveUsesFromUnmarkedBlocks(MDefinition *instr)
{
// When the instruction depends on removed block,
// alias analysis needs to get rerun to have the right dependency.
if (instr->dependency() && !instr->dependency()->block()->isMarked())
rerunAliasAnalysis_ = true;
for (MUseIterator iter(instr->usesBegin()); iter != instr->usesEnd(); ) {
if (!iter->consumer()->block()->isMarked())
iter = instr->removeUse(iter);
@ -161,9 +174,9 @@ UnreachableCodeElimination::removeUnmarkedBlocksAndClearDominators()
if (block->isMarked()) {
block->setId(--id);
for (MPhiIterator iter(block->phisBegin()); iter != block->phisEnd(); iter++)
removeUsesFromUnmarkedBlocks(*iter);
checkDependencyAndRemoveUsesFromUnmarkedBlocks(*iter);
for (MInstructionIterator iter(block->begin()); iter != block->end(); iter++)
removeUsesFromUnmarkedBlocks(*iter);
checkDependencyAndRemoveUsesFromUnmarkedBlocks(*iter);
} else {
if (block->numPredecessors() > 1) {
// If this block had phis, then any reachable

View File

@ -22,9 +22,10 @@ class UnreachableCodeElimination
MIRGraph &graph_;
uint32_t marked_;
bool redundantPhis_;
bool rerunAliasAnalysis_;
bool prunePointlessBranchesAndMarkReachableBlocks();
void removeUsesFromUnmarkedBlocks(MDefinition *instr);
void checkDependencyAndRemoveUsesFromUnmarkedBlocks(MDefinition *instr);
bool removeUnmarkedBlocksAndClearDominators();
bool removeUnmarkedBlocksAndCleanup();
@ -33,7 +34,8 @@ class UnreachableCodeElimination
: mir_(mir),
graph_(graph),
marked_(0),
redundantPhis_(false)
redundantPhis_(false),
rerunAliasAnalysis_(false)
{}
// Walks the graph and discovers what is reachable. Removes everything else.