summaryrefslogtreecommitdiff
path: root/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2008-08-28 20:28:56 +0000
committerDan Gohman <gohman@apple.com>2008-08-28 20:28:56 +0000
commit5edd361497f4c78a20fcbb75c6e7e94ff8046ed1 (patch)
tree79564f08d17b47da84c6833241831e02433547b7 /lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
parent833a990c26d2f3346371110f1ace3d64a8b342f8 (diff)
downloadllvm-5edd361497f4c78a20fcbb75c6e7e94ff8046ed1.tar.gz
llvm-5edd361497f4c78a20fcbb75c6e7e94ff8046ed1.tar.bz2
llvm-5edd361497f4c78a20fcbb75c6e7e94ff8046ed1.tar.xz
Fix a FastISel bug where the instructions from lowering the arguments
were being emitted after the first instructions of the entry block. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55496 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp')
-rw-r--r--lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp28
1 files changed, 16 insertions, 12 deletions
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
index 2f43222760..6211b5e592 100644
--- a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
+++ b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
@@ -5479,12 +5479,7 @@ SelectionDAGISel::HandlePHINodesInSuccessorBlocks(BasicBlock *LLVMBB) {
void SelectionDAGISel::SelectBasicBlock(BasicBlock *LLVMBB,
BasicBlock::iterator Begin,
- BasicBlock::iterator End,
- bool DoArgs) {
- // Lower any arguments needed in this block if this is the entry block.
- if (DoArgs)
- LowerArguments(LLVMBB);
-
+ BasicBlock::iterator End) {
SDL->setCurrentBasicBlock(BB);
MachineModuleInfo *MMI = CurDAG->getMachineModuleInfo();
@@ -5744,12 +5739,23 @@ void SelectionDAGISel::SelectAllBasicBlocks(Function &Fn, MachineFunction &MF) {
BasicBlock::iterator Begin = LLVMBB->begin();
BasicBlock::iterator End = LLVMBB->end();
- bool DoArgs = LLVMBB == &Fn.getEntryBlock();
+
+ // Lower any arguments needed in this block if this is the entry block.
+ if (LLVMBB == &Fn.getEntryBlock())
+ LowerArguments(LLVMBB);
// Before doing SelectionDAG ISel, see if FastISel has been requested.
// FastISel doesn't support EH landing pads, which require special handling.
if (EnableFastISel && !BB->isLandingPad()) {
if (FastISel *F = TLI.createFastISel(*FuncInfo->MF)) {
+ // Emit code for any incoming arguments. This must happen before
+ // beginning FastISel on the entry block.
+ if (LLVMBB == &Fn.getEntryBlock()) {
+ CurDAG->setRoot(SDL->getControlRoot());
+ CodeGenAndEmitDAG();
+ SDL->clear();
+ }
+ // Do FastISel on as many instructions as possible.
while (Begin != End) {
Begin = F->SelectInstructions(Begin, End, FuncInfo->ValueMap,
FuncInfo->MBBMap, BB);
@@ -5767,10 +5773,8 @@ void SelectionDAGISel::SelectAllBasicBlocks(Function &Fn, MachineFunction &MF) {
R = FuncInfo->CreateRegForValue(Begin);
}
- SelectBasicBlock(LLVMBB, Begin, next(Begin), DoArgs);
-
+ SelectBasicBlock(LLVMBB, Begin, next(Begin));
++Begin;
- DoArgs = false;
continue;
}
@@ -5792,8 +5796,8 @@ void SelectionDAGISel::SelectAllBasicBlocks(Function &Fn, MachineFunction &MF) {
}
}
- if (Begin != End || DoArgs)
- SelectBasicBlock(LLVMBB, Begin, End, DoArgs);
+ if (Begin != End)
+ SelectBasicBlock(LLVMBB, Begin, End);
FinishBasicBlock();
}