Don't send PHI nodes down to SelectionDAGBuilder of FastISel, since
authorDan Gohman <gohman@apple.com>
Tue, 20 Apr 2010 15:00:41 +0000 (15:00 +0000)
committerDan Gohman <gohman@apple.com>
Tue, 20 Apr 2010 15:00:41 +0000 (15:00 +0000)
they end up doing nothing.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101904 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/SelectionDAG/FastISel.cpp
lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h
lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp

index cd72fe7003d2a77ad8e3de25f958e4ba30fd5dd2..8f53c5caaebbffe71a10727308da5ae7b695d688 100644 (file)
@@ -52,6 +52,7 @@
 #include "llvm/Target/TargetInstrInfo.h"
 #include "llvm/Target/TargetLowering.h"
 #include "llvm/Target/TargetMachine.h"
+#include "llvm/Support/ErrorHandling.h"
 #include "FunctionLoweringInfo.h"
 using namespace llvm;
 
@@ -692,10 +693,6 @@ FastISel::SelectOperator(const User *I, unsigned Opcode) {
     // Nothing to emit.
     return true;
 
-  case Instruction::PHI:
-    // PHI nodes are already emitted.
-    return true;
-
   case Instruction::Alloca:
     // FunctionLowering has the static-sized case covered.
     if (StaticAllocaMap.count(cast<AllocaInst>(I)))
@@ -735,6 +732,9 @@ FastISel::SelectOperator(const User *I, unsigned Opcode) {
     return true;
   }
 
+  case Instruction::PHI:
+    llvm_unreachable("FastISel shouldn't visit PHI nodes!");
+
   default:
     // Unhandled instruction. Halt "fast" selection and bail.
     return false;
index 470689bd06f502df10ce1ee053b631781434ab75..054174f037e9902d7642411f968633f365069ffe 100644 (file)
@@ -621,6 +621,10 @@ void SelectionDAGBuilder::visit(const Instruction &I) {
   CurDebugLoc = DebugLoc();
 }
 
+void SelectionDAGBuilder::visitPHI(const PHINode &) {
+  llvm_unreachable("SelectionDAGBuilder shouldn't visit PHI nodes!");
+}
+
 void SelectionDAGBuilder::visit(unsigned Opcode, const User &I) {
   // Note: this doesn't use InstVisitor, because it has to work with
   // ConstantExpr's in addition to instructions.
index 1f9e43ff339299b4fb5f7e7896e23b76edee256c..ad18850bacd9001039c7422ffa014600a6f23fd3 100644 (file)
@@ -468,7 +468,7 @@ private:
   void visitAlloca(const AllocaInst &I);
   void visitLoad(const LoadInst &I);
   void visitStore(const StoreInst &I);
-  void visitPHI(const PHINode &I) { } // PHI nodes are handled specially.
+  void visitPHI(const PHINode &I);
   void visitCall(const CallInst &I);
   bool visitMemCmpCall(const CallInst &I);
   
index e21b1c8ca59336f4243eab8dad81f4c72e1ab43f..2a27d1b59a2c0099598befeecaf31201c7412e88 100644 (file)
@@ -728,7 +728,7 @@ void SelectionDAGISel::SelectAllBasicBlocks(const Function &Fn) {
     const BasicBlock *LLVMBB = &*I;
     MachineBasicBlock *BB = FuncInfo->MBBMap[LLVMBB];
 
-    BasicBlock::const_iterator const Begin = LLVMBB->begin();
+    BasicBlock::const_iterator const Begin = LLVMBB->getFirstNonPHI();
     BasicBlock::const_iterator const End = LLVMBB->end();
     BasicBlock::const_iterator BI = Begin;