blob: e0aa4053987c225a3545dbdea6f45daf1542e80b [file] [log] [blame]
Alkis Evlogimenos34d9bc92004-02-23 23:08:11 +00001//===-- llvm/CodeGen/VirtRegMap.cpp - Virtual Register Map ----------------===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner4ee451d2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Alkis Evlogimenos34d9bc92004-02-23 23:08:11 +00007//
8//===----------------------------------------------------------------------===//
9//
Chris Lattner8c4d88d2004-09-30 01:54:45 +000010// This file implements the VirtRegMap class.
11//
Dan Gohmanf451cb82010-02-10 16:03:48 +000012// It also contains implementations of the Spiller interface, which, given a
Chris Lattner8c4d88d2004-09-30 01:54:45 +000013// virtual register map and a machine function, eliminates all virtual
14// references by replacing them with physical register references - adding spill
Alkis Evlogimenos0d6c5b62004-02-24 08:58:30 +000015// code as necessary.
Alkis Evlogimenos34d9bc92004-02-23 23:08:11 +000016//
17//===----------------------------------------------------------------------===//
18
Jakob Stoklund Olesen4281e202012-01-07 07:39:47 +000019#define DEBUG_TYPE "regalloc"
Jakob Stoklund Olesen1ead68d2012-11-28 19:13:06 +000020#include "llvm/CodeGen/VirtRegMap.h"
Jakob Stoklund Olesen05ec7122012-06-08 23:44:45 +000021#include "LiveDebugVariables.h"
Chandler Carruthd04a8d42012-12-03 16:50:05 +000022#include "llvm/ADT/STLExtras.h"
23#include "llvm/ADT/Statistic.h"
Jakob Stoklund Olesen05ec7122012-06-08 23:44:45 +000024#include "llvm/CodeGen/LiveIntervalAnalysis.h"
Evan Chengbb36a432012-09-21 20:04:28 +000025#include "llvm/CodeGen/LiveStackAnalysis.h"
Alkis Evlogimenos34d9bc92004-02-23 23:08:11 +000026#include "llvm/CodeGen/MachineFrameInfo.h"
Chris Lattner8c4d88d2004-09-30 01:54:45 +000027#include "llvm/CodeGen/MachineFunction.h"
Evan Cheng4cce6b42008-04-11 17:53:36 +000028#include "llvm/CodeGen/MachineInstrBuilder.h"
Chris Lattner84bc5422007-12-31 04:13:23 +000029#include "llvm/CodeGen/MachineRegisterInfo.h"
Jakob Stoklund Olesen05ec7122012-06-08 23:44:45 +000030#include "llvm/CodeGen/Passes.h"
Quentin Colombetce734f12013-09-25 00:26:17 +000031#include "llvm/IR/Function.h"
Reid Spencer551ccae2004-09-01 22:55:40 +000032#include "llvm/Support/CommandLine.h"
Chris Lattnera4f0b3a2006-08-27 12:54:02 +000033#include "llvm/Support/Compiler.h"
Evan Cheng752272a2009-02-11 08:24:21 +000034#include "llvm/Support/Debug.h"
Daniel Dunbar1cd1d982009-07-24 10:36:58 +000035#include "llvm/Support/raw_ostream.h"
Chandler Carruthd04a8d42012-12-03 16:50:05 +000036#include "llvm/Target/TargetInstrInfo.h"
37#include "llvm/Target/TargetMachine.h"
38#include "llvm/Target/TargetRegisterInfo.h"
Chris Lattner27f29162004-10-26 15:35:58 +000039#include <algorithm>
Alkis Evlogimenos34d9bc92004-02-23 23:08:11 +000040using namespace llvm;
41
Jakob Stoklund Olesen01afdb32011-09-15 18:31:13 +000042STATISTIC(NumSpillSlots, "Number of spill slots allocated");
43STATISTIC(NumIdCopies, "Number of identity moves eliminated after rewriting");
Dan Gohman844731a2008-05-13 00:00:25 +000044
Chris Lattner8c4d88d2004-09-30 01:54:45 +000045//===----------------------------------------------------------------------===//
46// VirtRegMap implementation
47//===----------------------------------------------------------------------===//
48
Owen Anderson49c8aa02009-03-13 05:55:11 +000049char VirtRegMap::ID = 0;
50
Owen Andersonce665bd2010-10-07 22:25:06 +000051INITIALIZE_PASS(VirtRegMap, "virtregmap", "Virtual Register Map", false, false)
Owen Anderson49c8aa02009-03-13 05:55:11 +000052
53bool VirtRegMap::runOnMachineFunction(MachineFunction &mf) {
Evan Cheng90f95f82009-06-14 20:22:55 +000054 MRI = &mf.getRegInfo();
Owen Anderson49c8aa02009-03-13 05:55:11 +000055 TII = mf.getTarget().getInstrInfo();
Mike Stumpfe095f32009-05-04 18:40:41 +000056 TRI = mf.getTarget().getRegisterInfo();
Owen Anderson49c8aa02009-03-13 05:55:11 +000057 MF = &mf;
Lang Hames233a60e2009-11-03 23:52:08 +000058
Owen Anderson49c8aa02009-03-13 05:55:11 +000059 Virt2PhysMap.clear();
60 Virt2StackSlotMap.clear();
Owen Anderson49c8aa02009-03-13 05:55:11 +000061 Virt2SplitMap.clear();
Mike Stumpfe095f32009-05-04 18:40:41 +000062
Chris Lattner29268692006-09-05 02:12:02 +000063 grow();
Owen Anderson49c8aa02009-03-13 05:55:11 +000064 return false;
Chris Lattner29268692006-09-05 02:12:02 +000065}
66
Chris Lattner8c4d88d2004-09-30 01:54:45 +000067void VirtRegMap::grow() {
Jakob Stoklund Olesen42e9c962011-01-09 21:58:20 +000068 unsigned NumRegs = MF->getRegInfo().getNumVirtRegs();
69 Virt2PhysMap.resize(NumRegs);
70 Virt2StackSlotMap.resize(NumRegs);
Jakob Stoklund Olesen42e9c962011-01-09 21:58:20 +000071 Virt2SplitMap.resize(NumRegs);
Alkis Evlogimenos34d9bc92004-02-23 23:08:11 +000072}
73
Jakob Stoklund Olesenb55e91e2010-11-16 00:41:01 +000074unsigned VirtRegMap::createSpillSlot(const TargetRegisterClass *RC) {
75 int SS = MF->getFrameInfo()->CreateSpillStackObject(RC->getSize(),
76 RC->getAlignment());
Jakob Stoklund Olesen01afdb32011-09-15 18:31:13 +000077 ++NumSpillSlots;
Jakob Stoklund Olesenb55e91e2010-11-16 00:41:01 +000078 return SS;
79}
80
Jakob Stoklund Olesen980bddf2012-12-04 00:30:22 +000081bool VirtRegMap::hasPreferredPhys(unsigned VirtReg) {
82 unsigned Hint = MRI->getSimpleHint(VirtReg);
83 if (!Hint)
84 return 0;
85 if (TargetRegisterInfo::isVirtualRegister(Hint))
86 Hint = getPhys(Hint);
87 return getPhys(VirtReg) == Hint;
88}
89
Jakob Stoklund Olesenfc637442012-12-03 23:23:50 +000090bool VirtRegMap::hasKnownPreference(unsigned VirtReg) {
91 std::pair<unsigned, unsigned> Hint = MRI->getRegAllocationHint(VirtReg);
92 if (TargetRegisterInfo::isPhysicalRegister(Hint.second))
93 return true;
94 if (TargetRegisterInfo::isVirtualRegister(Hint.second))
95 return hasPhys(Hint.second);
96 return false;
97}
98
Chris Lattner8c4d88d2004-09-30 01:54:45 +000099int VirtRegMap::assignVirt2StackSlot(unsigned virtReg) {
Dan Gohman6f0d0242008-02-10 18:45:23 +0000100 assert(TargetRegisterInfo::isVirtualRegister(virtReg));
Chris Lattner7f690e62004-09-30 02:15:18 +0000101 assert(Virt2StackSlotMap[virtReg] == NO_STACK_SLOT &&
Chris Lattner8c4d88d2004-09-30 01:54:45 +0000102 "attempt to assign stack slot to already spilled register");
Owen Anderson49c8aa02009-03-13 05:55:11 +0000103 const TargetRegisterClass* RC = MF->getRegInfo().getRegClass(virtReg);
Jakob Stoklund Olesenb55e91e2010-11-16 00:41:01 +0000104 return Virt2StackSlotMap[virtReg] = createSpillSlot(RC);
Chris Lattner8c4d88d2004-09-30 01:54:45 +0000105}
106
Evan Chengd3653122008-02-27 03:04:06 +0000107void VirtRegMap::assignVirt2StackSlot(unsigned virtReg, int SS) {
Dan Gohman6f0d0242008-02-10 18:45:23 +0000108 assert(TargetRegisterInfo::isVirtualRegister(virtReg));
Chris Lattner7f690e62004-09-30 02:15:18 +0000109 assert(Virt2StackSlotMap[virtReg] == NO_STACK_SLOT &&
Chris Lattner8c4d88d2004-09-30 01:54:45 +0000110 "attempt to assign stack slot to already spilled register");
Evan Chengd3653122008-02-27 03:04:06 +0000111 assert((SS >= 0 ||
Owen Anderson49c8aa02009-03-13 05:55:11 +0000112 (SS >= MF->getFrameInfo()->getObjectIndexBegin())) &&
Evan Cheng91935142007-04-04 07:40:01 +0000113 "illegal fixed frame index");
Evan Chengd3653122008-02-27 03:04:06 +0000114 Virt2StackSlotMap[virtReg] = SS;
Alkis Evlogimenos38af59a2004-05-29 20:38:05 +0000115}
116
Jakob Stoklund Olesen05ec7122012-06-08 23:44:45 +0000117void VirtRegMap::print(raw_ostream &OS, const Module*) const {
118 OS << "********** REGISTER MAP **********\n";
119 for (unsigned i = 0, e = MRI->getNumVirtRegs(); i != e; ++i) {
120 unsigned Reg = TargetRegisterInfo::index2VirtReg(i);
121 if (Virt2PhysMap[Reg] != (unsigned)VirtRegMap::NO_PHYS_REG) {
122 OS << '[' << PrintReg(Reg, TRI) << " -> "
123 << PrintReg(Virt2PhysMap[Reg], TRI) << "] "
124 << MRI->getRegClass(Reg)->getName() << "\n";
125 }
126 }
127
128 for (unsigned i = 0, e = MRI->getNumVirtRegs(); i != e; ++i) {
129 unsigned Reg = TargetRegisterInfo::index2VirtReg(i);
130 if (Virt2StackSlotMap[Reg] != VirtRegMap::NO_STACK_SLOT) {
131 OS << '[' << PrintReg(Reg, TRI) << " -> fi#" << Virt2StackSlotMap[Reg]
132 << "] " << MRI->getRegClass(Reg)->getName() << "\n";
133 }
134 }
135 OS << '\n';
136}
137
Manman Renb720be62012-09-11 22:23:19 +0000138#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
Jakob Stoklund Olesen05ec7122012-06-08 23:44:45 +0000139void VirtRegMap::dump() const {
140 print(dbgs());
141}
Manman Ren77e300e2012-09-06 19:06:06 +0000142#endif
Jakob Stoklund Olesen05ec7122012-06-08 23:44:45 +0000143
144//===----------------------------------------------------------------------===//
145// VirtRegRewriter
146//===----------------------------------------------------------------------===//
147//
148// The VirtRegRewriter is the last of the register allocator passes.
149// It rewrites virtual registers to physical registers as specified in the
150// VirtRegMap analysis. It also updates live-in information on basic blocks
151// according to LiveIntervals.
152//
153namespace {
154class VirtRegRewriter : public MachineFunctionPass {
155 MachineFunction *MF;
156 const TargetMachine *TM;
157 const TargetRegisterInfo *TRI;
158 const TargetInstrInfo *TII;
159 MachineRegisterInfo *MRI;
160 SlotIndexes *Indexes;
161 LiveIntervals *LIS;
162 VirtRegMap *VRM;
163
164 void rewrite();
165 void addMBBLiveIns();
166public:
167 static char ID;
168 VirtRegRewriter() : MachineFunctionPass(ID) {}
169
170 virtual void getAnalysisUsage(AnalysisUsage &AU) const;
171
172 virtual bool runOnMachineFunction(MachineFunction&);
173};
174} // end anonymous namespace
175
176char &llvm::VirtRegRewriterID = VirtRegRewriter::ID;
177
178INITIALIZE_PASS_BEGIN(VirtRegRewriter, "virtregrewriter",
179 "Virtual Register Rewriter", false, false)
180INITIALIZE_PASS_DEPENDENCY(SlotIndexes)
181INITIALIZE_PASS_DEPENDENCY(LiveIntervals)
182INITIALIZE_PASS_DEPENDENCY(LiveDebugVariables)
Evan Chengbb36a432012-09-21 20:04:28 +0000183INITIALIZE_PASS_DEPENDENCY(LiveStacks)
Jakob Stoklund Olesen05ec7122012-06-08 23:44:45 +0000184INITIALIZE_PASS_DEPENDENCY(VirtRegMap)
185INITIALIZE_PASS_END(VirtRegRewriter, "virtregrewriter",
186 "Virtual Register Rewriter", false, false)
187
188char VirtRegRewriter::ID = 0;
189
190void VirtRegRewriter::getAnalysisUsage(AnalysisUsage &AU) const {
191 AU.setPreservesCFG();
192 AU.addRequired<LiveIntervals>();
193 AU.addRequired<SlotIndexes>();
194 AU.addPreserved<SlotIndexes>();
195 AU.addRequired<LiveDebugVariables>();
Evan Chengbb36a432012-09-21 20:04:28 +0000196 AU.addRequired<LiveStacks>();
197 AU.addPreserved<LiveStacks>();
Jakob Stoklund Olesen05ec7122012-06-08 23:44:45 +0000198 AU.addRequired<VirtRegMap>();
199 MachineFunctionPass::getAnalysisUsage(AU);
200}
201
202bool VirtRegRewriter::runOnMachineFunction(MachineFunction &fn) {
203 MF = &fn;
204 TM = &MF->getTarget();
205 TRI = TM->getRegisterInfo();
206 TII = TM->getInstrInfo();
207 MRI = &MF->getRegInfo();
208 Indexes = &getAnalysis<SlotIndexes>();
209 LIS = &getAnalysis<LiveIntervals>();
210 VRM = &getAnalysis<VirtRegMap>();
Jakob Stoklund Olesenba05c012011-02-18 22:03:18 +0000211 DEBUG(dbgs() << "********** REWRITE VIRTUAL REGISTERS **********\n"
212 << "********** Function: "
Craig Topper96601ca2012-08-22 06:07:19 +0000213 << MF->getName() << '\n');
Jakob Stoklund Olesen05ec7122012-06-08 23:44:45 +0000214 DEBUG(VRM->dump());
215
216 // Add kill flags while we still have virtual registers.
Jakob Stoklund Olesene617ccb2012-09-06 18:15:18 +0000217 LIS->addKillFlags(VRM);
Jakob Stoklund Olesen05ec7122012-06-08 23:44:45 +0000218
Jakob Stoklund Olesenfe17bdb2012-06-09 00:14:47 +0000219 // Live-in lists on basic blocks are required for physregs.
220 addMBBLiveIns();
221
Jakob Stoklund Olesen05ec7122012-06-08 23:44:45 +0000222 // Rewrite virtual registers.
223 rewrite();
224
225 // Write out new DBG_VALUE instructions.
226 getAnalysis<LiveDebugVariables>().emitDebugValues(VRM);
227
228 // All machine operands and other references to virtual registers have been
229 // replaced. Remove the virtual registers and release all the transient data.
230 VRM->clearAllVirt();
231 MRI->clearVirtRegs();
232 return true;
233}
234
Jakob Stoklund Olesenfe17bdb2012-06-09 00:14:47 +0000235// Compute MBB live-in lists from virtual register live ranges and their
236// assignments.
237void VirtRegRewriter::addMBBLiveIns() {
238 SmallVector<MachineBasicBlock*, 16> LiveIn;
239 for (unsigned Idx = 0, IdxE = MRI->getNumVirtRegs(); Idx != IdxE; ++Idx) {
240 unsigned VirtReg = TargetRegisterInfo::index2VirtReg(Idx);
241 if (MRI->reg_nodbg_empty(VirtReg))
242 continue;
243 LiveInterval &LI = LIS->getInterval(VirtReg);
244 if (LI.empty() || LIS->intervalIsInOneMBB(LI))
245 continue;
246 // This is a virtual register that is live across basic blocks. Its
247 // assigned PhysReg must be marked as live-in to those blocks.
248 unsigned PhysReg = VRM->getPhys(VirtReg);
249 assert(PhysReg != VirtRegMap::NO_PHYS_REG && "Unmapped virtual register.");
250
251 // Scan the segments of LI.
252 for (LiveInterval::const_iterator I = LI.begin(), E = LI.end(); I != E;
253 ++I) {
254 if (!Indexes->findLiveInMBBs(I->start, I->end, LiveIn))
255 continue;
256 for (unsigned i = 0, e = LiveIn.size(); i != e; ++i)
257 if (!LiveIn[i]->isLiveIn(PhysReg))
258 LiveIn[i]->addLiveIn(PhysReg);
259 LiveIn.clear();
260 }
261 }
262}
263
Jakob Stoklund Olesen05ec7122012-06-08 23:44:45 +0000264void VirtRegRewriter::rewrite() {
Jakob Stoklund Olesen93e110b2011-04-27 17:42:31 +0000265 SmallVector<unsigned, 8> SuperDeads;
266 SmallVector<unsigned, 8> SuperDefs;
Jakob Stoklund Olesenba05c012011-02-18 22:03:18 +0000267 SmallVector<unsigned, 8> SuperKills;
Quentin Colombetce734f12013-09-25 00:26:17 +0000268 SmallPtrSet<const MachineInstr *, 4> NoReturnInsts;
Jakob Stoklund Olesenba05c012011-02-18 22:03:18 +0000269
270 for (MachineFunction::iterator MBBI = MF->begin(), MBBE = MF->end();
271 MBBI != MBBE; ++MBBI) {
272 DEBUG(MBBI->print(dbgs(), Indexes));
Quentin Colombetce734f12013-09-25 00:26:17 +0000273 bool IsExitBB = MBBI->succ_empty();
Evan Cheng3f9c2512012-01-19 07:46:36 +0000274 for (MachineBasicBlock::instr_iterator
275 MII = MBBI->instr_begin(), MIE = MBBI->instr_end(); MII != MIE;) {
Jakob Stoklund Olesenba05c012011-02-18 22:03:18 +0000276 MachineInstr *MI = MII;
277 ++MII;
278
Quentin Colombetce734f12013-09-25 00:26:17 +0000279 // Check if this instruction is a call to a noreturn function.
280 // If so, all the definitions set by this instruction can be ignored.
281 if (IsExitBB && MI->isCall())
282 for (MachineInstr::mop_iterator MOI = MI->operands_begin(),
283 MOE = MI->operands_end(); MOI != MOE; ++MOI) {
284 MachineOperand &MO = *MOI;
285 if (!MO.isGlobal())
286 continue;
287 const Function *Func = dyn_cast<Function>(MO.getGlobal());
Quentin Colombetf0c6ab62013-11-08 18:14:17 +0000288 if (!Func || !Func->hasFnAttribute(Attribute::NoReturn) ||
289 // We need to keep correct unwind information
290 // even if the function will not return, since the
291 // runtime may need it.
292 !Func->hasFnAttribute(Attribute::NoUnwind))
Quentin Colombetce734f12013-09-25 00:26:17 +0000293 continue;
294 NoReturnInsts.insert(MI);
295 break;
296 }
297
Jakob Stoklund Olesenba05c012011-02-18 22:03:18 +0000298 for (MachineInstr::mop_iterator MOI = MI->operands_begin(),
299 MOE = MI->operands_end(); MOI != MOE; ++MOI) {
300 MachineOperand &MO = *MOI;
Jakob Stoklund Olesend9f0ff52012-02-17 19:07:56 +0000301
302 // Make sure MRI knows about registers clobbered by regmasks.
303 if (MO.isRegMask())
304 MRI->addPhysRegsUsedFromRegMask(MO.getRegMask());
305
Jakob Stoklund Olesenba05c012011-02-18 22:03:18 +0000306 if (!MO.isReg() || !TargetRegisterInfo::isVirtualRegister(MO.getReg()))
307 continue;
308 unsigned VirtReg = MO.getReg();
Jakob Stoklund Olesen05ec7122012-06-08 23:44:45 +0000309 unsigned PhysReg = VRM->getPhys(VirtReg);
310 assert(PhysReg != VirtRegMap::NO_PHYS_REG &&
311 "Instruction uses unmapped VirtReg");
Jakob Stoklund Olesenfb9ebbf2012-10-15 21:57:41 +0000312 assert(!MRI->isReserved(PhysReg) && "Reserved register assignment");
Jakob Stoklund Olesenba05c012011-02-18 22:03:18 +0000313
314 // Preserve semantics of sub-register operands.
315 if (MO.getSubReg()) {
316 // A virtual register kill refers to the whole register, so we may
Jakob Stoklund Olesen200a8ce2011-10-05 00:01:48 +0000317 // have to add <imp-use,kill> operands for the super-register. A
318 // partial redef always kills and redefines the super-register.
319 if (MO.readsReg() && (MO.isDef() || MO.isKill()))
320 SuperKills.push_back(PhysReg);
321
322 if (MO.isDef()) {
323 // The <def,undef> flag only makes sense for sub-register defs, and
324 // we are substituting a full physreg. An <imp-use,kill> operand
325 // from the SuperKills list will represent the partial read of the
326 // super-register.
327 MO.setIsUndef(false);
328
329 // Also add implicit defs for the super-register.
330 if (MO.isDead())
331 SuperDeads.push_back(PhysReg);
332 else
333 SuperDefs.push_back(PhysReg);
334 }
Jakob Stoklund Olesenba05c012011-02-18 22:03:18 +0000335
336 // PhysReg operands cannot have subregister indexes.
337 PhysReg = TRI->getSubReg(PhysReg, MO.getSubReg());
338 assert(PhysReg && "Invalid SubReg for physical register");
339 MO.setSubReg(0);
340 }
341 // Rewrite. Note we could have used MachineOperand::substPhysReg(), but
342 // we need the inlining here.
343 MO.setReg(PhysReg);
344 }
345
346 // Add any missing super-register kills after rewriting the whole
347 // instruction.
348 while (!SuperKills.empty())
349 MI->addRegisterKilled(SuperKills.pop_back_val(), TRI, true);
350
Jakob Stoklund Olesen93e110b2011-04-27 17:42:31 +0000351 while (!SuperDeads.empty())
352 MI->addRegisterDead(SuperDeads.pop_back_val(), TRI, true);
353
354 while (!SuperDefs.empty())
355 MI->addRegisterDefined(SuperDefs.pop_back_val(), TRI);
356
Jakob Stoklund Olesenba05c012011-02-18 22:03:18 +0000357 DEBUG(dbgs() << "> " << *MI);
358
359 // Finally, remove any identity copies.
360 if (MI->isIdentityCopy()) {
Jakob Stoklund Olesencf5e5f32011-05-06 17:59:57 +0000361 ++NumIdCopies;
Jakob Stoklund Olesen280ea1a2011-03-31 17:55:25 +0000362 if (MI->getNumOperands() == 2) {
363 DEBUG(dbgs() << "Deleting identity copy.\n");
Jakob Stoklund Olesen280ea1a2011-03-31 17:55:25 +0000364 if (Indexes)
365 Indexes->removeMachineInstrFromMaps(MI);
366 // It's safe to erase MI because MII has already been incremented.
367 MI->eraseFromParent();
368 } else {
369 // Transform identity copy to a KILL to deal with subregisters.
370 MI->setDesc(TII->get(TargetOpcode::KILL));
371 DEBUG(dbgs() << "Identity copy: " << *MI);
372 }
Jakob Stoklund Olesenba05c012011-02-18 22:03:18 +0000373 }
374 }
375 }
376
377 // Tell MRI about physical registers in use.
Quentin Colombetce734f12013-09-25 00:26:17 +0000378 if (NoReturnInsts.empty()) {
379 for (unsigned Reg = 1, RegE = TRI->getNumRegs(); Reg != RegE; ++Reg)
380 if (!MRI->reg_nodbg_empty(Reg))
381 MRI->setPhysRegUsed(Reg);
382 } else {
383 for (unsigned Reg = 1, RegE = TRI->getNumRegs(); Reg != RegE; ++Reg) {
384 if (MRI->reg_nodbg_empty(Reg))
385 continue;
386 // Check if this register has a use that will impact the rest of the
387 // code. Uses in debug and noreturn instructions do not impact the
388 // generated code.
389 for (MachineRegisterInfo::reg_nodbg_iterator It =
390 MRI->reg_nodbg_begin(Reg),
391 EndIt = MRI->reg_nodbg_end(); It != EndIt; ++It) {
392 if (!NoReturnInsts.count(&(*It))) {
393 MRI->setPhysRegUsed(Reg);
394 break;
395 }
396 }
397 }
398 }
Jakob Stoklund Olesenba05c012011-02-18 22:03:18 +0000399}