}
//===----------------------------------------------------------------------===//
-// GVN Pass
+// GVN Pass
//===----------------------------------------------------------------------===//
namespace {
Value* v = GetValueForBlock(LI->getParent(), LI, BlockReplValues, true);
LI->replaceAllUsesWith(v);
- if (!isa<GlobalValue>(v))
+ if (isa<PHINode>(v))
v->takeName(LI);
if (isa<PointerType>(v->getType()))
MD->invalidateCachedPointerInfo(v);
// Perform PHI construction.
Value* v = GetValueForBlock(LI->getParent(), LI, BlockReplValues, true);
LI->replaceAllUsesWith(v);
- if (!isa<GlobalValue>(v))
+ if (isa<PHINode>(v))
v->takeName(LI);
if (isa<PointerType>(v->getType()))
MD->invalidateCachedPointerInfo(v);
DenseMap<BasicBlock*, ValueNumberScope*>::iterator LA =
localAvail.find(Current);
if (LA == localAvail.end()) return 0;
- DenseMap<unsigned, Value*>::iterator V = LA->second->table.find(valno);
+ DenseMap<uint32_t, Value*>::iterator V = LA->second->table.find(valno);
if (V != LA->second->table.end()) {
// Found an instance, record it.
p->replaceAllUsesWith(constVal);
if (isa<PointerType>(constVal->getType()))
MD->invalidateCachedPointerInfo(constVal);
+ VN.erase(p);
+
toErase.push_back(p);
} else {
localAvail[I->getParent()]->table.insert(std::make_pair(num, I));
return false;
}
-// GVN::runOnFunction - This is the main transformation entry point for a
-// function.
-//
+/// runOnFunction - This is the main transformation entry point for a function.
bool GVN::runOnFunction(Function& F) {
MD = &getAnalysis<MemoryDependenceAnalysis>();
DT = &getAnalysis<DominatorTree>();
return Changed || toSplit.size();
}
-// iterateOnFunction - Executes one iteration of GVN
+/// iterateOnFunction - Executes one iteration of GVN
bool GVN::iterateOnFunction(Function &F) {
cleanupGlobalSets();