mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-11 10:25:41 +00:00
Make LiveVariables an instance variable of PHIElimination.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174828 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -42,6 +42,7 @@ DisableEdgeSplitting("disable-phi-elim-edge-splitting", cl::init(false),
|
|||||||
namespace {
|
namespace {
|
||||||
class PHIElimination : public MachineFunctionPass {
|
class PHIElimination : public MachineFunctionPass {
|
||||||
MachineRegisterInfo *MRI; // Machine register information
|
MachineRegisterInfo *MRI; // Machine register information
|
||||||
|
LiveVariables *LV;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static char ID; // Pass identification, replacement for typeid
|
static char ID; // Pass identification, replacement for typeid
|
||||||
@@ -70,7 +71,7 @@ namespace {
|
|||||||
|
|
||||||
/// Split critical edges where necessary for good coalescer performance.
|
/// Split critical edges where necessary for good coalescer performance.
|
||||||
bool SplitPHIEdges(MachineFunction &MF, MachineBasicBlock &MBB,
|
bool SplitPHIEdges(MachineFunction &MF, MachineBasicBlock &MBB,
|
||||||
LiveVariables &LV, MachineLoopInfo *MLI);
|
MachineLoopInfo *MLI);
|
||||||
|
|
||||||
typedef std::pair<unsigned, unsigned> BBVRegPair;
|
typedef std::pair<unsigned, unsigned> BBVRegPair;
|
||||||
typedef DenseMap<BBVRegPair, unsigned> VRegPHIUse;
|
typedef DenseMap<BBVRegPair, unsigned> VRegPHIUse;
|
||||||
@@ -110,6 +111,7 @@ void PHIElimination::getAnalysisUsage(AnalysisUsage &AU) const {
|
|||||||
|
|
||||||
bool PHIElimination::runOnMachineFunction(MachineFunction &MF) {
|
bool PHIElimination::runOnMachineFunction(MachineFunction &MF) {
|
||||||
MRI = &MF.getRegInfo();
|
MRI = &MF.getRegInfo();
|
||||||
|
LV = getAnalysisIfAvailable<LiveVariables>();
|
||||||
|
|
||||||
bool Changed = false;
|
bool Changed = false;
|
||||||
|
|
||||||
@@ -117,12 +119,10 @@ bool PHIElimination::runOnMachineFunction(MachineFunction &MF) {
|
|||||||
MRI->leaveSSA();
|
MRI->leaveSSA();
|
||||||
|
|
||||||
// Split critical edges to help the coalescer
|
// Split critical edges to help the coalescer
|
||||||
if (!DisableEdgeSplitting) {
|
if (!DisableEdgeSplitting && LV) {
|
||||||
if (LiveVariables *LV = getAnalysisIfAvailable<LiveVariables>()) {
|
MachineLoopInfo *MLI = getAnalysisIfAvailable<MachineLoopInfo>();
|
||||||
MachineLoopInfo *MLI = getAnalysisIfAvailable<MachineLoopInfo>();
|
for (MachineFunction::iterator I = MF.begin(), E = MF.end(); I != E; ++I)
|
||||||
for (MachineFunction::iterator I = MF.begin(), E = MF.end(); I != E; ++I)
|
Changed |= SplitPHIEdges(MF, *I, MLI);
|
||||||
Changed |= SplitPHIEdges(MF, *I, *LV, MLI);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Populate VRegPHIUseCount
|
// Populate VRegPHIUseCount
|
||||||
@@ -244,7 +244,6 @@ void PHIElimination::LowerAtomicPHINode(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update live variable information if there is any.
|
// Update live variable information if there is any.
|
||||||
LiveVariables *LV = getAnalysisIfAvailable<LiveVariables>();
|
|
||||||
if (LV) {
|
if (LV) {
|
||||||
MachineInstr *PHICopy = prior(AfterPHIsIt);
|
MachineInstr *PHICopy = prior(AfterPHIsIt);
|
||||||
|
|
||||||
@@ -418,7 +417,6 @@ void PHIElimination::analyzePHINodes(const MachineFunction& MF) {
|
|||||||
|
|
||||||
bool PHIElimination::SplitPHIEdges(MachineFunction &MF,
|
bool PHIElimination::SplitPHIEdges(MachineFunction &MF,
|
||||||
MachineBasicBlock &MBB,
|
MachineBasicBlock &MBB,
|
||||||
LiveVariables &LV,
|
|
||||||
MachineLoopInfo *MLI) {
|
MachineLoopInfo *MLI) {
|
||||||
if (MBB.empty() || !MBB.front().isPHI() || MBB.isLandingPad())
|
if (MBB.empty() || !MBB.front().isPHI() || MBB.isLandingPad())
|
||||||
return false; // Quick exit for basic blocks without PHIs.
|
return false; // Quick exit for basic blocks without PHIs.
|
||||||
@@ -450,7 +448,7 @@ bool PHIElimination::SplitPHIEdges(MachineFunction &MF,
|
|||||||
// there is a risk it may not be coalesced away.
|
// there is a risk it may not be coalesced away.
|
||||||
//
|
//
|
||||||
// If the copy would be a kill, there is no need to split the edge.
|
// If the copy would be a kill, there is no need to split the edge.
|
||||||
if (!LV.isLiveOut(Reg, *PreMBB))
|
if (!LV->isLiveOut(Reg, *PreMBB))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
DEBUG(dbgs() << PrintReg(Reg) << " live-out before critical edge BB#"
|
DEBUG(dbgs() << PrintReg(Reg) << " live-out before critical edge BB#"
|
||||||
@@ -465,7 +463,7 @@ bool PHIElimination::SplitPHIEdges(MachineFunction &MF,
|
|||||||
// is likely to be left after coalescing. If we are looking at a loop
|
// is likely to be left after coalescing. If we are looking at a loop
|
||||||
// exiting edge, split it so we won't insert code in the loop, otherwise
|
// exiting edge, split it so we won't insert code in the loop, otherwise
|
||||||
// don't bother.
|
// don't bother.
|
||||||
bool ShouldSplit = !LV.isLiveIn(Reg, MBB);
|
bool ShouldSplit = !LV->isLiveIn(Reg, MBB);
|
||||||
|
|
||||||
// Check for a loop exiting edge.
|
// Check for a loop exiting edge.
|
||||||
if (!ShouldSplit && CurLoop != PreLoop) {
|
if (!ShouldSplit && CurLoop != PreLoop) {
|
||||||
|
Reference in New Issue
Block a user