1//===-- LiveIntervalAnalysis.cpp - Live Interval Analysis -----------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
--- 39 unchanged lines hidden (view full) ---
48
49// Hidden options for help debugging.
50static cl::opt<bool> DisableReMat("disable-rematerialization",
51 cl::init(false), cl::Hidden);
52
53static cl::opt<bool> EnableFastSpilling("fast-spill",
54 cl::init(false), cl::Hidden);
55
56STATISTIC(numIntervals , "Number of original intervals");
57STATISTIC(numFolds , "Number of loads/stores folded into instructions");
58STATISTIC(numSplits , "Number of intervals split");
59
60char LiveIntervals::ID = 0;
61static RegisterPass<LiveIntervals> X("liveintervals", "Live Interval Analysis");
62
63void LiveIntervals::getAnalysisUsage(AnalysisUsage &AU) const {
64 AU.setPreservesCFG();
65 AU.addRequired<AliasAnalysis>();
66 AU.addPreserved<AliasAnalysis>();
--- 17 unchanged lines hidden (view full) ---
84
85void LiveIntervals::releaseMemory() {
86 // Free the live intervals themselves.
87 for (DenseMap<unsigned, LiveInterval*>::iterator I = r2iMap_.begin(),
88 E = r2iMap_.end(); I != E; ++I)
89 delete I->second;
90
91 r2iMap_.clear();
92
93 // Release VNInfo memroy regions after all VNInfo objects are dtor'd.
94 VNInfoAllocator.Reset();
95 while (!CloneMIs.empty()) {
96 MachineInstr *MI = CloneMIs.back();
97 CloneMIs.pop_back();
98 mf_->DeleteMachineInstr(MI);
99 }
--- 8 unchanged lines hidden (view full) ---
108 tri_ = tm_->getRegisterInfo();
109 tii_ = tm_->getInstrInfo();
110 aa_ = &getAnalysis<AliasAnalysis>();
111 lv_ = &getAnalysis<LiveVariables>();
112 indexes_ = &getAnalysis<SlotIndexes>();
113 allocatableRegs_ = tri_->getAllocatableSet(fn);
114
115 computeIntervals();
116
117 numIntervals += getNumIntervals();
118
119 DEBUG(dump());
120 return true;
121}
122
123/// print - Implement the dump method.
--- 271 unchanged lines hidden (view full) ---
395 } else {
396 // Otherwise, this must be because of phi elimination. If this is the
397 // first redefinition of the vreg that we have seen, go back and change
398 // the live range in the PHI block to be a different value number.
399 if (interval.containsOneValue()) {
400 // Remove the old range that we now know has an incorrect number.
401 VNInfo *VNI = interval.getValNumInfo(0);
402 MachineInstr *Killer = vi.Kills[0];
403 SlotIndex Start = getMBBStartIdx(Killer->getParent());
404 SlotIndex End = getInstructionIndex(Killer).getDefIndex();
405 DEBUG({
406 errs() << " Removing [" << Start << "," << End << "] from: ";
407 interval.print(errs(), tri_);
408 errs() << "\n";
409 });
410 interval.removeRange(Start, End);
--- 227 unchanged lines hidden (view full) ---
638 vni->setIsPHIDef(true);
639 LiveRange LR(start, end, vni);
640
641 interval.addRange(LR);
642 LR.valno->addKill(end);
643 DEBUG(errs() << " +" << LR << '\n');
644}
645
646/// computeIntervals - computes the live intervals for virtual
647/// registers. for some ordering of the machine instructions [1,N] a
648/// live interval is an interval [i, j) where 1 <= i <= j < N for
649/// which a variable is live
650void LiveIntervals::computeIntervals() {
651 DEBUG(errs() << "********** COMPUTING LIVE INTERVALS **********\n"
652 << "********** Function: "
653 << ((Value*)mf_->getFunction())->getName() << '\n');
--- 1411 unchanged lines hidden ---
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
--- 39 unchanged lines hidden (view full) ---
48
49// Hidden options for help debugging.
50static cl::opt<bool> DisableReMat("disable-rematerialization",
51 cl::init(false), cl::Hidden);
52
53static cl::opt<bool> EnableFastSpilling("fast-spill",
54 cl::init(false), cl::Hidden);
55
56STATISTIC(numIntervals , "Number of original intervals");
57STATISTIC(numFolds , "Number of loads/stores folded into instructions");
58STATISTIC(numSplits , "Number of intervals split");
59
60char LiveIntervals::ID = 0;
61static RegisterPass<LiveIntervals> X("liveintervals", "Live Interval Analysis");
62
63void LiveIntervals::getAnalysisUsage(AnalysisUsage &AU) const {
64 AU.setPreservesCFG();
65 AU.addRequired<AliasAnalysis>();
66 AU.addPreserved<AliasAnalysis>();
--- 17 unchanged lines hidden (view full) ---
84
85void LiveIntervals::releaseMemory() {
86 // Free the live intervals themselves.
87 for (DenseMap<unsigned, LiveInterval*>::iterator I = r2iMap_.begin(),
88 E = r2iMap_.end(); I != E; ++I)
89 delete I->second;
90
91 r2iMap_.clear();
92
93 // Release VNInfo memroy regions after all VNInfo objects are dtor'd.
94 VNInfoAllocator.Reset();
95 while (!CloneMIs.empty()) {
96 MachineInstr *MI = CloneMIs.back();
97 CloneMIs.pop_back();
98 mf_->DeleteMachineInstr(MI);
99 }
--- 8 unchanged lines hidden (view full) ---
108 tri_ = tm_->getRegisterInfo();
109 tii_ = tm_->getInstrInfo();
110 aa_ = &getAnalysis<AliasAnalysis>();
111 lv_ = &getAnalysis<LiveVariables>();
112 indexes_ = &getAnalysis<SlotIndexes>();
113 allocatableRegs_ = tri_->getAllocatableSet(fn);
114
115 computeIntervals();
116
117 numIntervals += getNumIntervals();
118
119 DEBUG(dump());
120 return true;
121}
122
123/// print - Implement the dump method.
--- 271 unchanged lines hidden (view full) ---
395 } else {
396 // Otherwise, this must be because of phi elimination. If this is the
397 // first redefinition of the vreg that we have seen, go back and change
398 // the live range in the PHI block to be a different value number.
399 if (interval.containsOneValue()) {
400 // Remove the old range that we now know has an incorrect number.
401 VNInfo *VNI = interval.getValNumInfo(0);
402 MachineInstr *Killer = vi.Kills[0];
403 SlotIndex Start = getMBBStartIdx(Killer->getParent());
404 SlotIndex End = getInstructionIndex(Killer).getDefIndex();
405 DEBUG({
406 errs() << " Removing [" << Start << "," << End << "] from: ";
407 interval.print(errs(), tri_);
408 errs() << "\n";
409 });
410 interval.removeRange(Start, End);
--- 227 unchanged lines hidden (view full) ---
638 vni->setIsPHIDef(true);
639 LiveRange LR(start, end, vni);
640
641 interval.addRange(LR);
642 LR.valno->addKill(end);
643 DEBUG(errs() << " +" << LR << '\n');
644}
645
646/// computeIntervals - computes the live intervals for virtual
647/// registers. for some ordering of the machine instructions [1,N] a
648/// live interval is an interval [i, j) where 1 <= i <= j < N for
649/// which a variable is live
650void LiveIntervals::computeIntervals() {
651 DEBUG(errs() << "********** COMPUTING LIVE INTERVALS **********\n"
652 << "********** Function: "
653 << ((Value*)mf_->getFunction())->getName() << '\n');
--- 1411 unchanged lines hidden ---