From e8c92dd439581bec7e3516cbdbea74e2e60fe7f0 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Fri, 23 Apr 2010 15:29:50 +0000 Subject: [PATCH] Move FastISel's HandlePHINodesInSuccessorBlocks call down into FastISel itself too. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@102176 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/FastISel.h | 16 ++++++++-------- lib/CodeGen/SelectionDAG/FastISel.cpp | 6 ++++++ lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp | 14 -------------- 3 files changed, 14 insertions(+), 22 deletions(-) diff --git a/include/llvm/CodeGen/FastISel.h b/include/llvm/CodeGen/FastISel.h index 8c8698cdc00..2eb2df2f601 100644 --- a/include/llvm/CodeGen/FastISel.h +++ b/include/llvm/CodeGen/FastISel.h @@ -107,14 +107,6 @@ public: /// index value. unsigned getRegForGEPIndex(const Value *V); - /// HandlePHINodesInSuccessorBlocks - Handle PHI nodes in successor blocks. - /// Emit code to ensure constants are copied into registers when needed. - /// Remember the virtual registers that need to be added to the Machine PHI - /// nodes as input. We cannot just directly add them, because expansion - /// might result in multiple MBB's for one BB. As such, the start of the - /// BB might correspond to a different MBB than the end. - bool HandlePHINodesInSuccessorBlocks(const BasicBlock *LLVMBB); - virtual ~FastISel(); protected: @@ -311,6 +303,14 @@ private: bool SelectBitCast(const User *I); bool SelectCast(const User *I, unsigned Opcode); + + /// HandlePHINodesInSuccessorBlocks - Handle PHI nodes in successor blocks. + /// Emit code to ensure constants are copied into registers when needed. + /// Remember the virtual registers that need to be added to the Machine PHI + /// nodes as input. We cannot just directly add them, because expansion + /// might result in multiple MBB's for one BB. As such, the start of the + /// BB might correspond to a different MBB than the end. + bool HandlePHINodesInSuccessorBlocks(const BasicBlock *LLVMBB); }; } diff --git a/lib/CodeGen/SelectionDAG/FastISel.cpp b/lib/CodeGen/SelectionDAG/FastISel.cpp index 132c42ef0d7..c40eaf62928 100644 --- a/lib/CodeGen/SelectionDAG/FastISel.cpp +++ b/lib/CodeGen/SelectionDAG/FastISel.cpp @@ -553,6 +553,12 @@ bool FastISel::SelectBitCast(const User *I) { bool FastISel::SelectInstruction(const Instruction *I) { + // Just before the terminator instruction, insert instructions to + // feed PHI nodes in successor blocks. + if (isa(I)) + if (!HandlePHINodesInSuccessorBlocks(I->getParent())) + return false; + DL = I->getDebugLoc(); // First, try doing target-independent selection. diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp index 875672e4e10..2cdd1cc9783 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp @@ -751,20 +751,6 @@ void SelectionDAGISel::SelectAllBasicBlocks(const Function &Fn) { FastIS->startNewBlock(BB); // Do FastISel on as many instructions as possible. for (; BI != End; ++BI) { - // Just before the terminator instruction, insert instructions to - // feed PHI nodes in successor blocks. - if (isa(BI)) - if (!FastIS->HandlePHINodesInSuccessorBlocks(LLVMBB)) { - ++NumFastIselFailures; - if (EnableFastISelVerbose || EnableFastISelAbort) { - dbgs() << "FastISel miss: "; - BI->dump(); - } - assert(!EnableFastISelAbort && - "FastISel didn't handle a PHI in a successor"); - break; - } - // Try to select the instruction with FastISel. if (FastIS->SelectInstruction(BI)) continue; -- 2.34.1