mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-01 00:33:09 +00:00
Fix the updating of the machine CFG when a PHI node was in a successor of
the jump table's range check block. This re-enables 100% dense jump tables by default on PPC & x86 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@27952 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
84bfed087b
commit
9453eea49b
@ -41,7 +41,7 @@ public:
|
|||||||
SelectionDAG *CurDAG;
|
SelectionDAG *CurDAG;
|
||||||
MachineBasicBlock *BB;
|
MachineBasicBlock *BB;
|
||||||
|
|
||||||
SelectionDAGISel(TargetLowering &tli) : TLI(tli), JT(0,0,0) {}
|
SelectionDAGISel(TargetLowering &tli) : TLI(tli), JT(0,0,0,0) {}
|
||||||
|
|
||||||
virtual void getAnalysisUsage(AnalysisUsage &AU) const;
|
virtual void getAnalysisUsage(AnalysisUsage &AU) const;
|
||||||
|
|
||||||
@ -89,8 +89,8 @@ public:
|
|||||||
MachineBasicBlock *ThisBB;
|
MachineBasicBlock *ThisBB;
|
||||||
};
|
};
|
||||||
struct JumpTable {
|
struct JumpTable {
|
||||||
JumpTable(unsigned R, unsigned J, MachineBasicBlock *me) : Reg(R), JTI(J),
|
JumpTable(unsigned R, unsigned J, MachineBasicBlock *M,
|
||||||
MBB(me) {}
|
MachineBasicBlock *D) : Reg(R), JTI(J), MBB(M), Default(D) {}
|
||||||
// Reg - the virtual register containing the index of the jump table entry
|
// Reg - the virtual register containing the index of the jump table entry
|
||||||
// to jump to.
|
// to jump to.
|
||||||
unsigned Reg;
|
unsigned Reg;
|
||||||
@ -98,6 +98,9 @@ public:
|
|||||||
unsigned JTI;
|
unsigned JTI;
|
||||||
// MBB - the MBB into which to emit the code for the indirect jump.
|
// MBB - the MBB into which to emit the code for the indirect jump.
|
||||||
MachineBasicBlock *MBB;
|
MachineBasicBlock *MBB;
|
||||||
|
// Default - the MBB of the default bb, which is a successor of the range
|
||||||
|
// check MBB. This is when updating PHI nodes in successors.
|
||||||
|
MachineBasicBlock *Default;
|
||||||
// SuccMBBs - a vector of unique successor MBBs used for updating CFG info
|
// SuccMBBs - a vector of unique successor MBBs used for updating CFG info
|
||||||
// and PHI nodes.
|
// and PHI nodes.
|
||||||
std::set<MachineBasicBlock*> SuccMBBs;
|
std::set<MachineBasicBlock*> SuccMBBs;
|
||||||
|
@ -408,7 +408,7 @@ public:
|
|||||||
SelectionDAGLowering(SelectionDAG &dag, TargetLowering &tli,
|
SelectionDAGLowering(SelectionDAG &dag, TargetLowering &tli,
|
||||||
FunctionLoweringInfo &funcinfo)
|
FunctionLoweringInfo &funcinfo)
|
||||||
: TLI(tli), DAG(dag), TD(DAG.getTarget().getTargetData()),
|
: TLI(tli), DAG(dag), TD(DAG.getTarget().getTargetData()),
|
||||||
JT(0,0,0), FuncInfo(funcinfo) {
|
JT(0,0,0,0), FuncInfo(funcinfo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// getRoot - Return the current virtual root of the Selection DAG.
|
/// getRoot - Return the current virtual root of the Selection DAG.
|
||||||
@ -891,7 +891,7 @@ void SelectionDAGLowering::visitSwitch(SwitchInst &I) {
|
|||||||
// FIXME: Make this work with 64 bit targets someday, possibly by always
|
// FIXME: Make this work with 64 bit targets someday, possibly by always
|
||||||
// doing differences there so that entries stay 32 bits.
|
// doing differences there so that entries stay 32 bits.
|
||||||
// FIXME: Make this work with PIC code
|
// FIXME: Make this work with PIC code
|
||||||
if (0 && TLI.isOperationLegal(ISD::BRIND, TLI.getPointerTy()) &&
|
if (TLI.isOperationLegal(ISD::BRIND, TLI.getPointerTy()) &&
|
||||||
TLI.getPointerTy() == MVT::i32 &&
|
TLI.getPointerTy() == MVT::i32 &&
|
||||||
(Relocs == Reloc::Static || Relocs == Reloc::DynamicNoPIC) &&
|
(Relocs == Reloc::Static || Relocs == Reloc::DynamicNoPIC) &&
|
||||||
Cases.size() > 3) {
|
Cases.size() > 3) {
|
||||||
@ -955,6 +955,7 @@ void SelectionDAGLowering::visitSwitch(SwitchInst &I) {
|
|||||||
JT.Reg = JumpTableReg;
|
JT.Reg = JumpTableReg;
|
||||||
JT.JTI = JTI;
|
JT.JTI = JTI;
|
||||||
JT.MBB = JumpTableBB;
|
JT.MBB = JumpTableBB;
|
||||||
|
JT.Default = Default;
|
||||||
JT.SuccMBBs = UniqueBBs;
|
JT.SuccMBBs = UniqueBBs;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -3190,12 +3191,15 @@ void SelectionDAGISel::SelectBasicBlock(BasicBlock *LLVMBB, MachineFunction &MF,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we need to emit a jump table,
|
// If the JumpTable record is filled in, then we need to emit a jump table.
|
||||||
|
// Updating the PHI nodes is tricky in this case, since we need to determine
|
||||||
|
// whether the PHI is a successor of the range check MBB or the jump table MBB
|
||||||
if (JT.Reg) {
|
if (JT.Reg) {
|
||||||
assert(SwitchCases.empty() && "Cannot have jump table and lowered switch");
|
assert(SwitchCases.empty() && "Cannot have jump table and lowered switch");
|
||||||
SelectionDAG SDAG(TLI, MF, getAnalysisToUpdate<MachineDebugInfo>());
|
SelectionDAG SDAG(TLI, MF, getAnalysisToUpdate<MachineDebugInfo>());
|
||||||
CurDAG = &SDAG;
|
CurDAG = &SDAG;
|
||||||
SelectionDAGLowering SDL(SDAG, TLI, FuncInfo);
|
SelectionDAGLowering SDL(SDAG, TLI, FuncInfo);
|
||||||
|
MachineBasicBlock *RangeBB = BB;
|
||||||
// Set the current basic block to the mbb we wish to insert the code into
|
// Set the current basic block to the mbb we wish to insert the code into
|
||||||
BB = JT.MBB;
|
BB = JT.MBB;
|
||||||
SDL.setCurrentBasicBlock(BB);
|
SDL.setCurrentBasicBlock(BB);
|
||||||
@ -3209,9 +3213,10 @@ void SelectionDAGISel::SelectBasicBlock(BasicBlock *LLVMBB, MachineFunction &MF,
|
|||||||
MachineBasicBlock *PHIBB = PHI->getParent();
|
MachineBasicBlock *PHIBB = PHI->getParent();
|
||||||
assert(PHI->getOpcode() == TargetInstrInfo::PHI &&
|
assert(PHI->getOpcode() == TargetInstrInfo::PHI &&
|
||||||
"This is not a machine PHI node that we are updating!");
|
"This is not a machine PHI node that we are updating!");
|
||||||
if (JT.SuccMBBs.find(PHIBB) != JT.SuccMBBs.end()) {
|
if (PHIBB == JT.Default || JT.SuccMBBs.find(PHIBB) != JT.SuccMBBs.end()) {
|
||||||
|
PHIBB = (PHIBB == JT.Default) ? RangeBB : BB;
|
||||||
PHI->addRegOperand(PHINodesToUpdate[pi].second);
|
PHI->addRegOperand(PHINodesToUpdate[pi].second);
|
||||||
PHI->addMachineBasicBlockOperand(BB);
|
PHI->addMachineBasicBlockOperand(PHIBB);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user