mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-11-01 15:17:25 +00:00
Don't require LiveVariables for PHIElimination. Enable critical edge splitting
when LiveVariables is available. The -split-phi-edges is now gone, and so is the hack to disable it when using the local register allocator. The PHIElimination pass no longer has LiveVariables as a prerequisite - that is what broke the local allocator. Instead we do critical edge splitting when possible - that is when LiveVariables is available. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@89213 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -21,7 +21,6 @@
|
|||||||
#include "llvm/CodeGen/MachineInstr.h"
|
#include "llvm/CodeGen/MachineInstr.h"
|
||||||
#include "llvm/CodeGen/MachineInstrBuilder.h"
|
#include "llvm/CodeGen/MachineInstrBuilder.h"
|
||||||
#include "llvm/CodeGen/MachineRegisterInfo.h"
|
#include "llvm/CodeGen/MachineRegisterInfo.h"
|
||||||
#include "llvm/CodeGen/RegAllocRegistry.h"
|
|
||||||
#include "llvm/Function.h"
|
#include "llvm/Function.h"
|
||||||
#include "llvm/Target/TargetMachine.h"
|
#include "llvm/Target/TargetMachine.h"
|
||||||
#include "llvm/ADT/SmallPtrSet.h"
|
#include "llvm/ADT/SmallPtrSet.h"
|
||||||
@@ -37,37 +36,17 @@ using namespace llvm;
|
|||||||
STATISTIC(NumAtomic, "Number of atomic phis lowered");
|
STATISTIC(NumAtomic, "Number of atomic phis lowered");
|
||||||
STATISTIC(NumSplits, "Number of critical edges split on demand");
|
STATISTIC(NumSplits, "Number of critical edges split on demand");
|
||||||
|
|
||||||
static cl::opt<bool>
|
|
||||||
SplitEdges("split-phi-edges",
|
|
||||||
cl::desc("Split critical edges during phi elimination"),
|
|
||||||
cl::init(false), cl::Hidden);
|
|
||||||
|
|
||||||
char PHIElimination::ID = 0;
|
char PHIElimination::ID = 0;
|
||||||
static RegisterPass<PHIElimination>
|
static RegisterPass<PHIElimination>
|
||||||
X("phi-node-elimination", "Eliminate PHI nodes for register allocation");
|
X("phi-node-elimination", "Eliminate PHI nodes for register allocation");
|
||||||
|
|
||||||
const PassInfo *const llvm::PHIEliminationID = &X;
|
const PassInfo *const llvm::PHIEliminationID = &X;
|
||||||
|
|
||||||
namespace llvm { FunctionPass *createLocalRegisterAllocator(); }
|
|
||||||
|
|
||||||
// Should we run edge splitting?
|
|
||||||
static bool shouldSplitEdges() {
|
|
||||||
// Edge splitting breaks the local register allocator. It cannot tolerate
|
|
||||||
// LiveVariables being run.
|
|
||||||
if (RegisterRegAlloc::getDefault() == createLocalRegisterAllocator)
|
|
||||||
return false;
|
|
||||||
return SplitEdges;
|
|
||||||
}
|
|
||||||
|
|
||||||
void llvm::PHIElimination::getAnalysisUsage(AnalysisUsage &AU) const {
|
void llvm::PHIElimination::getAnalysisUsage(AnalysisUsage &AU) const {
|
||||||
AU.addPreserved<LiveVariables>();
|
AU.addPreserved<LiveVariables>();
|
||||||
AU.addPreserved<MachineDominatorTree>();
|
AU.addPreserved<MachineDominatorTree>();
|
||||||
if (shouldSplitEdges()) {
|
// rdar://7401784 This would be nice:
|
||||||
AU.addRequired<LiveVariables>();
|
// AU.addPreservedID(MachineLoopInfoID);
|
||||||
} else {
|
|
||||||
AU.setPreservesCFG();
|
|
||||||
AU.addPreservedID(MachineLoopInfoID);
|
|
||||||
}
|
|
||||||
MachineFunctionPass::getAnalysisUsage(AU);
|
MachineFunctionPass::getAnalysisUsage(AU);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,9 +58,9 @@ bool llvm::PHIElimination::runOnMachineFunction(MachineFunction &Fn) {
|
|||||||
bool Changed = false;
|
bool Changed = false;
|
||||||
|
|
||||||
// Split critical edges to help the coalescer
|
// Split critical edges to help the coalescer
|
||||||
if (shouldSplitEdges())
|
if (LiveVariables *LV = getAnalysisIfAvailable<LiveVariables>())
|
||||||
for (MachineFunction::iterator I = Fn.begin(), E = Fn.end(); I != E; ++I)
|
for (MachineFunction::iterator I = Fn.begin(), E = Fn.end(); I != E; ++I)
|
||||||
Changed |= SplitPHIEdges(Fn, *I);
|
Changed |= SplitPHIEdges(Fn, *I, *LV);
|
||||||
|
|
||||||
// Populate VRegPHIUseCount
|
// Populate VRegPHIUseCount
|
||||||
analyzePHINodes(Fn);
|
analyzePHINodes(Fn);
|
||||||
@@ -361,10 +340,11 @@ void llvm::PHIElimination::analyzePHINodes(const MachineFunction& Fn) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool llvm::PHIElimination::SplitPHIEdges(MachineFunction &MF,
|
bool llvm::PHIElimination::SplitPHIEdges(MachineFunction &MF,
|
||||||
MachineBasicBlock &MBB) {
|
MachineBasicBlock &MBB,
|
||||||
|
LiveVariables &LV) {
|
||||||
if (MBB.empty() || MBB.front().getOpcode() != TargetInstrInfo::PHI)
|
if (MBB.empty() || MBB.front().getOpcode() != TargetInstrInfo::PHI)
|
||||||
return false; // Quick exit for basic blocks without PHIs.
|
return false; // Quick exit for basic blocks without PHIs.
|
||||||
LiveVariables &LV = getAnalysis<LiveVariables>();
|
|
||||||
for (MachineBasicBlock::const_iterator BBI = MBB.begin(), BBE = MBB.end();
|
for (MachineBasicBlock::const_iterator BBI = MBB.begin(), BBE = MBB.end();
|
||||||
BBI != BBE && BBI->getOpcode() == TargetInstrInfo::PHI; ++BBI) {
|
BBI != BBE && BBI->getOpcode() == TargetInstrInfo::PHI; ++BBI) {
|
||||||
for (unsigned i = 1, e = BBI->getNumOperands(); i != e; i += 2) {
|
for (unsigned i = 1, e = BBI->getNumOperands(); i != e; i += 2) {
|
||||||
|
|||||||
@@ -90,7 +90,8 @@ namespace llvm {
|
|||||||
void analyzePHINodes(const MachineFunction& Fn);
|
void analyzePHINodes(const MachineFunction& Fn);
|
||||||
|
|
||||||
/// 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);
|
||||||
|
|
||||||
/// isLiveOut - Determine if Reg is live out from MBB, when not
|
/// isLiveOut - Determine if Reg is live out from MBB, when not
|
||||||
/// considering PHI nodes. This means that Reg is either killed by
|
/// considering PHI nodes. This means that Reg is either killed by
|
||||||
|
|||||||
Reference in New Issue
Block a user