1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 11:42:57 +01:00

Make this into a static method.

llvm-svn: 80170
This commit is contained in:
Owen Anderson 2009-08-26 22:55:11 +00:00
parent 626333e9d1
commit 2ed352c8b6

View File

@ -730,10 +730,8 @@ namespace {
void dump(DenseMap<uint32_t, Value*>& d);
bool iterateOnFunction(Function &F);
Value* CollapsePhi(PHINode* p);
bool isSafeReplacement(PHINode* p, Instruction* inst);
bool performPRE(Function& F);
Value* lookupNumber(BasicBlock* BB, uint32_t num);
bool mergeBlockIntoPredecessor(BasicBlock* BB);
Value* AttemptRedundancyElimination(Instruction* orig, unsigned valno);
void cleanupGlobalSets();
void verifyRemoved(const Instruction *I) const;
@ -758,6 +756,19 @@ void GVN::dump(DenseMap<uint32_t, Value*>& d) {
printf("}\n");
}
static bool isSafeReplacement(PHINode* p, Instruction* inst) {
if (!isa<PHINode>(inst))
return true;
for (Instruction::use_iterator UI = p->use_begin(), E = p->use_end();
UI != E; ++UI)
if (PHINode* use_phi = dyn_cast<PHINode>(UI))
if (use_phi->getParent() == inst->getParent())
return false;
return true;
}
Value* GVN::CollapsePhi(PHINode* p) {
Value* constVal = p->hasConstantValue();
if (!constVal) return 0;
@ -772,19 +783,6 @@ Value* GVN::CollapsePhi(PHINode* p) {
return 0;
}
bool GVN::isSafeReplacement(PHINode* p, Instruction* inst) {
if (!isa<PHINode>(inst))
return true;
for (Instruction::use_iterator UI = p->use_begin(), E = p->use_end();
UI != E; ++UI)
if (PHINode* use_phi = dyn_cast<PHINode>(UI))
if (use_phi->getParent() == inst->getParent())
return false;
return true;
}
/// GetValueForBlock - Get the value to use within the specified basic block.
/// available values are in Phis.
Value *GVN::GetValueForBlock(BasicBlock *BB, Instruction* orig,