Reset CFG edge tracking on re-run.

This commit is contained in:
Ben Vanik 2014-08-06 11:38:36 -07:00
parent b6046b1860
commit 9efd372d92
2 changed files with 12 additions and 3 deletions

View File

@ -33,7 +33,8 @@ int Compiler::Compile(HIRBuilder* builder) {
// TODO(benvanik): sophisticated stuff. Run passes in parallel, run until they
// stop changing things, etc.
for (auto& pass : passes_) {
for (size_t i = 0; i < passes_.size(); ++i) {
auto& pass = passes_[i];
scratch_arena_.Reset();
if (pass->Run(builder)) {
return 1;

View File

@ -30,10 +30,18 @@ ControlFlowAnalysisPass::~ControlFlowAnalysisPass() {}
int ControlFlowAnalysisPass::Run(HIRBuilder* builder) {
SCOPE_profile_cpu_f("alloy");
// TODO(benvanik): reset edges for all blocks? Needed to be re-runnable.
// Reset edges for all blocks. Needed to be re-runnable.
// Note that this wastes a bunch of arena memory, so we shouldn't
// re-run too often.
auto block = builder->first_block();
while (block) {
block->incoming_edge_head = nullptr;
block->outgoing_edge_head = nullptr;
block = block->next;
}
// Add edges.
auto block = builder->first_block();
block = builder->first_block();
while (block) {
auto instr = block->instr_tail;
while (instr) {