forked from OSchip/llvm-project
Fix a FastISel bug where the instructions from lowering the arguments
were being emitted after the first instructions of the entry block. llvm-svn: 55496
This commit is contained in:
parent
0ac012835f
commit
360c57f683
|
@ -110,8 +110,7 @@ private:
|
||||||
|
|
||||||
void SelectBasicBlock(BasicBlock *LLVMBB,
|
void SelectBasicBlock(BasicBlock *LLVMBB,
|
||||||
BasicBlock::iterator Begin,
|
BasicBlock::iterator Begin,
|
||||||
BasicBlock::iterator End,
|
BasicBlock::iterator End);
|
||||||
bool DoArgs);
|
|
||||||
void CodeGenAndEmitDAG();
|
void CodeGenAndEmitDAG();
|
||||||
void LowerArguments(BasicBlock *BB);
|
void LowerArguments(BasicBlock *BB);
|
||||||
|
|
||||||
|
|
|
@ -5479,12 +5479,7 @@ SelectionDAGISel::HandlePHINodesInSuccessorBlocks(BasicBlock *LLVMBB) {
|
||||||
|
|
||||||
void SelectionDAGISel::SelectBasicBlock(BasicBlock *LLVMBB,
|
void SelectionDAGISel::SelectBasicBlock(BasicBlock *LLVMBB,
|
||||||
BasicBlock::iterator Begin,
|
BasicBlock::iterator Begin,
|
||||||
BasicBlock::iterator End,
|
BasicBlock::iterator End) {
|
||||||
bool DoArgs) {
|
|
||||||
// Lower any arguments needed in this block if this is the entry block.
|
|
||||||
if (DoArgs)
|
|
||||||
LowerArguments(LLVMBB);
|
|
||||||
|
|
||||||
SDL->setCurrentBasicBlock(BB);
|
SDL->setCurrentBasicBlock(BB);
|
||||||
|
|
||||||
MachineModuleInfo *MMI = CurDAG->getMachineModuleInfo();
|
MachineModuleInfo *MMI = CurDAG->getMachineModuleInfo();
|
||||||
|
@ -5744,12 +5739,23 @@ void SelectionDAGISel::SelectAllBasicBlocks(Function &Fn, MachineFunction &MF) {
|
||||||
|
|
||||||
BasicBlock::iterator Begin = LLVMBB->begin();
|
BasicBlock::iterator Begin = LLVMBB->begin();
|
||||||
BasicBlock::iterator End = LLVMBB->end();
|
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.
|
// Before doing SelectionDAG ISel, see if FastISel has been requested.
|
||||||
// FastISel doesn't support EH landing pads, which require special handling.
|
// FastISel doesn't support EH landing pads, which require special handling.
|
||||||
if (EnableFastISel && !BB->isLandingPad()) {
|
if (EnableFastISel && !BB->isLandingPad()) {
|
||||||
if (FastISel *F = TLI.createFastISel(*FuncInfo->MF)) {
|
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) {
|
while (Begin != End) {
|
||||||
Begin = F->SelectInstructions(Begin, End, FuncInfo->ValueMap,
|
Begin = F->SelectInstructions(Begin, End, FuncInfo->ValueMap,
|
||||||
FuncInfo->MBBMap, BB);
|
FuncInfo->MBBMap, BB);
|
||||||
|
@ -5767,10 +5773,8 @@ void SelectionDAGISel::SelectAllBasicBlocks(Function &Fn, MachineFunction &MF) {
|
||||||
R = FuncInfo->CreateRegForValue(Begin);
|
R = FuncInfo->CreateRegForValue(Begin);
|
||||||
}
|
}
|
||||||
|
|
||||||
SelectBasicBlock(LLVMBB, Begin, next(Begin), DoArgs);
|
SelectBasicBlock(LLVMBB, Begin, next(Begin));
|
||||||
|
|
||||||
++Begin;
|
++Begin;
|
||||||
DoArgs = false;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5792,8 +5796,8 @@ void SelectionDAGISel::SelectAllBasicBlocks(Function &Fn, MachineFunction &MF) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Begin != End || DoArgs)
|
if (Begin != End)
|
||||||
SelectBasicBlock(LLVMBB, Begin, End, DoArgs);
|
SelectBasicBlock(LLVMBB, Begin, End);
|
||||||
|
|
||||||
FinishBasicBlock();
|
FinishBasicBlock();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue