// For a given block, calculate the generated expressions, temporaries,
// and the AVAIL_OUT set
void cleanup();
- void elimination();
+ void elimination(bool& changed_function);
void val_insert(std::set<Value*>& s, Value* v);
void val_replace(std::set<Value*>& s, Value* v);
DOUT << "}\n\n";
}
-void GVNPRE::elimination() {
+void GVNPRE::elimination(bool& changed_function) {
DOUT << "\n\nPhase 3: Elimination\n\n";
std::vector<std::pair<Instruction*, Value*> > replace;
std::pair<Instruction*, Value*> rep = replace.back();
replace.pop_back();
rep.first->replaceAllUsesWith(rep.second);
+ changed_function = true;
}
for (std::vector<Instruction*>::iterator I = erase.begin(), E = erase.end();
availableOut.clear();
anticipatedIn.clear();
invokeDep.clear();
+
+ bool changed_function = false;
std::map<BasicBlock*, std::set<Value*> > generatedExpressions;
std::map<BasicBlock*, std::set<PHINode*> > generatedPhis;
// If function has no exit blocks, only perform GVN
PostDominatorTree &PDT = getAnalysis<PostDominatorTree>();
if (PDT[&F.getEntryBlock()] == 0) {
- elimination();
+ elimination(changed_function);
cleanup();
return true;
C->getName()+".gvnpre",
(*PI)->getTerminator());
+ changed_function = true;
+
VN.add(newVal, VN.lookup(U));
std::set<Value*>& predAvail = availableOut[*PI];
p->addIncoming(avail[*PI], *PI);
}
+ changed_function = true;
+
VN.add(p, VN.lookup(e));
DOUT << "Creating value: " << std::hex << p << std::dec << "\n";
}
// Phase 3: Eliminate
- elimination();
+ elimination(changed_function);
// Phase 4: Cleanup
cleanup();
- return true;
+ return changed_function;
}