From f8a801a9b80f3c9e663d7ba201d7e70e56d84f89 Mon Sep 17 00:00:00 2001 From: Evan Cheng Date: Thu, 7 Aug 2008 00:43:25 +0000 Subject: [PATCH] Factor code that finalize PHI nodes, jump tables, etc. out of SelectBasicBlock. No functionality changes. llvm-svn: 54438 --- include/llvm/CodeGen/SelectionDAGISel.h | 7 +++- lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp | 37 ++++++++++++------- 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/include/llvm/CodeGen/SelectionDAGISel.h b/include/llvm/CodeGen/SelectionDAGISel.h index 668e64eb874..804ccf3e590 100644 --- a/include/llvm/CodeGen/SelectionDAGISel.h +++ b/include/llvm/CodeGen/SelectionDAGISel.h @@ -182,10 +182,15 @@ private: FunctionLoweringInfo &FuncInfo); void SelectBasicBlock(BasicBlock *BB, MachineFunction &MF, FunctionLoweringInfo &FuncInfo, + std::vector > &PHINodesToUpdate, + NodeAllocatorType &NodeAllocator); + void FinishBasicBlock(BasicBlock *BB, MachineFunction &MF, + FunctionLoweringInfo &FuncInfo, + std::vector > &PHINodesToUpdate, NodeAllocatorType &NodeAllocator); void BuildSelectionDAG(SelectionDAG &DAG, BasicBlock *LLVMBB, - std::vector > &PHINodesToUpdate, + std::vector > &PHINodesToUpdate, FunctionLoweringInfo &FuncInfo); void CodeGenAndEmitDAG(SelectionDAG &DAG); void LowerArguments(BasicBlock *BB, SelectionDAGLowering &SDL); diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp index 961c12d7a77..ac30ff63b70 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp @@ -5441,29 +5441,38 @@ void SelectionDAGISel::SelectAllBasicBlocks(Function &Fn, MachineFunction &MF, // each basic block. NodeAllocatorType NodeAllocator; - for (Function::iterator I = Fn.begin(), E = Fn.end(); I != E; ++I) - SelectBasicBlock(I, MF, FuncInfo, NodeAllocator); + std::vector > PHINodesToUpdate; + for (Function::iterator I = Fn.begin(), E = Fn.end(); I != E; ++I) { + BasicBlock *LLVMBB = &*I; + PHINodesToUpdate.clear(); + SelectBasicBlock(LLVMBB, MF, FuncInfo, PHINodesToUpdate, NodeAllocator); + FinishBasicBlock(LLVMBB, MF, FuncInfo, PHINodesToUpdate, NodeAllocator); + } } void SelectionDAGISel::SelectBasicBlock(BasicBlock *LLVMBB, MachineFunction &MF, FunctionLoweringInfo &FuncInfo, + std::vector > &PHINodesToUpdate, NodeAllocatorType &NodeAllocator) { - std::vector > PHINodesToUpdate; - { - SelectionDAG DAG(TLI, MF, FuncInfo, - getAnalysisToUpdate(), - NodeAllocator); - CurDAG = &DAG; + SelectionDAG DAG(TLI, MF, FuncInfo, + getAnalysisToUpdate(), + NodeAllocator); + CurDAG = &DAG; - // First step, lower LLVM code to some DAG. This DAG may use operations and - // types that are not supported by the target. - BuildSelectionDAG(DAG, LLVMBB, PHINodesToUpdate, FuncInfo); + // First step, lower LLVM code to some DAG. This DAG may use operations and + // types that are not supported by the target. + BuildSelectionDAG(DAG, LLVMBB, PHINodesToUpdate, FuncInfo); - // Second step, emit the lowered DAG as machine code. - CodeGenAndEmitDAG(DAG); - } + // Second step, emit the lowered DAG as machine code. + CodeGenAndEmitDAG(DAG); +} +void +SelectionDAGISel::FinishBasicBlock(BasicBlock *LLVMBB, MachineFunction &MF, + FunctionLoweringInfo &FuncInfo, + std::vector > &PHINodesToUpdate, + NodeAllocatorType &NodeAllocator) { DOUT << "Total amount of phi nodes to update: " << PHINodesToUpdate.size() << "\n"; DEBUG(for (unsigned i = 0, e = PHINodesToUpdate.size(); i != e; ++i)