mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-07 12:28:24 +00:00
Refactor LiveRangeEdit::eliminateDeadDefs.
I want to add logic to handle more cases. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184571 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
#define LLVM_CODEGEN_LIVERANGEEDIT_H
|
||||
|
||||
#include "llvm/ADT/ArrayRef.h"
|
||||
#include "llvm/ADT/SetVector.h"
|
||||
#include "llvm/ADT/SmallPtrSet.h"
|
||||
#include "llvm/CodeGen/LiveInterval.h"
|
||||
#include "llvm/Target/TargetMachine.h"
|
||||
@@ -90,6 +91,12 @@ private:
|
||||
/// a load, eliminate the register by folding the def into the use.
|
||||
bool foldAsLoad(LiveInterval *LI, SmallVectorImpl<MachineInstr*> &Dead);
|
||||
|
||||
typedef SetVector<LiveInterval*,
|
||||
SmallVector<LiveInterval*, 8>,
|
||||
SmallPtrSet<LiveInterval*, 8> > ToShrinkSet;
|
||||
/// Helper for eliminateDeadDefs.
|
||||
void eliminateDeadDef(MachineInstr *MI, ToShrinkSet &ToShrink);
|
||||
|
||||
public:
|
||||
/// Create a LiveRangeEdit for breaking down parent into smaller pieces.
|
||||
/// @param parent The register being spilled or split.
|
||||
|
@@ -13,7 +13,6 @@
|
||||
|
||||
#define DEBUG_TYPE "regalloc"
|
||||
#include "llvm/CodeGen/LiveRangeEdit.h"
|
||||
#include "llvm/ADT/SetVector.h"
|
||||
#include "llvm/ADT/Statistic.h"
|
||||
#include "llvm/CodeGen/CalcSpillWeights.h"
|
||||
#include "llvm/CodeGen/LiveIntervalAnalysis.h"
|
||||
@@ -216,30 +215,22 @@ bool LiveRangeEdit::foldAsLoad(LiveInterval *LI,
|
||||
return true;
|
||||
}
|
||||
|
||||
void LiveRangeEdit::eliminateDeadDefs(SmallVectorImpl<MachineInstr*> &Dead,
|
||||
ArrayRef<unsigned> RegsBeingSpilled) {
|
||||
SetVector<LiveInterval*,
|
||||
SmallVector<LiveInterval*, 8>,
|
||||
SmallPtrSet<LiveInterval*, 8> > ToShrink;
|
||||
|
||||
for (;;) {
|
||||
// Erase all dead defs.
|
||||
while (!Dead.empty()) {
|
||||
MachineInstr *MI = Dead.pop_back_val();
|
||||
/// Find all live intervals that need to shrink, then remove the instruction.
|
||||
void LiveRangeEdit::eliminateDeadDef(MachineInstr *MI, ToShrinkSet &ToShrink) {
|
||||
assert(MI->allDefsAreDead() && "Def isn't really dead");
|
||||
SlotIndex Idx = LIS.getInstructionIndex(MI).getRegSlot();
|
||||
|
||||
// Never delete inline asm.
|
||||
if (MI->isInlineAsm()) {
|
||||
DEBUG(dbgs() << "Won't delete: " << Idx << '\t' << *MI);
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
|
||||
// Use the same criteria as DeadMachineInstructionElim.
|
||||
bool SawStore = false;
|
||||
if (!MI->isSafeToMove(&TII, 0, SawStore)) {
|
||||
DEBUG(dbgs() << "Can't delete: " << Idx << '\t' << *MI);
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
|
||||
DEBUG(dbgs() << "Deleting dead def " << Idx << '\t' << *MI);
|
||||
@@ -317,7 +308,16 @@ void LiveRangeEdit::eliminateDeadDefs(SmallVectorImpl<MachineInstr*> &Dead,
|
||||
eraseVirtReg(Reg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LiveRangeEdit::eliminateDeadDefs(SmallVectorImpl<MachineInstr*> &Dead,
|
||||
ArrayRef<unsigned> RegsBeingSpilled) {
|
||||
ToShrinkSet ToShrink;
|
||||
|
||||
for (;;) {
|
||||
// Erase all dead defs.
|
||||
while (!Dead.empty())
|
||||
eliminateDeadDef(Dead.pop_back_val(), ToShrink);
|
||||
|
||||
if (ToShrink.empty())
|
||||
break;
|
||||
|
Reference in New Issue
Block a user