llvm.org GIT mirror llvm / 2c1d772
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 Bill Wendling 11 years ago
3 changed file(s) with 24 addition(s) and 11 deletion(s). Raw diff Collapse all Expand all
190190 FunctionPass *createMachineSinkingPass();
191191
192192 /// createStackSlotColoringPass - This pass performs stack slot coloring.
193 FunctionPass *createStackSlotColoringPass();
193 FunctionPass *createStackSlotColoringPass(bool);
194194
195195 /// createStackProtectorPass - This pass adds stack protectors to functions.
196196 FunctionPass *createStackProtectorPass(const TargetLowering *tli);
192192
193193 // Perform stack slot coloring.
194194 if (OptLevel != CodeGenOpt::None)
195 PM.add(createStackSlotColoringPass());
195 PM.add(createStackSlotColoringPass(false));
196 /*OptLevel >= CodeGenOpt::Aggressive*/
196197
197198 if (PrintMachineCode) // Print the register-allocated code
198199 PM.add(createMachineFunctionPrinterPass(cerr));
3636 cl::desc("Suppress slot sharing during stack coloring"));
3737
3838 static cl::opt
39 ColorWithRegs("color-ss-with-regs",
40 cl::init(false), cl::Hidden,
41 cl::desc("Color stack slots with free registers"));
39 ColorWithRegsOpt("color-ss-with-regs",
40 cl::init(false), cl::Hidden,
41 cl::desc("Color stack slots with free registers"));
4242
4343
4444 static cl::opt DCELimit("ssc-dce-limit", cl::init(-1), cl::Hidden);
4545
4646 STATISTIC(NumEliminated, "Number of stack slots eliminated due to coloring");
4747 STATISTIC(NumRegRepl, "Number of stack slot refs replaced with reg refs");
48 STATISTIC(NumLoadElim, "Number of load eliminated");
48 STATISTIC(NumLoadElim, "Number of loads eliminated");
4949 STATISTIC(NumStoreElim, "Number of stores eliminated");
5050 STATISTIC(NumDead, "Number of trivially dead stack accesses eliminated");
5151
5252 namespace {
5353 class VISIBILITY_HIDDEN StackSlotColoring : public MachineFunctionPass {
54 bool ColorWithRegs;
5455 LiveStacks* LS;
5556 VirtRegMap* VRM;
5657 MachineFrameInfo *MFI;
8889
8990 public:
9091 static char ID; // Pass identification
91 StackSlotColoring() : MachineFunctionPass(&ID), NextColor(-1) {}
92 StackSlotColoring() :
93 MachineFunctionPass(&ID), ColorWithRegs(false), NextColor(-1) {}
94 StackSlotColoring(bool RegColor) :
95 MachineFunctionPass(&ID), ColorWithRegs(RegColor), NextColor(-1) {}
9296
9397 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
9498 AU.addRequired();
135139 static RegisterPass
136140 X("stack-slot-coloring", "Stack Slot Coloring");
137141
138 FunctionPass *llvm::createStackSlotColoringPass() {
139 return new StackSlotColoring();
142 FunctionPass *llvm::createStackSlotColoringPass(bool RegColor) {
143 return new StackSlotColoring(RegColor);
140144 }
141145
142146 namespace {
230234 StackSlotColoring::ColorSlotsWithFreeRegs(SmallVector &SlotMapping,
231235 SmallVector, 16> &RevMap,
232236 BitVector &SlotIsReg) {
233 if (!ColorWithRegs || !VRM->HasUnusedRegisters())
237 if (!(ColorWithRegs || ColorWithRegsOpt) || !VRM->HasUnusedRegisters())
234238 return false;
235239
236240 bool Changed = false;
238242 for (unsigned i = 0, e = SSIntervals.size(); i != e; ++i) {
239243 LiveInterval *li = SSIntervals[i];
240244 int SS = li->getStackSlotIndex();
241 if (!UsedColors[SS])
245 if (!UsedColors[SS] || li->weight < 20)
246 // If the weight is < 20, i.e. two references in a loop with depth 1,
247 // don't bother with it.
242248 continue;
243249
244250 // These slots allow to share the same registers.
471477 bool StackSlotColoring::PropagateBackward(MachineBasicBlock::iterator MII,
472478 MachineBasicBlock *MBB,
473479 unsigned OldReg, unsigned NewReg) {
480 if (MII == MBB->begin())
481 return false;
482
474483 SmallVector Refs;
475484 while (--MII != MBB->begin()) {
476485 bool FoundDef = false; // Not counting 2address def.
521530 bool StackSlotColoring::PropagateForward(MachineBasicBlock::iterator MII,
522531 MachineBasicBlock *MBB,
523532 unsigned OldReg, unsigned NewReg) {
533 if (MII == MBB->end())
534 return false;
535
524536 SmallVector Uses;
525537 while (++MII != MBB->end()) {
526538 bool FoundUse = false;