Disable an xform that causes an infinite loop. This fixes PR1594
[oota-llvm.git] / lib / Transforms / Utils / LowerSelect.cpp
index c0c8a329da2aa299c9329235507be46278b9ab40..317e84aa96f345e146c0668d86df67a0df4674d7 100644 (file)
 #include "llvm/Instructions.h"
 #include "llvm/Pass.h"
 #include "llvm/Type.h"
+#include "llvm/Support/Compiler.h"
 using namespace llvm;
 
 namespace {
   /// LowerSelect - Turn select instructions into conditional branches.
   ///
-  class LowerSelect : public FunctionPass {
+  class VISIBILITY_HIDDEN LowerSelect : public FunctionPass {
     bool OnlyFP;   // Only lower FP select instructions?
   public:
-    LowerSelect(bool onlyfp = false) : OnlyFP(onlyfp) {}
+    static char ID; // Pass identification, replacement for typeid
+    explicit LowerSelect(bool onlyfp = false) : FunctionPass((intptr_t)&ID), 
+      OnlyFP(onlyfp) {}
 
     virtual void getAnalysisUsage(AnalysisUsage &AU) const {
       // This certainly destroys the CFG.
-      // This is a cluster of orthogonal Transforms:   
+      // This is a cluster of orthogonal Transforms:
       AU.addPreserved<UnifyFunctionExitNodes>();
       AU.addPreservedID(PromoteMemoryToRegisterID);
       AU.addPreservedID(LowerSwitchID);
@@ -47,6 +50,7 @@ namespace {
     bool runOnFunction(Function &F);
   };
 
+  char LowerSelect::ID = 0;
   RegisterPass<LowerSelect>
   X("lowerselect", "Lower select instructions to branches");
 }
@@ -84,8 +88,8 @@ bool LowerSelect::runOnFunction(Function &F) {
           new BranchInst(NewTrue, NewCont, SI->getCondition(), BB);
 
           // Create a new PHI node in the cont block with the entries we need.
-          std::string Name = SI->getName(); SI->setName("");
-          PHINode *PN = new PHINode(SI->getType(), Name, NewCont->begin());
+          PHINode *PN = new PHINode(SI->getType(), "", NewCont->begin());
+          PN->takeName(SI);
           PN->addIncoming(SI->getTrueValue(), NewTrue);
           PN->addIncoming(SI->getFalseValue(), BB);