mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-17 05:29:24 +00:00
Fix FastISel to not initialize the PIC-base register multiple times
in functions with PIC references from more than one basic block. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@56807 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
7962e856d1
commit
a43abd102f
@ -60,6 +60,7 @@ public:
|
|||||||
///
|
///
|
||||||
void setCurrentBlock(MachineBasicBlock *mbb) {
|
void setCurrentBlock(MachineBasicBlock *mbb) {
|
||||||
MBB = mbb;
|
MBB = mbb;
|
||||||
|
LocalValueMap.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// SelectInstruction - Do "fast" instruction selection for the given
|
/// SelectInstruction - Do "fast" instruction selection for the given
|
||||||
|
@ -709,6 +709,15 @@ void SelectionDAGISel::CodeGenAndEmitDAG() {
|
|||||||
|
|
||||||
void SelectionDAGISel::SelectAllBasicBlocks(Function &Fn, MachineFunction &MF,
|
void SelectionDAGISel::SelectAllBasicBlocks(Function &Fn, MachineFunction &MF,
|
||||||
MachineModuleInfo *MMI) {
|
MachineModuleInfo *MMI) {
|
||||||
|
// Initialize the Fast-ISel state, if needed.
|
||||||
|
FastISel *FastIS = 0;
|
||||||
|
if (EnableFastISel)
|
||||||
|
FastIS = TLI.createFastISel(*FuncInfo->MF, MMI,
|
||||||
|
FuncInfo->ValueMap,
|
||||||
|
FuncInfo->MBBMap,
|
||||||
|
FuncInfo->StaticAllocaMap);
|
||||||
|
|
||||||
|
// Iterate over all basic blocks in the function.
|
||||||
for (Function::iterator I = Fn.begin(), E = Fn.end(); I != E; ++I) {
|
for (Function::iterator I = Fn.begin(), E = Fn.end(); I != E; ++I) {
|
||||||
BasicBlock *LLVMBB = &*I;
|
BasicBlock *LLVMBB = &*I;
|
||||||
BB = FuncInfo->MBBMap[LLVMBB];
|
BB = FuncInfo->MBBMap[LLVMBB];
|
||||||
@ -724,7 +733,7 @@ void SelectionDAGISel::SelectAllBasicBlocks(Function &Fn, MachineFunction &MF,
|
|||||||
|
|
||||||
// If any of the arguments has the byval attribute, forgo
|
// If any of the arguments has the byval attribute, forgo
|
||||||
// fast-isel in the entry block.
|
// fast-isel in the entry block.
|
||||||
if (EnableFastISel) {
|
if (FastIS) {
|
||||||
unsigned j = 1;
|
unsigned j = 1;
|
||||||
for (Function::arg_iterator I = Fn.arg_begin(), E = Fn.arg_end();
|
for (Function::arg_iterator I = Fn.arg_begin(), E = Fn.arg_end();
|
||||||
I != E; ++I, ++j)
|
I != E; ++I, ++j)
|
||||||
@ -739,11 +748,7 @@ void SelectionDAGISel::SelectAllBasicBlocks(Function &Fn, MachineFunction &MF,
|
|||||||
|
|
||||||
// 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 && !SuppressFastISel && !BB->isLandingPad()) {
|
if (FastIS && !SuppressFastISel && !BB->isLandingPad()) {
|
||||||
if (FastISel *F = TLI.createFastISel(*FuncInfo->MF, MMI,
|
|
||||||
FuncInfo->ValueMap,
|
|
||||||
FuncInfo->MBBMap,
|
|
||||||
FuncInfo->StaticAllocaMap)) {
|
|
||||||
// Emit code for any incoming arguments. This must happen before
|
// Emit code for any incoming arguments. This must happen before
|
||||||
// beginning FastISel on the entry block.
|
// beginning FastISel on the entry block.
|
||||||
if (LLVMBB == &Fn.getEntryBlock()) {
|
if (LLVMBB == &Fn.getEntryBlock()) {
|
||||||
@ -751,13 +756,13 @@ void SelectionDAGISel::SelectAllBasicBlocks(Function &Fn, MachineFunction &MF,
|
|||||||
CodeGenAndEmitDAG();
|
CodeGenAndEmitDAG();
|
||||||
SDL->clear();
|
SDL->clear();
|
||||||
}
|
}
|
||||||
F->setCurrentBlock(BB);
|
FastIS->setCurrentBlock(BB);
|
||||||
// Do FastISel on as many instructions as possible.
|
// Do FastISel on as many instructions as possible.
|
||||||
for (; BI != End; ++BI) {
|
for (; BI != End; ++BI) {
|
||||||
// Just before the terminator instruction, insert instructions to
|
// Just before the terminator instruction, insert instructions to
|
||||||
// feed PHI nodes in successor blocks.
|
// feed PHI nodes in successor blocks.
|
||||||
if (isa<TerminatorInst>(BI))
|
if (isa<TerminatorInst>(BI))
|
||||||
if (!HandlePHINodesInSuccessorBlocksFast(LLVMBB, F)) {
|
if (!HandlePHINodesInSuccessorBlocksFast(LLVMBB, FastIS)) {
|
||||||
if (EnableFastISelVerbose || EnableFastISelAbort) {
|
if (EnableFastISelVerbose || EnableFastISelAbort) {
|
||||||
cerr << "FastISel miss: ";
|
cerr << "FastISel miss: ";
|
||||||
BI->dump();
|
BI->dump();
|
||||||
@ -768,11 +773,11 @@ void SelectionDAGISel::SelectAllBasicBlocks(Function &Fn, MachineFunction &MF,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// First try normal tablegen-generated "fast" selection.
|
// First try normal tablegen-generated "fast" selection.
|
||||||
if (F->SelectInstruction(BI))
|
if (FastIS->SelectInstruction(BI))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Next, try calling the target to attempt to handle the instruction.
|
// Next, try calling the target to attempt to handle the instruction.
|
||||||
if (F->TargetSelectInstruction(BI))
|
if (FastIS->TargetSelectInstruction(BI))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Then handle certain instructions as single-LLVM-Instruction blocks.
|
// Then handle certain instructions as single-LLVM-Instruction blocks.
|
||||||
@ -806,8 +811,6 @@ void SelectionDAGISel::SelectAllBasicBlocks(Function &Fn, MachineFunction &MF,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
delete F;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run SelectionDAG instruction selection on the remainder of the block
|
// Run SelectionDAG instruction selection on the remainder of the block
|
||||||
@ -818,6 +821,8 @@ void SelectionDAGISel::SelectAllBasicBlocks(Function &Fn, MachineFunction &MF,
|
|||||||
|
|
||||||
FinishBasicBlock();
|
FinishBasicBlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delete FastIS;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Loading…
Reference in New Issue
Block a user