Make this into a static method.
authorOwen Anderson <resistor@mac.com>
Wed, 26 Aug 2009 22:55:11 +0000 (22:55 +0000)
committerOwen Anderson <resistor@mac.com>
Wed, 26 Aug 2009 22:55:11 +0000 (22:55 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80170 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/GVN.cpp

index c782f7da7009c390b2e996125bb786dd203ad78f..a667a98d194e75bed134cdff8e5c53cdc310f950 100644 (file)
@@ -730,10 +730,8 @@ namespace {
     void dump(DenseMap<uint32_t, Value*>& d);
     bool iterateOnFunction(Function &F);
     Value* CollapsePhi(PHINode* p);
     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 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;
     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");
 }
 
   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;
 Value* GVN::CollapsePhi(PHINode* p) {
   Value* constVal = p->hasConstantValue();
   if (!constVal) return 0;
@@ -772,19 +783,6 @@ Value* GVN::CollapsePhi(PHINode* p) {
   return 0;
 }
 
   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,
 /// GetValueForBlock - Get the value to use within the specified basic block.
 /// available values are in Phis.
 Value *GVN::GetValueForBlock(BasicBlock *BB, Instruction* orig,