mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-12 01:25:49 +00:00
When inserting copies during splitting, always use the parent register as the
source, and let rewrite() clean it up. This way, kill flags on the inserted copies are fixed as well during rewrite(). We can't just assume that all the copies we insert are going to be kills since critical edges into loop headers sometimes require both source and dest to be live out of a block. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@117980 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -659,13 +659,13 @@ void LiveIntervalMap::addRange(SlotIndex Start, SlotIndex End) {
|
|||||||
addSimpleRange(I->start, std::min(End, I->end), I->valno);
|
addSimpleRange(I->start, std::min(End, I->end), I->valno);
|
||||||
}
|
}
|
||||||
|
|
||||||
VNInfo *LiveIntervalMap::defByCopyFrom(unsigned Reg,
|
VNInfo *LiveIntervalMap::defByCopy(const VNInfo *ParentVNI,
|
||||||
const VNInfo *ParentVNI,
|
MachineBasicBlock &MBB,
|
||||||
MachineBasicBlock &MBB,
|
MachineBasicBlock::iterator I) {
|
||||||
MachineBasicBlock::iterator I) {
|
|
||||||
const TargetInstrDesc &TID = MBB.getParent()->getTarget().getInstrInfo()->
|
const TargetInstrDesc &TID = MBB.getParent()->getTarget().getInstrInfo()->
|
||||||
get(TargetOpcode::COPY);
|
get(TargetOpcode::COPY);
|
||||||
MachineInstr *MI = BuildMI(MBB, I, DebugLoc(), TID, li_->reg).addReg(Reg);
|
MachineInstr *MI = BuildMI(MBB, I, DebugLoc(), TID, li_->reg)
|
||||||
|
.addReg(parentli_.reg);
|
||||||
SlotIndex DefIdx = lis_.InsertMachineInstrInMaps(MI).getDefIndex();
|
SlotIndex DefIdx = lis_.InsertMachineInstrInMaps(MI).getDefIndex();
|
||||||
VNInfo *VNI = defValue(ParentVNI, DefIdx);
|
VNInfo *VNI = defValue(ParentVNI, DefIdx);
|
||||||
VNI->setCopy(MI);
|
VNI->setCopy(MI);
|
||||||
@@ -723,8 +723,7 @@ void SplitEditor::enterIntvBefore(SlotIndex Idx) {
|
|||||||
truncatedValues.insert(ParentVNI);
|
truncatedValues.insert(ParentVNI);
|
||||||
MachineInstr *MI = lis_.getInstructionFromIndex(Idx);
|
MachineInstr *MI = lis_.getInstructionFromIndex(Idx);
|
||||||
assert(MI && "enterIntvBefore called with invalid index");
|
assert(MI && "enterIntvBefore called with invalid index");
|
||||||
VNInfo *VNI = openli_.defByCopyFrom(edit_.getReg(), ParentVNI,
|
VNInfo *VNI = openli_.defByCopy(ParentVNI, *MI->getParent(), MI);
|
||||||
*MI->getParent(), MI);
|
|
||||||
openli_.getLI()->addRange(LiveRange(VNI->def, Idx.getDefIndex(), VNI));
|
openli_.getLI()->addRange(LiveRange(VNI->def, Idx.getDefIndex(), VNI));
|
||||||
DEBUG(dbgs() << ": " << *openli_.getLI() << '\n');
|
DEBUG(dbgs() << ": " << *openli_.getLI() << '\n');
|
||||||
}
|
}
|
||||||
@@ -741,8 +740,7 @@ void SplitEditor::enterIntvAtEnd(MachineBasicBlock &MBB) {
|
|||||||
}
|
}
|
||||||
DEBUG(dbgs() << ": valno " << ParentVNI->id);
|
DEBUG(dbgs() << ": valno " << ParentVNI->id);
|
||||||
truncatedValues.insert(ParentVNI);
|
truncatedValues.insert(ParentVNI);
|
||||||
VNInfo *VNI = openli_.defByCopyFrom(edit_.getReg(), ParentVNI,
|
VNInfo *VNI = openli_.defByCopy(ParentVNI, MBB, MBB.getFirstTerminator());
|
||||||
MBB, MBB.getFirstTerminator());
|
|
||||||
// Make sure openli is live out of MBB.
|
// Make sure openli is live out of MBB.
|
||||||
openli_.getLI()->addRange(LiveRange(VNI->def, End, VNI));
|
openli_.getLI()->addRange(LiveRange(VNI->def, End, VNI));
|
||||||
DEBUG(dbgs() << ": " << *openli_.getLI() << '\n');
|
DEBUG(dbgs() << ": " << *openli_.getLI() << '\n');
|
||||||
@@ -775,8 +773,7 @@ void SplitEditor::leaveIntvAfter(SlotIndex Idx) {
|
|||||||
|
|
||||||
MachineBasicBlock::iterator MII = lis_.getInstructionFromIndex(Idx);
|
MachineBasicBlock::iterator MII = lis_.getInstructionFromIndex(Idx);
|
||||||
MachineBasicBlock *MBB = MII->getParent();
|
MachineBasicBlock *MBB = MII->getParent();
|
||||||
VNInfo *VNI = dupli_.defByCopyFrom(openli_.getLI()->reg, ParentVNI, *MBB,
|
VNInfo *VNI = dupli_.defByCopy(ParentVNI, *MBB, llvm::next(MII));
|
||||||
llvm::next(MII));
|
|
||||||
|
|
||||||
// Finally we must make sure that openli is properly extended from Idx to the
|
// Finally we must make sure that openli is properly extended from Idx to the
|
||||||
// new copy.
|
// new copy.
|
||||||
@@ -798,8 +795,8 @@ void SplitEditor::leaveIntvAtTop(MachineBasicBlock &MBB) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// We are going to insert a back copy, so we must have a dupli_.
|
// We are going to insert a back copy, so we must have a dupli_.
|
||||||
VNInfo *VNI = dupli_.defByCopyFrom(openli_.getLI()->reg, ParentVNI,
|
VNInfo *VNI = dupli_.defByCopy(ParentVNI, MBB,
|
||||||
MBB, MBB.SkipPHIsAndLabels(MBB.begin()));
|
MBB.SkipPHIsAndLabels(MBB.begin()));
|
||||||
|
|
||||||
// Finally we must make sure that openli is properly extended from Start to
|
// Finally we must make sure that openli is properly extended from Start to
|
||||||
// the new copy.
|
// the new copy.
|
||||||
|
@@ -246,12 +246,12 @@ public:
|
|||||||
/// beforehand so mapValue will work.
|
/// beforehand so mapValue will work.
|
||||||
void addRange(SlotIndex Start, SlotIndex End);
|
void addRange(SlotIndex Start, SlotIndex End);
|
||||||
|
|
||||||
/// defByCopyFrom - Insert a copy from Reg to li, assuming that Reg carries
|
/// defByCopy- Insert a copy from parentli to li, assuming that ParentVNI is
|
||||||
/// ParentVNI. Add a minimal live range for the new value and return it.
|
/// live at the insert location. Add a minimal live range for the new value
|
||||||
VNInfo *defByCopyFrom(unsigned Reg,
|
/// and return it.
|
||||||
const VNInfo *ParentVNI,
|
VNInfo *defByCopy(const VNInfo *ParentVNI,
|
||||||
MachineBasicBlock &MBB,
|
MachineBasicBlock &MBB,
|
||||||
MachineBasicBlock::iterator I);
|
MachineBasicBlock::iterator I);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user