mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-12 17:32:19 +00:00
Make the spiller responsible for updating the LiveStacks analysis.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@117337 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
7c730e7790
commit
2d17293dd0
@ -66,6 +66,9 @@ namespace llvm {
|
|||||||
|
|
||||||
extern char &PreAllocSplittingID;
|
extern char &PreAllocSplittingID;
|
||||||
|
|
||||||
|
/// LiveStacks pass. An analysis keeping track of the liveness of stack slots.
|
||||||
|
extern char &LiveStacksID;
|
||||||
|
|
||||||
/// SimpleRegisterCoalescing pass. Aggressively coalesces every register
|
/// SimpleRegisterCoalescing pass. Aggressively coalesces every register
|
||||||
/// copy it can.
|
/// copy it can.
|
||||||
///
|
///
|
||||||
|
@ -28,6 +28,8 @@ char LiveStacks::ID = 0;
|
|||||||
INITIALIZE_PASS(LiveStacks, "livestacks",
|
INITIALIZE_PASS(LiveStacks, "livestacks",
|
||||||
"Live Stack Slot Analysis", false, false)
|
"Live Stack Slot Analysis", false, false)
|
||||||
|
|
||||||
|
char &llvm::LiveStacksID = LiveStacks::ID;
|
||||||
|
|
||||||
void LiveStacks::getAnalysisUsage(AnalysisUsage &AU) const {
|
void LiveStacks::getAnalysisUsage(AnalysisUsage &AU) const {
|
||||||
AU.setPreservesAll();
|
AU.setPreservesAll();
|
||||||
AU.addPreserved<SlotIndexes>();
|
AU.addPreserved<SlotIndexes>();
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
#include "llvm/Function.h"
|
#include "llvm/Function.h"
|
||||||
#include "llvm/CodeGen/CalcSpillWeights.h"
|
#include "llvm/CodeGen/CalcSpillWeights.h"
|
||||||
#include "llvm/CodeGen/LiveIntervalAnalysis.h"
|
#include "llvm/CodeGen/LiveIntervalAnalysis.h"
|
||||||
#include "llvm/CodeGen/LiveStackAnalysis.h"
|
|
||||||
#include "llvm/CodeGen/MachineFunctionPass.h"
|
#include "llvm/CodeGen/MachineFunctionPass.h"
|
||||||
#include "llvm/CodeGen/MachineInstr.h"
|
#include "llvm/CodeGen/MachineInstr.h"
|
||||||
#include "llvm/CodeGen/MachineLoopInfo.h"
|
#include "llvm/CodeGen/MachineLoopInfo.h"
|
||||||
@ -138,7 +137,6 @@ namespace {
|
|||||||
BitVector allocatableRegs_;
|
BitVector allocatableRegs_;
|
||||||
BitVector reservedRegs_;
|
BitVector reservedRegs_;
|
||||||
LiveIntervals* li_;
|
LiveIntervals* li_;
|
||||||
LiveStacks* ls_;
|
|
||||||
MachineLoopInfo *loopInfo;
|
MachineLoopInfo *loopInfo;
|
||||||
|
|
||||||
/// handled_ - Intervals are added to the handled_ set in the order of their
|
/// handled_ - Intervals are added to the handled_ set in the order of their
|
||||||
@ -204,8 +202,8 @@ namespace {
|
|||||||
AU.addRequired<CalculateSpillWeights>();
|
AU.addRequired<CalculateSpillWeights>();
|
||||||
if (PreSplitIntervals)
|
if (PreSplitIntervals)
|
||||||
AU.addRequiredID(PreAllocSplittingID);
|
AU.addRequiredID(PreAllocSplittingID);
|
||||||
AU.addRequired<LiveStacks>();
|
AU.addRequiredID(LiveStacksID);
|
||||||
AU.addPreserved<LiveStacks>();
|
AU.addPreservedID(LiveStacksID);
|
||||||
AU.addRequired<MachineLoopInfo>();
|
AU.addRequired<MachineLoopInfo>();
|
||||||
AU.addPreserved<MachineLoopInfo>();
|
AU.addPreserved<MachineLoopInfo>();
|
||||||
AU.addRequired<VirtRegMap>();
|
AU.addRequired<VirtRegMap>();
|
||||||
@ -498,7 +496,6 @@ bool RALinScan::runOnMachineFunction(MachineFunction &fn) {
|
|||||||
allocatableRegs_ = tri_->getAllocatableSet(fn);
|
allocatableRegs_ = tri_->getAllocatableSet(fn);
|
||||||
reservedRegs_ = tri_->getReservedRegs(fn);
|
reservedRegs_ = tri_->getReservedRegs(fn);
|
||||||
li_ = &getAnalysis<LiveIntervals>();
|
li_ = &getAnalysis<LiveIntervals>();
|
||||||
ls_ = &getAnalysis<LiveStacks>();
|
|
||||||
loopInfo = &getAnalysis<MachineLoopInfo>();
|
loopInfo = &getAnalysis<MachineLoopInfo>();
|
||||||
|
|
||||||
// We don't run the coalescer here because we have no reason to
|
// We don't run the coalescer here because we have no reason to
|
||||||
@ -658,8 +655,6 @@ void RALinScan::linearScan() {
|
|||||||
|
|
||||||
// Look for physical registers that end up not being allocated even though
|
// Look for physical registers that end up not being allocated even though
|
||||||
// register allocator had to spill other registers in its register class.
|
// register allocator had to spill other registers in its register class.
|
||||||
if (ls_->getNumIntervals() == 0)
|
|
||||||
return;
|
|
||||||
if (!vrm_->FindUnusedRegisters(li_))
|
if (!vrm_->FindUnusedRegisters(li_))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -804,30 +799,6 @@ static void RevertVectorIteratorsTo(RALinScan::IntervalPtrs &V,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// addStackInterval - Create a LiveInterval for stack if the specified live
|
|
||||||
/// interval has been spilled.
|
|
||||||
static void addStackInterval(LiveInterval *cur, LiveStacks *ls_,
|
|
||||||
LiveIntervals *li_,
|
|
||||||
MachineRegisterInfo* mri_, VirtRegMap &vrm_) {
|
|
||||||
int SS = vrm_.getStackSlot(cur->reg);
|
|
||||||
if (SS == VirtRegMap::NO_STACK_SLOT)
|
|
||||||
return;
|
|
||||||
|
|
||||||
const TargetRegisterClass *RC = mri_->getRegClass(cur->reg);
|
|
||||||
LiveInterval &SI = ls_->getOrCreateInterval(SS, RC);
|
|
||||||
|
|
||||||
VNInfo *VNI;
|
|
||||||
if (SI.hasAtLeastOneValue())
|
|
||||||
VNI = SI.getValNumInfo(0);
|
|
||||||
else
|
|
||||||
VNI = SI.getNextValue(SlotIndex(), 0,
|
|
||||||
ls_->getVNInfoAllocator());
|
|
||||||
|
|
||||||
LiveInterval &RI = li_->getInterval(cur->reg);
|
|
||||||
// FIXME: This may be overly conservative.
|
|
||||||
SI.MergeRangesInAsValue(RI, VNI);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// getConflictWeight - Return the number of conflicts between cur
|
/// getConflictWeight - Return the number of conflicts between cur
|
||||||
/// live interval and defs and uses of Reg weighted by loop depthes.
|
/// live interval and defs and uses of Reg weighted by loop depthes.
|
||||||
static
|
static
|
||||||
@ -1244,7 +1215,6 @@ void RALinScan::assignRegOrStackSlotAtInterval(LiveInterval* cur) {
|
|||||||
spiller_->spill(cur, added, spillIs);
|
spiller_->spill(cur, added, spillIs);
|
||||||
|
|
||||||
std::sort(added.begin(), added.end(), LISorter());
|
std::sort(added.begin(), added.end(), LISorter());
|
||||||
addStackInterval(cur, ls_, li_, mri_, *vrm_);
|
|
||||||
if (added.empty())
|
if (added.empty())
|
||||||
return; // Early exit if all spills were folded.
|
return; // Early exit if all spills were folded.
|
||||||
|
|
||||||
@ -1319,7 +1289,6 @@ void RALinScan::assignRegOrStackSlotAtInterval(LiveInterval* cur) {
|
|||||||
if (sli->beginIndex() < earliestStart)
|
if (sli->beginIndex() < earliestStart)
|
||||||
earliestStart = sli->beginIndex();
|
earliestStart = sli->beginIndex();
|
||||||
spiller_->spill(sli, added, spillIs);
|
spiller_->spill(sli, added, spillIs);
|
||||||
addStackInterval(sli, ls_, li_, mri_, *vrm_);
|
|
||||||
spilled.insert(sli->reg);
|
spilled.insert(sli->reg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#include "Spiller.h"
|
#include "Spiller.h"
|
||||||
#include "VirtRegMap.h"
|
#include "VirtRegMap.h"
|
||||||
#include "llvm/CodeGen/LiveIntervalAnalysis.h"
|
#include "llvm/CodeGen/LiveIntervalAnalysis.h"
|
||||||
|
#include "llvm/CodeGen/LiveStackAnalysis.h"
|
||||||
#include "llvm/CodeGen/MachineFrameInfo.h"
|
#include "llvm/CodeGen/MachineFrameInfo.h"
|
||||||
#include "llvm/CodeGen/MachineFunction.h"
|
#include "llvm/CodeGen/MachineFunction.h"
|
||||||
#include "llvm/CodeGen/MachineInstrBuilder.h"
|
#include "llvm/CodeGen/MachineInstrBuilder.h"
|
||||||
@ -195,13 +196,17 @@ namespace {
|
|||||||
/// Falls back on LiveIntervals::addIntervalsForSpills.
|
/// Falls back on LiveIntervals::addIntervalsForSpills.
|
||||||
class StandardSpiller : public Spiller {
|
class StandardSpiller : public Spiller {
|
||||||
protected:
|
protected:
|
||||||
|
MachineFunction *mf;
|
||||||
LiveIntervals *lis;
|
LiveIntervals *lis;
|
||||||
|
LiveStacks *lss;
|
||||||
MachineLoopInfo *loopInfo;
|
MachineLoopInfo *loopInfo;
|
||||||
VirtRegMap *vrm;
|
VirtRegMap *vrm;
|
||||||
public:
|
public:
|
||||||
StandardSpiller(MachineFunctionPass &pass, MachineFunction &mf,
|
StandardSpiller(MachineFunctionPass &pass, MachineFunction &mf,
|
||||||
VirtRegMap &vrm)
|
VirtRegMap &vrm)
|
||||||
: lis(&pass.getAnalysis<LiveIntervals>()),
|
: mf(&mf),
|
||||||
|
lis(&pass.getAnalysis<LiveIntervals>()),
|
||||||
|
lss(&pass.getAnalysis<LiveStacks>()),
|
||||||
loopInfo(pass.getAnalysisIfAvailable<MachineLoopInfo>()),
|
loopInfo(pass.getAnalysisIfAvailable<MachineLoopInfo>()),
|
||||||
vrm(&vrm) {}
|
vrm(&vrm) {}
|
||||||
|
|
||||||
@ -212,6 +217,16 @@ public:
|
|||||||
std::vector<LiveInterval*> added =
|
std::vector<LiveInterval*> added =
|
||||||
lis->addIntervalsForSpills(*li, spillIs, loopInfo, *vrm);
|
lis->addIntervalsForSpills(*li, spillIs, loopInfo, *vrm);
|
||||||
newIntervals.insert(newIntervals.end(), added.begin(), added.end());
|
newIntervals.insert(newIntervals.end(), added.begin(), added.end());
|
||||||
|
|
||||||
|
// Update LiveStacks.
|
||||||
|
int SS = vrm->getStackSlot(li->reg);
|
||||||
|
if (SS == VirtRegMap::NO_STACK_SLOT)
|
||||||
|
return;
|
||||||
|
const TargetRegisterClass *RC = mf->getRegInfo().getRegClass(li->reg);
|
||||||
|
LiveInterval &SI = lss->getOrCreateInterval(SS, RC);
|
||||||
|
if (!SI.hasAtLeastOneValue())
|
||||||
|
SI.getNextValue(SlotIndex(), 0, lss->getVNInfoAllocator());
|
||||||
|
SI.MergeRangesInAsValue(*li, SI.getValNumInfo(0));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user