mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-13 09:33:50 +00:00
Just turn aggressive stack coloring off at -O3.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71140 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
d0c1f9c932
commit
2c1d7726f2
@ -191,7 +191,7 @@ namespace llvm {
|
||||
FunctionPass *createMachineSinkingPass();
|
||||
|
||||
/// createStackSlotColoringPass - This pass performs stack slot coloring.
|
||||
FunctionPass *createStackSlotColoringPass();
|
||||
FunctionPass *createStackSlotColoringPass(bool);
|
||||
|
||||
/// createStackProtectorPass - This pass adds stack protectors to functions.
|
||||
FunctionPass *createStackProtectorPass(const TargetLowering *tli);
|
||||
|
@ -193,7 +193,8 @@ bool LLVMTargetMachine::addCommonCodeGenPasses(PassManagerBase &PM,
|
||||
|
||||
// Perform stack slot coloring.
|
||||
if (OptLevel != CodeGenOpt::None)
|
||||
PM.add(createStackSlotColoringPass());
|
||||
PM.add(createStackSlotColoringPass(false));
|
||||
/*OptLevel >= CodeGenOpt::Aggressive*/
|
||||
|
||||
if (PrintMachineCode) // Print the register-allocated code
|
||||
PM.add(createMachineFunctionPrinterPass(cerr));
|
||||
|
@ -37,21 +37,22 @@ DisableSharing("no-stack-slot-sharing",
|
||||
cl::desc("Suppress slot sharing during stack coloring"));
|
||||
|
||||
static cl::opt<bool>
|
||||
ColorWithRegs("color-ss-with-regs",
|
||||
cl::init(false), cl::Hidden,
|
||||
cl::desc("Color stack slots with free registers"));
|
||||
ColorWithRegsOpt("color-ss-with-regs",
|
||||
cl::init(false), cl::Hidden,
|
||||
cl::desc("Color stack slots with free registers"));
|
||||
|
||||
|
||||
static cl::opt<int> DCELimit("ssc-dce-limit", cl::init(-1), cl::Hidden);
|
||||
|
||||
STATISTIC(NumEliminated, "Number of stack slots eliminated due to coloring");
|
||||
STATISTIC(NumRegRepl, "Number of stack slot refs replaced with reg refs");
|
||||
STATISTIC(NumLoadElim, "Number of load eliminated");
|
||||
STATISTIC(NumLoadElim, "Number of loads eliminated");
|
||||
STATISTIC(NumStoreElim, "Number of stores eliminated");
|
||||
STATISTIC(NumDead, "Number of trivially dead stack accesses eliminated");
|
||||
|
||||
namespace {
|
||||
class VISIBILITY_HIDDEN StackSlotColoring : public MachineFunctionPass {
|
||||
bool ColorWithRegs;
|
||||
LiveStacks* LS;
|
||||
VirtRegMap* VRM;
|
||||
MachineFrameInfo *MFI;
|
||||
@ -89,7 +90,10 @@ namespace {
|
||||
|
||||
public:
|
||||
static char ID; // Pass identification
|
||||
StackSlotColoring() : MachineFunctionPass(&ID), NextColor(-1) {}
|
||||
StackSlotColoring() :
|
||||
MachineFunctionPass(&ID), ColorWithRegs(false), NextColor(-1) {}
|
||||
StackSlotColoring(bool RegColor) :
|
||||
MachineFunctionPass(&ID), ColorWithRegs(RegColor), NextColor(-1) {}
|
||||
|
||||
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
|
||||
AU.addRequired<LiveStacks>();
|
||||
@ -136,8 +140,8 @@ char StackSlotColoring::ID = 0;
|
||||
static RegisterPass<StackSlotColoring>
|
||||
X("stack-slot-coloring", "Stack Slot Coloring");
|
||||
|
||||
FunctionPass *llvm::createStackSlotColoringPass() {
|
||||
return new StackSlotColoring();
|
||||
FunctionPass *llvm::createStackSlotColoringPass(bool RegColor) {
|
||||
return new StackSlotColoring(RegColor);
|
||||
}
|
||||
|
||||
namespace {
|
||||
@ -231,7 +235,7 @@ bool
|
||||
StackSlotColoring::ColorSlotsWithFreeRegs(SmallVector<int, 16> &SlotMapping,
|
||||
SmallVector<SmallVector<int, 4>, 16> &RevMap,
|
||||
BitVector &SlotIsReg) {
|
||||
if (!ColorWithRegs || !VRM->HasUnusedRegisters())
|
||||
if (!(ColorWithRegs || ColorWithRegsOpt) || !VRM->HasUnusedRegisters())
|
||||
return false;
|
||||
|
||||
bool Changed = false;
|
||||
@ -239,7 +243,9 @@ StackSlotColoring::ColorSlotsWithFreeRegs(SmallVector<int, 16> &SlotMapping,
|
||||
for (unsigned i = 0, e = SSIntervals.size(); i != e; ++i) {
|
||||
LiveInterval *li = SSIntervals[i];
|
||||
int SS = li->getStackSlotIndex();
|
||||
if (!UsedColors[SS])
|
||||
if (!UsedColors[SS] || li->weight < 20)
|
||||
// If the weight is < 20, i.e. two references in a loop with depth 1,
|
||||
// don't bother with it.
|
||||
continue;
|
||||
|
||||
// These slots allow to share the same registers.
|
||||
@ -472,6 +478,9 @@ void StackSlotColoring::RewriteInstruction(MachineInstr *MI, int OldFI,
|
||||
bool StackSlotColoring::PropagateBackward(MachineBasicBlock::iterator MII,
|
||||
MachineBasicBlock *MBB,
|
||||
unsigned OldReg, unsigned NewReg) {
|
||||
if (MII == MBB->begin())
|
||||
return false;
|
||||
|
||||
SmallVector<MachineOperand*, 4> Refs;
|
||||
while (--MII != MBB->begin()) {
|
||||
bool FoundDef = false; // Not counting 2address def.
|
||||
@ -522,6 +531,9 @@ bool StackSlotColoring::PropagateBackward(MachineBasicBlock::iterator MII,
|
||||
bool StackSlotColoring::PropagateForward(MachineBasicBlock::iterator MII,
|
||||
MachineBasicBlock *MBB,
|
||||
unsigned OldReg, unsigned NewReg) {
|
||||
if (MII == MBB->end())
|
||||
return false;
|
||||
|
||||
SmallVector<MachineOperand*, 4> Uses;
|
||||
while (++MII != MBB->end()) {
|
||||
bool FoundUse = false;
|
||||
|
Loading…
x
Reference in New Issue
Block a user