aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-03-30 01:10:47 +0000
committerChris Lattner <sabre@nondot.org>2005-03-30 01:10:47 +0000
commita33ef4816d2c192e36e7c025d18c66e89ef9d311 (patch)
tree7e38ba2b0816c1f693d0ea706691b3384b245cd7 /lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
parent71df3f8cabce61a1cab31596f0f0cf8803461e80 (diff)
Instead of setting up the CFG edges at selectiondag construction time, set
them up after the code has been emitted. This allows targets to select one mbb as multiple mbb's as needed. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20937 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp')
-rw-r--r--lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp22
1 files changed, 15 insertions, 7 deletions
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
index ded66afaa1..9871cb32c1 100644
--- a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
+++ b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
@@ -414,7 +414,6 @@ void SelectionDAGLowering::visitRet(ReturnInst &I) {
void SelectionDAGLowering::visitBr(BranchInst &I) {
// Update machine-CFG edges.
MachineBasicBlock *Succ0MBB = FuncInfo.MBBMap[I.getSuccessor(0)];
- CurMBB->addSuccessor(Succ0MBB);
// Figure out which block is immediately after the current one.
MachineBasicBlock *NextBlock = 0;
@@ -429,7 +428,6 @@ void SelectionDAGLowering::visitBr(BranchInst &I) {
DAG.getBasicBlock(Succ0MBB)));
} else {
MachineBasicBlock *Succ1MBB = FuncInfo.MBBMap[I.getSuccessor(1)];
- CurMBB->addSuccessor(Succ1MBB);
SDOperand Cond = getValue(I.getCondition());
@@ -893,7 +891,8 @@ LowerArguments(BasicBlock *BB, SelectionDAGLowering &SDL,
// anything special.
if (OldRoot != SDL.DAG.getRoot()) {
unsigned a = 0;
- for (Function::arg_iterator AI = F.arg_begin(), E = F.arg_end(); AI != E; ++AI,++a)
+ for (Function::arg_iterator AI = F.arg_begin(), E = F.arg_end();
+ AI != E; ++AI,++a)
if (!AI->use_empty()) {
SDL.setValue(AI, Args[a]);
SDOperand Copy =
@@ -904,7 +903,8 @@ LowerArguments(BasicBlock *BB, SelectionDAGLowering &SDL,
// Otherwise, if any argument is only accessed in a single basic block,
// emit that argument only to that basic block.
unsigned a = 0;
- for (Function::arg_iterator AI = F.arg_begin(), E = F.arg_end(); AI != E; ++AI,++a)
+ for (Function::arg_iterator AI = F.arg_begin(), E = F.arg_end();
+ AI != E; ++AI,++a)
if (!AI->use_empty()) {
if (BasicBlock *BBU = IsOnlyUsedInOneBasicBlock(AI)) {
FuncInfo.BlockLocalArguments.insert(std::make_pair(BBU,
@@ -1058,8 +1058,8 @@ void SelectionDAGISel::SelectBasicBlock(BasicBlock *LLVMBB, MachineFunction &MF,
DEBUG(std::cerr << "Legalized selection DAG:\n");
DEBUG(DAG.dump());
- // Finally, instruction select all of the operations to machine code, adding
- // the code to the MachineBasicBlock.
+ // Third, instruction select all of the operations to machine code, adding the
+ // code to the MachineBasicBlock.
InstructionSelectBasicBlock(DAG);
if (ViewDAGs) DAG.viewGraph();
@@ -1067,7 +1067,7 @@ void SelectionDAGISel::SelectBasicBlock(BasicBlock *LLVMBB, MachineFunction &MF,
DEBUG(std::cerr << "Selected machine code:\n");
DEBUG(BB->dump());
- // Finally, now that we know what the last MBB the LLVM BB expanded is, update
+ // Next, now that we know what the last MBB the LLVM BB expanded is, update
// PHI nodes in successors.
for (unsigned i = 0, e = PHINodesToUpdate.size(); i != e; ++i) {
MachineInstr *PHI = PHINodesToUpdate[i].first;
@@ -1076,4 +1076,12 @@ void SelectionDAGISel::SelectBasicBlock(BasicBlock *LLVMBB, MachineFunction &MF,
PHI->addRegOperand(PHINodesToUpdate[i].second);
PHI->addMachineBasicBlockOperand(BB);
}
+
+ // Finally, add the CFG edges from the last selected MBB to the successor
+ // MBBs.
+ TerminatorInst *TI = LLVMBB->getTerminator();
+ for (unsigned i = 0, e = TI->getNumSuccessors(); i != e; ++i) {
+ MachineBasicBlock *Succ0MBB = FuncInfo.MBBMap[TI->getSuccessor(i)];
+ BB->addSuccessor(Succ0MBB);
+ }
}