blob: bb61682c23287fee6b695380529939abf13f2dfb [file] [log] [blame]
David Goodwin34877712009-10-26 19:32:42 +00001//===----- AggressiveAntiDepBreaker.cpp - Anti-dep breaker -------- ---------===//
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//===----------------------------------------------------------------------===//
9//
10// This file implements the AggressiveAntiDepBreaker class, which
11// implements register anti-dependence breaking during post-RA
12// scheduling. It attempts to break all anti-dependencies within a
13// block.
14//
15//===----------------------------------------------------------------------===//
16
David Goodwin4de099d2009-11-03 20:57:50 +000017#define DEBUG_TYPE "post-RA-sched"
David Goodwin34877712009-10-26 19:32:42 +000018#include "AggressiveAntiDepBreaker.h"
19#include "llvm/CodeGen/MachineBasicBlock.h"
20#include "llvm/CodeGen/MachineFrameInfo.h"
21#include "llvm/CodeGen/MachineInstr.h"
22#include "llvm/Target/TargetInstrInfo.h"
23#include "llvm/Target/TargetMachine.h"
24#include "llvm/Target/TargetRegisterInfo.h"
David Goodwine10deca2009-10-26 22:31:16 +000025#include "llvm/Support/CommandLine.h"
David Goodwin34877712009-10-26 19:32:42 +000026#include "llvm/Support/Debug.h"
27#include "llvm/Support/ErrorHandling.h"
28#include "llvm/Support/raw_ostream.h"
David Goodwin34877712009-10-26 19:32:42 +000029using namespace llvm;
30
David Goodwin3e72d302009-11-19 23:12:37 +000031// If DebugDiv > 0 then only break antidep with (ID % DebugDiv) == DebugMod
32static cl::opt<int>
33DebugDiv("agg-antidep-debugdiv",
34 cl::desc("Debug control for aggressive anti-dep breaker"),
35 cl::init(0), cl::Hidden);
36static cl::opt<int>
37DebugMod("agg-antidep-debugmod",
38 cl::desc("Debug control for aggressive anti-dep breaker"),
39 cl::init(0), cl::Hidden);
40
David Goodwin990d2852009-12-09 17:18:22 +000041AggressiveAntiDepState::AggressiveAntiDepState(const unsigned TargetRegs,
42 MachineBasicBlock *BB) :
43 NumTargetRegs(TargetRegs), GroupNodes(TargetRegs, 0) {
David Goodwin34877712009-10-26 19:32:42 +000044
David Goodwin990d2852009-12-09 17:18:22 +000045 const unsigned BBSize = BB->size();
46 for (unsigned i = 0; i < NumTargetRegs; ++i) {
47 // Initialize all registers to be in their own group. Initially we
48 // assign the register to the same-indexed GroupNode.
49 GroupNodeIndices[i] = i;
50 // Initialize the indices to indicate that no registers are live.
51 KillIndices[i] = ~0u;
52 DefIndices[i] = BBSize;
53 }
David Goodwin34877712009-10-26 19:32:42 +000054}
55
David Goodwine10deca2009-10-26 22:31:16 +000056unsigned AggressiveAntiDepState::GetGroup(unsigned Reg)
David Goodwin34877712009-10-26 19:32:42 +000057{
58 unsigned Node = GroupNodeIndices[Reg];
59 while (GroupNodes[Node] != Node)
60 Node = GroupNodes[Node];
61
62 return Node;
63}
64
David Goodwin87d21b92009-11-13 19:52:48 +000065void AggressiveAntiDepState::GetGroupRegs(
66 unsigned Group,
67 std::vector<unsigned> &Regs,
68 std::multimap<unsigned, AggressiveAntiDepState::RegisterReference> *RegRefs)
David Goodwin34877712009-10-26 19:32:42 +000069{
David Goodwin990d2852009-12-09 17:18:22 +000070 for (unsigned Reg = 0; Reg != NumTargetRegs; ++Reg) {
David Goodwin87d21b92009-11-13 19:52:48 +000071 if ((GetGroup(Reg) == Group) && (RegRefs->count(Reg) > 0))
David Goodwin34877712009-10-26 19:32:42 +000072 Regs.push_back(Reg);
73 }
74}
75
David Goodwine10deca2009-10-26 22:31:16 +000076unsigned AggressiveAntiDepState::UnionGroups(unsigned Reg1, unsigned Reg2)
David Goodwin34877712009-10-26 19:32:42 +000077{
78 assert(GroupNodes[0] == 0 && "GroupNode 0 not parent!");
79 assert(GroupNodeIndices[0] == 0 && "Reg 0 not in Group 0!");
80
81 // find group for each register
82 unsigned Group1 = GetGroup(Reg1);
83 unsigned Group2 = GetGroup(Reg2);
84
85 // if either group is 0, then that must become the parent
86 unsigned Parent = (Group1 == 0) ? Group1 : Group2;
87 unsigned Other = (Parent == Group1) ? Group2 : Group1;
88 GroupNodes.at(Other) = Parent;
89 return Parent;
90}
91
David Goodwine10deca2009-10-26 22:31:16 +000092unsigned AggressiveAntiDepState::LeaveGroup(unsigned Reg)
David Goodwin34877712009-10-26 19:32:42 +000093{
94 // Create a new GroupNode for Reg. Reg's existing GroupNode must
95 // stay as is because there could be other GroupNodes referring to
96 // it.
97 unsigned idx = GroupNodes.size();
98 GroupNodes.push_back(idx);
99 GroupNodeIndices[Reg] = idx;
100 return idx;
101}
102
David Goodwine10deca2009-10-26 22:31:16 +0000103bool AggressiveAntiDepState::IsLive(unsigned Reg)
David Goodwin34877712009-10-26 19:32:42 +0000104{
105 // KillIndex must be defined and DefIndex not defined for a register
106 // to be live.
107 return((KillIndices[Reg] != ~0u) && (DefIndices[Reg] == ~0u));
108}
109
David Goodwine10deca2009-10-26 22:31:16 +0000110
111
112AggressiveAntiDepBreaker::
David Goodwin0855dee2009-11-10 00:15:47 +0000113AggressiveAntiDepBreaker(MachineFunction& MFi,
David Goodwin87d21b92009-11-13 19:52:48 +0000114 TargetSubtarget::RegClassVector& CriticalPathRCs) :
David Goodwine10deca2009-10-26 22:31:16 +0000115 AntiDepBreaker(), MF(MFi),
116 MRI(MF.getRegInfo()),
117 TRI(MF.getTarget().getRegisterInfo()),
118 AllocatableSet(TRI->getAllocatableSet(MF)),
David Goodwin557bbe62009-11-20 19:32:48 +0000119 State(NULL) {
David Goodwin87d21b92009-11-13 19:52:48 +0000120 /* Collect a bitset of all registers that are only broken if they
121 are on the critical path. */
122 for (unsigned i = 0, e = CriticalPathRCs.size(); i < e; ++i) {
123 BitVector CPSet = TRI->getAllocatableSet(MF, CriticalPathRCs[i]);
124 if (CriticalPathSet.none())
125 CriticalPathSet = CPSet;
126 else
127 CriticalPathSet |= CPSet;
128 }
129
130 DEBUG(errs() << "AntiDep Critical-Path Registers:");
131 DEBUG(for (int r = CriticalPathSet.find_first(); r != -1;
132 r = CriticalPathSet.find_next(r))
David Goodwin0855dee2009-11-10 00:15:47 +0000133 errs() << " " << TRI->getName(r));
David Goodwin87d21b92009-11-13 19:52:48 +0000134 DEBUG(errs() << '\n');
David Goodwine10deca2009-10-26 22:31:16 +0000135}
136
137AggressiveAntiDepBreaker::~AggressiveAntiDepBreaker() {
138 delete State;
David Goodwine10deca2009-10-26 22:31:16 +0000139}
140
141void AggressiveAntiDepBreaker::StartBlock(MachineBasicBlock *BB) {
142 assert(State == NULL);
David Goodwin990d2852009-12-09 17:18:22 +0000143 State = new AggressiveAntiDepState(TRI->getNumRegs(), BB);
David Goodwine10deca2009-10-26 22:31:16 +0000144
145 bool IsReturnBlock = (!BB->empty() && BB->back().getDesc().isReturn());
146 unsigned *KillIndices = State->GetKillIndices();
147 unsigned *DefIndices = State->GetDefIndices();
148
149 // Determine the live-out physregs for this block.
150 if (IsReturnBlock) {
151 // In a return block, examine the function live-out regs.
152 for (MachineRegisterInfo::liveout_iterator I = MRI.liveout_begin(),
153 E = MRI.liveout_end(); I != E; ++I) {
154 unsigned Reg = *I;
155 State->UnionGroups(Reg, 0);
156 KillIndices[Reg] = BB->size();
157 DefIndices[Reg] = ~0u;
158 // Repeat, for all aliases.
159 for (const unsigned *Alias = TRI->getAliasSet(Reg); *Alias; ++Alias) {
160 unsigned AliasReg = *Alias;
161 State->UnionGroups(AliasReg, 0);
162 KillIndices[AliasReg] = BB->size();
163 DefIndices[AliasReg] = ~0u;
164 }
165 }
166 } else {
167 // In a non-return block, examine the live-in regs of all successors.
168 for (MachineBasicBlock::succ_iterator SI = BB->succ_begin(),
169 SE = BB->succ_end(); SI != SE; ++SI)
170 for (MachineBasicBlock::livein_iterator I = (*SI)->livein_begin(),
171 E = (*SI)->livein_end(); I != E; ++I) {
172 unsigned Reg = *I;
173 State->UnionGroups(Reg, 0);
174 KillIndices[Reg] = BB->size();
175 DefIndices[Reg] = ~0u;
176 // Repeat, for all aliases.
177 for (const unsigned *Alias = TRI->getAliasSet(Reg); *Alias; ++Alias) {
178 unsigned AliasReg = *Alias;
179 State->UnionGroups(AliasReg, 0);
180 KillIndices[AliasReg] = BB->size();
181 DefIndices[AliasReg] = ~0u;
182 }
183 }
184 }
185
186 // Mark live-out callee-saved registers. In a return block this is
187 // all callee-saved registers. In non-return this is any
188 // callee-saved register that is not saved in the prolog.
189 const MachineFrameInfo *MFI = MF.getFrameInfo();
190 BitVector Pristine = MFI->getPristineRegs(BB);
191 for (const unsigned *I = TRI->getCalleeSavedRegs(); *I; ++I) {
192 unsigned Reg = *I;
193 if (!IsReturnBlock && !Pristine.test(Reg)) continue;
194 State->UnionGroups(Reg, 0);
195 KillIndices[Reg] = BB->size();
196 DefIndices[Reg] = ~0u;
197 // Repeat, for all aliases.
198 for (const unsigned *Alias = TRI->getAliasSet(Reg); *Alias; ++Alias) {
199 unsigned AliasReg = *Alias;
200 State->UnionGroups(AliasReg, 0);
201 KillIndices[AliasReg] = BB->size();
202 DefIndices[AliasReg] = ~0u;
203 }
204 }
205}
206
207void AggressiveAntiDepBreaker::FinishBlock() {
208 delete State;
209 State = NULL;
David Goodwine10deca2009-10-26 22:31:16 +0000210}
211
212void AggressiveAntiDepBreaker::Observe(MachineInstr *MI, unsigned Count,
213 unsigned InsertPosIndex) {
214 assert(Count < InsertPosIndex && "Instruction index out of expected range!");
215
David Goodwin5b3c3082009-10-29 23:30:59 +0000216 std::set<unsigned> PassthruRegs;
217 GetPassthruRegs(MI, PassthruRegs);
218 PrescanInstruction(MI, Count, PassthruRegs);
219 ScanInstruction(MI, Count);
220
David Goodwine10deca2009-10-26 22:31:16 +0000221 DEBUG(errs() << "Observe: ");
222 DEBUG(MI->dump());
David Goodwin5b3c3082009-10-29 23:30:59 +0000223 DEBUG(errs() << "\tRegs:");
David Goodwine10deca2009-10-26 22:31:16 +0000224
225 unsigned *DefIndices = State->GetDefIndices();
David Goodwin990d2852009-12-09 17:18:22 +0000226 for (unsigned Reg = 0; Reg != TRI->getNumRegs(); ++Reg) {
David Goodwine10deca2009-10-26 22:31:16 +0000227 // If Reg is current live, then mark that it can't be renamed as
228 // we don't know the extent of its live-range anymore (now that it
229 // has been scheduled). If it is not live but was defined in the
230 // previous schedule region, then set its def index to the most
231 // conservative location (i.e. the beginning of the previous
232 // schedule region).
233 if (State->IsLive(Reg)) {
234 DEBUG(if (State->GetGroup(Reg) != 0)
235 errs() << " " << TRI->getName(Reg) << "=g" <<
236 State->GetGroup(Reg) << "->g0(region live-out)");
237 State->UnionGroups(Reg, 0);
238 } else if ((DefIndices[Reg] < InsertPosIndex) && (DefIndices[Reg] >= Count)) {
239 DefIndices[Reg] = Count;
240 }
241 }
David Goodwin5b3c3082009-10-29 23:30:59 +0000242 DEBUG(errs() << '\n');
David Goodwine10deca2009-10-26 22:31:16 +0000243}
244
David Goodwin34877712009-10-26 19:32:42 +0000245bool AggressiveAntiDepBreaker::IsImplicitDefUse(MachineInstr *MI,
246 MachineOperand& MO)
247{
248 if (!MO.isReg() || !MO.isImplicit())
249 return false;
250
251 unsigned Reg = MO.getReg();
252 if (Reg == 0)
253 return false;
254
255 MachineOperand *Op = NULL;
256 if (MO.isDef())
257 Op = MI->findRegisterUseOperand(Reg, true);
258 else
259 Op = MI->findRegisterDefOperand(Reg);
260
261 return((Op != NULL) && Op->isImplicit());
262}
263
264void AggressiveAntiDepBreaker::GetPassthruRegs(MachineInstr *MI,
265 std::set<unsigned>& PassthruRegs) {
266 for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
267 MachineOperand &MO = MI->getOperand(i);
268 if (!MO.isReg()) continue;
269 if ((MO.isDef() && MI->isRegTiedToUseOperand(i)) ||
270 IsImplicitDefUse(MI, MO)) {
271 const unsigned Reg = MO.getReg();
272 PassthruRegs.insert(Reg);
273 for (const unsigned *Subreg = TRI->getSubRegisters(Reg);
274 *Subreg; ++Subreg) {
275 PassthruRegs.insert(*Subreg);
276 }
277 }
278 }
279}
280
David Goodwin557bbe62009-11-20 19:32:48 +0000281/// AntiDepEdges - Return in Edges the anti- and output- dependencies
282/// in SU that we want to consider for breaking.
283static void AntiDepEdges(SUnit *SU, std::vector<SDep*>& Edges) {
284 SmallSet<unsigned, 4> RegSet;
David Goodwin34877712009-10-26 19:32:42 +0000285 for (SUnit::pred_iterator P = SU->Preds.begin(), PE = SU->Preds.end();
286 P != PE; ++P) {
David Goodwin12dd99d2009-11-12 19:08:21 +0000287 if ((P->getKind() == SDep::Anti) || (P->getKind() == SDep::Output)) {
David Goodwin34877712009-10-26 19:32:42 +0000288 unsigned Reg = P->getReg();
David Goodwin557bbe62009-11-20 19:32:48 +0000289 if (RegSet.count(Reg) == 0) {
David Goodwin34877712009-10-26 19:32:42 +0000290 Edges.push_back(&*P);
David Goodwin557bbe62009-11-20 19:32:48 +0000291 RegSet.insert(Reg);
David Goodwin34877712009-10-26 19:32:42 +0000292 }
293 }
294 }
295}
296
David Goodwin87d21b92009-11-13 19:52:48 +0000297/// CriticalPathStep - Return the next SUnit after SU on the bottom-up
298/// critical path.
299static SUnit *CriticalPathStep(SUnit *SU) {
300 SDep *Next = 0;
301 unsigned NextDepth = 0;
302 // Find the predecessor edge with the greatest depth.
303 if (SU != 0) {
304 for (SUnit::pred_iterator P = SU->Preds.begin(), PE = SU->Preds.end();
305 P != PE; ++P) {
306 SUnit *PredSU = P->getSUnit();
307 unsigned PredLatency = P->getLatency();
308 unsigned PredTotalLatency = PredSU->getDepth() + PredLatency;
309 // In the case of a latency tie, prefer an anti-dependency edge over
310 // other types of edges.
311 if (NextDepth < PredTotalLatency ||
312 (NextDepth == PredTotalLatency && P->getKind() == SDep::Anti)) {
313 NextDepth = PredTotalLatency;
314 Next = &*P;
315 }
316 }
317 }
318
319 return (Next) ? Next->getSUnit() : 0;
320}
321
David Goodwin67a8a7b2009-10-29 19:17:04 +0000322void AggressiveAntiDepBreaker::HandleLastUse(unsigned Reg, unsigned KillIdx,
David Goodwin3e72d302009-11-19 23:12:37 +0000323 const char *tag, const char *header,
324 const char *footer) {
David Goodwin67a8a7b2009-10-29 19:17:04 +0000325 unsigned *KillIndices = State->GetKillIndices();
326 unsigned *DefIndices = State->GetDefIndices();
327 std::multimap<unsigned, AggressiveAntiDepState::RegisterReference>&
328 RegRefs = State->GetRegRefs();
329
330 if (!State->IsLive(Reg)) {
331 KillIndices[Reg] = KillIdx;
332 DefIndices[Reg] = ~0u;
333 RegRefs.erase(Reg);
334 State->LeaveGroup(Reg);
David Goodwin3e72d302009-11-19 23:12:37 +0000335 DEBUG(if (header != NULL) {
336 errs() << header << TRI->getName(Reg); header = NULL; });
David Goodwin67a8a7b2009-10-29 19:17:04 +0000337 DEBUG(errs() << "->g" << State->GetGroup(Reg) << tag);
338 }
339 // Repeat for subregisters.
340 for (const unsigned *Subreg = TRI->getSubRegisters(Reg);
341 *Subreg; ++Subreg) {
342 unsigned SubregReg = *Subreg;
343 if (!State->IsLive(SubregReg)) {
344 KillIndices[SubregReg] = KillIdx;
345 DefIndices[SubregReg] = ~0u;
346 RegRefs.erase(SubregReg);
347 State->LeaveGroup(SubregReg);
David Goodwin3e72d302009-11-19 23:12:37 +0000348 DEBUG(if (header != NULL) {
349 errs() << header << TRI->getName(Reg); header = NULL; });
David Goodwin67a8a7b2009-10-29 19:17:04 +0000350 DEBUG(errs() << " " << TRI->getName(SubregReg) << "->g" <<
351 State->GetGroup(SubregReg) << tag);
352 }
353 }
David Goodwin3e72d302009-11-19 23:12:37 +0000354
355 DEBUG(if ((header == NULL) && (footer != NULL)) errs() << footer);
David Goodwin67a8a7b2009-10-29 19:17:04 +0000356}
357
David Goodwin34877712009-10-26 19:32:42 +0000358void AggressiveAntiDepBreaker::PrescanInstruction(MachineInstr *MI, unsigned Count,
359 std::set<unsigned>& PassthruRegs) {
David Goodwine10deca2009-10-26 22:31:16 +0000360 unsigned *DefIndices = State->GetDefIndices();
361 std::multimap<unsigned, AggressiveAntiDepState::RegisterReference>&
362 RegRefs = State->GetRegRefs();
363
David Goodwin67a8a7b2009-10-29 19:17:04 +0000364 // Handle dead defs by simulating a last-use of the register just
365 // after the def. A dead def can occur because the def is truely
366 // dead, or because only a subregister is live at the def. If we
367 // don't do this the dead def will be incorrectly merged into the
368 // previous def.
David Goodwin34877712009-10-26 19:32:42 +0000369 for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
370 MachineOperand &MO = MI->getOperand(i);
371 if (!MO.isReg() || !MO.isDef()) continue;
372 unsigned Reg = MO.getReg();
373 if (Reg == 0) continue;
David Goodwin67a8a7b2009-10-29 19:17:04 +0000374
David Goodwin3e72d302009-11-19 23:12:37 +0000375 HandleLastUse(Reg, Count + 1, "", "\tDead Def: ", "\n");
David Goodwin34877712009-10-26 19:32:42 +0000376 }
377
378 DEBUG(errs() << "\tDef Groups:");
379 for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
380 MachineOperand &MO = MI->getOperand(i);
381 if (!MO.isReg() || !MO.isDef()) continue;
382 unsigned Reg = MO.getReg();
383 if (Reg == 0) continue;
384
David Goodwine10deca2009-10-26 22:31:16 +0000385 DEBUG(errs() << " " << TRI->getName(Reg) << "=g" << State->GetGroup(Reg));
David Goodwin34877712009-10-26 19:32:42 +0000386
David Goodwin67a8a7b2009-10-29 19:17:04 +0000387 // If MI's defs have a special allocation requirement, don't allow
David Goodwin34877712009-10-26 19:32:42 +0000388 // any def registers to be changed. Also assume all registers
389 // defined in a call must not be changed (ABI).
390 if (MI->getDesc().isCall() || MI->getDesc().hasExtraDefRegAllocReq()) {
David Goodwine10deca2009-10-26 22:31:16 +0000391 DEBUG(if (State->GetGroup(Reg) != 0) errs() << "->g0(alloc-req)");
392 State->UnionGroups(Reg, 0);
David Goodwin34877712009-10-26 19:32:42 +0000393 }
394
395 // Any aliased that are live at this point are completely or
David Goodwin67a8a7b2009-10-29 19:17:04 +0000396 // partially defined here, so group those aliases with Reg.
David Goodwin34877712009-10-26 19:32:42 +0000397 for (const unsigned *Alias = TRI->getAliasSet(Reg); *Alias; ++Alias) {
398 unsigned AliasReg = *Alias;
David Goodwine10deca2009-10-26 22:31:16 +0000399 if (State->IsLive(AliasReg)) {
400 State->UnionGroups(Reg, AliasReg);
401 DEBUG(errs() << "->g" << State->GetGroup(Reg) << "(via " <<
David Goodwin34877712009-10-26 19:32:42 +0000402 TRI->getName(AliasReg) << ")");
403 }
404 }
405
406 // Note register reference...
407 const TargetRegisterClass *RC = NULL;
408 if (i < MI->getDesc().getNumOperands())
409 RC = MI->getDesc().OpInfo[i].getRegClass(TRI);
David Goodwine10deca2009-10-26 22:31:16 +0000410 AggressiveAntiDepState::RegisterReference RR = { &MO, RC };
David Goodwin34877712009-10-26 19:32:42 +0000411 RegRefs.insert(std::make_pair(Reg, RR));
412 }
413
414 DEBUG(errs() << '\n');
David Goodwin67a8a7b2009-10-29 19:17:04 +0000415
416 // Scan the register defs for this instruction and update
417 // live-ranges.
418 for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
419 MachineOperand &MO = MI->getOperand(i);
420 if (!MO.isReg() || !MO.isDef()) continue;
421 unsigned Reg = MO.getReg();
422 if (Reg == 0) continue;
David Goodwin3e72d302009-11-19 23:12:37 +0000423 // Ignore KILLs and passthru registers for liveness...
424 if ((MI->getOpcode() == TargetInstrInfo::KILL) ||
425 (PassthruRegs.count(Reg) != 0))
426 continue;
David Goodwin67a8a7b2009-10-29 19:17:04 +0000427
David Goodwin3e72d302009-11-19 23:12:37 +0000428 // Update def for Reg and aliases.
David Goodwin67a8a7b2009-10-29 19:17:04 +0000429 DefIndices[Reg] = Count;
David Goodwin3e72d302009-11-19 23:12:37 +0000430 for (const unsigned *Alias = TRI->getAliasSet(Reg);
431 *Alias; ++Alias) {
432 unsigned AliasReg = *Alias;
433 DefIndices[AliasReg] = Count;
David Goodwin67a8a7b2009-10-29 19:17:04 +0000434 }
435 }
David Goodwin34877712009-10-26 19:32:42 +0000436}
437
438void AggressiveAntiDepBreaker::ScanInstruction(MachineInstr *MI,
439 unsigned Count) {
440 DEBUG(errs() << "\tUse Groups:");
David Goodwine10deca2009-10-26 22:31:16 +0000441 std::multimap<unsigned, AggressiveAntiDepState::RegisterReference>&
442 RegRefs = State->GetRegRefs();
David Goodwin34877712009-10-26 19:32:42 +0000443
444 // Scan the register uses for this instruction and update
445 // live-ranges, groups and RegRefs.
446 for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
447 MachineOperand &MO = MI->getOperand(i);
448 if (!MO.isReg() || !MO.isUse()) continue;
449 unsigned Reg = MO.getReg();
450 if (Reg == 0) continue;
451
David Goodwine10deca2009-10-26 22:31:16 +0000452 DEBUG(errs() << " " << TRI->getName(Reg) << "=g" <<
453 State->GetGroup(Reg));
David Goodwin34877712009-10-26 19:32:42 +0000454
455 // It wasn't previously live but now it is, this is a kill. Forget
456 // the previous live-range information and start a new live-range
457 // for the register.
David Goodwin67a8a7b2009-10-29 19:17:04 +0000458 HandleLastUse(Reg, Count, "(last-use)");
David Goodwin34877712009-10-26 19:32:42 +0000459
460 // If MI's uses have special allocation requirement, don't allow
461 // any use registers to be changed. Also assume all registers
462 // used in a call must not be changed (ABI).
463 if (MI->getDesc().isCall() || MI->getDesc().hasExtraSrcRegAllocReq()) {
David Goodwine10deca2009-10-26 22:31:16 +0000464 DEBUG(if (State->GetGroup(Reg) != 0) errs() << "->g0(alloc-req)");
465 State->UnionGroups(Reg, 0);
David Goodwin34877712009-10-26 19:32:42 +0000466 }
467
468 // Note register reference...
469 const TargetRegisterClass *RC = NULL;
470 if (i < MI->getDesc().getNumOperands())
471 RC = MI->getDesc().OpInfo[i].getRegClass(TRI);
David Goodwine10deca2009-10-26 22:31:16 +0000472 AggressiveAntiDepState::RegisterReference RR = { &MO, RC };
David Goodwin34877712009-10-26 19:32:42 +0000473 RegRefs.insert(std::make_pair(Reg, RR));
474 }
475
476 DEBUG(errs() << '\n');
477
478 // Form a group of all defs and uses of a KILL instruction to ensure
479 // that all registers are renamed as a group.
480 if (MI->getOpcode() == TargetInstrInfo::KILL) {
481 DEBUG(errs() << "\tKill Group:");
482
483 unsigned FirstReg = 0;
484 for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
485 MachineOperand &MO = MI->getOperand(i);
486 if (!MO.isReg()) continue;
487 unsigned Reg = MO.getReg();
488 if (Reg == 0) continue;
489
490 if (FirstReg != 0) {
491 DEBUG(errs() << "=" << TRI->getName(Reg));
David Goodwine10deca2009-10-26 22:31:16 +0000492 State->UnionGroups(FirstReg, Reg);
David Goodwin34877712009-10-26 19:32:42 +0000493 } else {
494 DEBUG(errs() << " " << TRI->getName(Reg));
495 FirstReg = Reg;
496 }
497 }
498
David Goodwine10deca2009-10-26 22:31:16 +0000499 DEBUG(errs() << "->g" << State->GetGroup(FirstReg) << '\n');
David Goodwin34877712009-10-26 19:32:42 +0000500 }
501}
502
503BitVector AggressiveAntiDepBreaker::GetRenameRegisters(unsigned Reg) {
504 BitVector BV(TRI->getNumRegs(), false);
505 bool first = true;
506
507 // Check all references that need rewriting for Reg. For each, use
508 // the corresponding register class to narrow the set of registers
509 // that are appropriate for renaming.
David Goodwine10deca2009-10-26 22:31:16 +0000510 std::pair<std::multimap<unsigned,
511 AggressiveAntiDepState::RegisterReference>::iterator,
512 std::multimap<unsigned,
513 AggressiveAntiDepState::RegisterReference>::iterator>
514 Range = State->GetRegRefs().equal_range(Reg);
515 for (std::multimap<unsigned, AggressiveAntiDepState::RegisterReference>::iterator
David Goodwin34877712009-10-26 19:32:42 +0000516 Q = Range.first, QE = Range.second; Q != QE; ++Q) {
517 const TargetRegisterClass *RC = Q->second.RC;
518 if (RC == NULL) continue;
519
520 BitVector RCBV = TRI->getAllocatableSet(MF, RC);
521 if (first) {
522 BV |= RCBV;
523 first = false;
524 } else {
525 BV &= RCBV;
526 }
527
528 DEBUG(errs() << " " << RC->getName());
529 }
530
531 return BV;
532}
533
534bool AggressiveAntiDepBreaker::FindSuitableFreeRegisters(
David Goodwin54097832009-11-05 01:19:35 +0000535 unsigned AntiDepGroupIndex,
536 RenameOrderType& RenameOrder,
537 std::map<unsigned, unsigned> &RenameMap) {
David Goodwine10deca2009-10-26 22:31:16 +0000538 unsigned *KillIndices = State->GetKillIndices();
539 unsigned *DefIndices = State->GetDefIndices();
540 std::multimap<unsigned, AggressiveAntiDepState::RegisterReference>&
541 RegRefs = State->GetRegRefs();
542
David Goodwin87d21b92009-11-13 19:52:48 +0000543 // Collect all referenced registers in the same group as
544 // AntiDepReg. These all need to be renamed together if we are to
545 // break the anti-dependence.
David Goodwin34877712009-10-26 19:32:42 +0000546 std::vector<unsigned> Regs;
David Goodwin87d21b92009-11-13 19:52:48 +0000547 State->GetGroupRegs(AntiDepGroupIndex, Regs, &RegRefs);
David Goodwin34877712009-10-26 19:32:42 +0000548 assert(Regs.size() > 0 && "Empty register group!");
549 if (Regs.size() == 0)
550 return false;
551
552 // Find the "superest" register in the group. At the same time,
553 // collect the BitVector of registers that can be used to rename
554 // each register.
555 DEBUG(errs() << "\tRename Candidates for Group g" << AntiDepGroupIndex << ":\n");
556 std::map<unsigned, BitVector> RenameRegisterMap;
557 unsigned SuperReg = 0;
558 for (unsigned i = 0, e = Regs.size(); i != e; ++i) {
559 unsigned Reg = Regs[i];
560 if ((SuperReg == 0) || TRI->isSuperRegister(SuperReg, Reg))
561 SuperReg = Reg;
562
563 // If Reg has any references, then collect possible rename regs
564 if (RegRefs.count(Reg) > 0) {
565 DEBUG(errs() << "\t\t" << TRI->getName(Reg) << ":");
566
567 BitVector BV = GetRenameRegisters(Reg);
568 RenameRegisterMap.insert(std::pair<unsigned, BitVector>(Reg, BV));
569
570 DEBUG(errs() << " ::");
571 DEBUG(for (int r = BV.find_first(); r != -1; r = BV.find_next(r))
572 errs() << " " << TRI->getName(r));
573 DEBUG(errs() << "\n");
574 }
575 }
576
577 // All group registers should be a subreg of SuperReg.
578 for (unsigned i = 0, e = Regs.size(); i != e; ++i) {
579 unsigned Reg = Regs[i];
580 if (Reg == SuperReg) continue;
581 bool IsSub = TRI->isSubRegister(SuperReg, Reg);
582 assert(IsSub && "Expecting group subregister");
583 if (!IsSub)
584 return false;
585 }
586
David Goodwin00621ef2009-11-20 23:33:54 +0000587#ifndef NDEBUG
588 // If DebugDiv > 0 then only rename (renamecnt % DebugDiv) == DebugMod
589 if (DebugDiv > 0) {
590 static int renamecnt = 0;
591 if (renamecnt++ % DebugDiv != DebugMod)
592 return false;
593
594 errs() << "*** Performing rename " << TRI->getName(SuperReg) <<
595 " for debug ***\n";
596 }
597#endif
598
David Goodwin54097832009-11-05 01:19:35 +0000599 // Check each possible rename register for SuperReg in round-robin
600 // order. If that register is available, and the corresponding
601 // registers are available for the other group subregisters, then we
602 // can use those registers to rename.
David Goodwin54097832009-11-05 01:19:35 +0000603 const TargetRegisterClass *SuperRC =
604 TRI->getPhysicalRegisterRegClass(SuperReg, MVT::Other);
605
606 const TargetRegisterClass::iterator RB = SuperRC->allocation_order_begin(MF);
607 const TargetRegisterClass::iterator RE = SuperRC->allocation_order_end(MF);
608 if (RB == RE) {
David Goodwin00621ef2009-11-20 23:33:54 +0000609 DEBUG(errs() << "\tEmpty Super Regclass!!\n");
David Goodwin54097832009-11-05 01:19:35 +0000610 return false;
611 }
612
David Goodwin00621ef2009-11-20 23:33:54 +0000613 DEBUG(errs() << "\tFind Registers:");
David Goodwin3e72d302009-11-19 23:12:37 +0000614
David Goodwin54097832009-11-05 01:19:35 +0000615 if (RenameOrder.count(SuperRC) == 0)
616 RenameOrder.insert(RenameOrderType::value_type(SuperRC, RE));
617
David Goodwin98f2f1a2009-11-05 01:45:50 +0000618 const TargetRegisterClass::iterator OrigR = RenameOrder[SuperRC];
David Goodwin54097832009-11-05 01:19:35 +0000619 const TargetRegisterClass::iterator EndR = ((OrigR == RE) ? RB : OrigR);
620 TargetRegisterClass::iterator R = OrigR;
621 do {
622 if (R == RB) R = RE;
623 --R;
David Goodwin00621ef2009-11-20 23:33:54 +0000624 const unsigned NewSuperReg = *R;
David Goodwin34877712009-10-26 19:32:42 +0000625 // Don't replace a register with itself.
David Goodwin00621ef2009-11-20 23:33:54 +0000626 if (NewSuperReg == SuperReg) continue;
David Goodwin54097832009-11-05 01:19:35 +0000627
David Goodwin00621ef2009-11-20 23:33:54 +0000628 DEBUG(errs() << " [" << TRI->getName(NewSuperReg) << ':');
629 RenameMap.clear();
630
631 // For each referenced group register (which must be a SuperReg or
632 // a subregister of SuperReg), find the corresponding subregister
633 // of NewSuperReg and make sure it is free to be renamed.
634 for (unsigned i = 0, e = Regs.size(); i != e; ++i) {
635 unsigned Reg = Regs[i];
636 unsigned NewReg = 0;
637 if (Reg == SuperReg) {
638 NewReg = NewSuperReg;
639 } else {
640 unsigned NewSubRegIdx = TRI->getSubRegIndex(SuperReg, Reg);
641 if (NewSubRegIdx != 0)
642 NewReg = TRI->getSubReg(NewSuperReg, NewSubRegIdx);
David Goodwin34877712009-10-26 19:32:42 +0000643 }
David Goodwin00621ef2009-11-20 23:33:54 +0000644
645 DEBUG(errs() << " " << TRI->getName(NewReg));
646
647 // Check if Reg can be renamed to NewReg.
648 BitVector BV = RenameRegisterMap[Reg];
649 if (!BV.test(NewReg)) {
650 DEBUG(errs() << "(no rename)");
651 goto next_super_reg;
652 }
653
654 // If NewReg is dead and NewReg's most recent def is not before
655 // Regs's kill, it's safe to replace Reg with NewReg. We
656 // must also check all aliases of NewReg, because we can't define a
657 // register when any sub or super is already live.
658 if (State->IsLive(NewReg) || (KillIndices[Reg] > DefIndices[NewReg])) {
659 DEBUG(errs() << "(live)");
660 goto next_super_reg;
661 } else {
662 bool found = false;
663 for (const unsigned *Alias = TRI->getAliasSet(NewReg);
664 *Alias; ++Alias) {
665 unsigned AliasReg = *Alias;
666 if (State->IsLive(AliasReg) || (KillIndices[Reg] > DefIndices[AliasReg])) {
667 DEBUG(errs() << "(alias " << TRI->getName(AliasReg) << " live)");
668 found = true;
669 break;
670 }
671 }
672 if (found)
673 goto next_super_reg;
674 }
675
676 // Record that 'Reg' can be renamed to 'NewReg'.
677 RenameMap.insert(std::pair<unsigned, unsigned>(Reg, NewReg));
David Goodwin34877712009-10-26 19:32:42 +0000678 }
David Goodwin54097832009-11-05 01:19:35 +0000679
David Goodwin00621ef2009-11-20 23:33:54 +0000680 // If we fall-out here, then every register in the group can be
681 // renamed, as recorded in RenameMap.
682 RenameOrder.erase(SuperRC);
683 RenameOrder.insert(RenameOrderType::value_type(SuperRC, R));
684 DEBUG(errs() << "]\n");
685 return true;
686
687 next_super_reg:
688 DEBUG(errs() << ']');
David Goodwin54097832009-11-05 01:19:35 +0000689 } while (R != EndR);
David Goodwin34877712009-10-26 19:32:42 +0000690
691 DEBUG(errs() << '\n');
692
693 // No registers are free and available!
694 return false;
695}
696
697/// BreakAntiDependencies - Identifiy anti-dependencies within the
698/// ScheduleDAG and break them by renaming registers.
699///
David Goodwine10deca2009-10-26 22:31:16 +0000700unsigned AggressiveAntiDepBreaker::BreakAntiDependencies(
701 std::vector<SUnit>& SUnits,
702 MachineBasicBlock::iterator& Begin,
703 MachineBasicBlock::iterator& End,
704 unsigned InsertPosIndex) {
705 unsigned *KillIndices = State->GetKillIndices();
706 unsigned *DefIndices = State->GetDefIndices();
707 std::multimap<unsigned, AggressiveAntiDepState::RegisterReference>&
708 RegRefs = State->GetRegRefs();
709
David Goodwin34877712009-10-26 19:32:42 +0000710 // The code below assumes that there is at least one instruction,
711 // so just duck out immediately if the block is empty.
David Goodwin4de099d2009-11-03 20:57:50 +0000712 if (SUnits.empty()) return 0;
David Goodwine10deca2009-10-26 22:31:16 +0000713
David Goodwin54097832009-11-05 01:19:35 +0000714 // For each regclass the next register to use for renaming.
715 RenameOrderType RenameOrder;
David Goodwin34877712009-10-26 19:32:42 +0000716
717 // ...need a map from MI to SUnit.
718 std::map<MachineInstr *, SUnit *> MISUnitMap;
David Goodwin34877712009-10-26 19:32:42 +0000719 for (unsigned i = 0, e = SUnits.size(); i != e; ++i) {
720 SUnit *SU = &SUnits[i];
721 MISUnitMap.insert(std::pair<MachineInstr *, SUnit *>(SU->getInstr(), SU));
722 }
723
David Goodwin87d21b92009-11-13 19:52:48 +0000724 // Track progress along the critical path through the SUnit graph as
725 // we walk the instructions. This is needed for regclasses that only
726 // break critical-path anti-dependencies.
727 SUnit *CriticalPathSU = 0;
728 MachineInstr *CriticalPathMI = 0;
729 if (CriticalPathSet.any()) {
730 for (unsigned i = 0, e = SUnits.size(); i != e; ++i) {
731 SUnit *SU = &SUnits[i];
732 if (!CriticalPathSU ||
733 ((SU->getDepth() + SU->Latency) >
734 (CriticalPathSU->getDepth() + CriticalPathSU->Latency))) {
735 CriticalPathSU = SU;
736 }
737 }
738
739 CriticalPathMI = CriticalPathSU->getInstr();
740 }
741
David Goodwin34877712009-10-26 19:32:42 +0000742#ifndef NDEBUG
David Goodwin557bbe62009-11-20 19:32:48 +0000743 DEBUG(errs() << "\n===== Aggressive anti-dependency breaking\n");
744 DEBUG(errs() << "Available regs:");
745 for (unsigned Reg = 0; Reg < TRI->getNumRegs(); ++Reg) {
746 if (!State->IsLive(Reg))
747 DEBUG(errs() << " " << TRI->getName(Reg));
David Goodwin34877712009-10-26 19:32:42 +0000748 }
David Goodwin557bbe62009-11-20 19:32:48 +0000749 DEBUG(errs() << '\n');
David Goodwin34877712009-10-26 19:32:42 +0000750#endif
751
752 // Attempt to break anti-dependence edges. Walk the instructions
753 // from the bottom up, tracking information about liveness as we go
754 // to help determine which registers are available.
755 unsigned Broken = 0;
756 unsigned Count = InsertPosIndex - 1;
757 for (MachineBasicBlock::iterator I = End, E = Begin;
758 I != E; --Count) {
759 MachineInstr *MI = --I;
760
761 DEBUG(errs() << "Anti: ");
762 DEBUG(MI->dump());
763
764 std::set<unsigned> PassthruRegs;
765 GetPassthruRegs(MI, PassthruRegs);
766
767 // Process the defs in MI...
768 PrescanInstruction(MI, Count, PassthruRegs);
David Goodwin87d21b92009-11-13 19:52:48 +0000769
David Goodwin557bbe62009-11-20 19:32:48 +0000770 // The dependence edges that represent anti- and output-
David Goodwin87d21b92009-11-13 19:52:48 +0000771 // dependencies that are candidates for breaking.
David Goodwin34877712009-10-26 19:32:42 +0000772 std::vector<SDep*> Edges;
773 SUnit *PathSU = MISUnitMap[MI];
David Goodwin557bbe62009-11-20 19:32:48 +0000774 AntiDepEdges(PathSU, Edges);
David Goodwin87d21b92009-11-13 19:52:48 +0000775
776 // If MI is not on the critical path, then we don't rename
777 // registers in the CriticalPathSet.
778 BitVector *ExcludeRegs = NULL;
779 if (MI == CriticalPathMI) {
780 CriticalPathSU = CriticalPathStep(CriticalPathSU);
781 CriticalPathMI = (CriticalPathSU) ? CriticalPathSU->getInstr() : 0;
782 } else {
783 ExcludeRegs = &CriticalPathSet;
784 }
785
David Goodwin34877712009-10-26 19:32:42 +0000786 // Ignore KILL instructions (they form a group in ScanInstruction
787 // but don't cause any anti-dependence breaking themselves)
788 if (MI->getOpcode() != TargetInstrInfo::KILL) {
789 // Attempt to break each anti-dependency...
790 for (unsigned i = 0, e = Edges.size(); i != e; ++i) {
791 SDep *Edge = Edges[i];
792 SUnit *NextSU = Edge->getSUnit();
793
David Goodwin12dd99d2009-11-12 19:08:21 +0000794 if ((Edge->getKind() != SDep::Anti) &&
795 (Edge->getKind() != SDep::Output)) continue;
David Goodwin34877712009-10-26 19:32:42 +0000796
797 unsigned AntiDepReg = Edge->getReg();
798 DEBUG(errs() << "\tAntidep reg: " << TRI->getName(AntiDepReg));
799 assert(AntiDepReg != 0 && "Anti-dependence on reg0?");
800
801 if (!AllocatableSet.test(AntiDepReg)) {
802 // Don't break anti-dependencies on non-allocatable registers.
803 DEBUG(errs() << " (non-allocatable)\n");
804 continue;
David Goodwin87d21b92009-11-13 19:52:48 +0000805 } else if ((ExcludeRegs != NULL) && ExcludeRegs->test(AntiDepReg)) {
806 // Don't break anti-dependencies for critical path registers
807 // if not on the critical path
808 DEBUG(errs() << " (not critical-path)\n");
809 continue;
David Goodwin34877712009-10-26 19:32:42 +0000810 } else if (PassthruRegs.count(AntiDepReg) != 0) {
811 // If the anti-dep register liveness "passes-thru", then
812 // don't try to change it. It will be changed along with
813 // the use if required to break an earlier antidep.
814 DEBUG(errs() << " (passthru)\n");
815 continue;
816 } else {
817 // No anti-dep breaking for implicit deps
818 MachineOperand *AntiDepOp = MI->findRegisterDefOperand(AntiDepReg);
819 assert(AntiDepOp != NULL && "Can't find index for defined register operand");
820 if ((AntiDepOp == NULL) || AntiDepOp->isImplicit()) {
821 DEBUG(errs() << " (implicit)\n");
822 continue;
823 }
824
825 // If the SUnit has other dependencies on the SUnit that
826 // it anti-depends on, don't bother breaking the
827 // anti-dependency since those edges would prevent such
828 // units from being scheduled past each other
829 // regardless.
David Goodwin557bbe62009-11-20 19:32:48 +0000830 //
831 // Also, if there are dependencies on other SUnits with the
832 // same register as the anti-dependency, don't attempt to
833 // break it.
David Goodwin34877712009-10-26 19:32:42 +0000834 for (SUnit::pred_iterator P = PathSU->Preds.begin(),
835 PE = PathSU->Preds.end(); P != PE; ++P) {
David Goodwin557bbe62009-11-20 19:32:48 +0000836 if (P->getSUnit() == NextSU ?
837 (P->getKind() != SDep::Anti || P->getReg() != AntiDepReg) :
838 (P->getKind() == SDep::Data && P->getReg() == AntiDepReg)) {
839 AntiDepReg = 0;
840 break;
841 }
842 }
843 for (SUnit::pred_iterator P = PathSU->Preds.begin(),
844 PE = PathSU->Preds.end(); P != PE; ++P) {
845 if ((P->getSUnit() == NextSU) && (P->getKind() != SDep::Anti) &&
846 (P->getKind() != SDep::Output)) {
David Goodwin34877712009-10-26 19:32:42 +0000847 DEBUG(errs() << " (real dependency)\n");
848 AntiDepReg = 0;
849 break;
David Goodwin557bbe62009-11-20 19:32:48 +0000850 } else if ((P->getSUnit() != NextSU) &&
851 (P->getKind() == SDep::Data) &&
852 (P->getReg() == AntiDepReg)) {
853 DEBUG(errs() << " (other dependency)\n");
854 AntiDepReg = 0;
855 break;
David Goodwin34877712009-10-26 19:32:42 +0000856 }
857 }
858
859 if (AntiDepReg == 0) continue;
860 }
861
862 assert(AntiDepReg != 0);
863 if (AntiDepReg == 0) continue;
864
865 // Determine AntiDepReg's register group.
David Goodwine10deca2009-10-26 22:31:16 +0000866 const unsigned GroupIndex = State->GetGroup(AntiDepReg);
David Goodwin34877712009-10-26 19:32:42 +0000867 if (GroupIndex == 0) {
868 DEBUG(errs() << " (zero group)\n");
869 continue;
870 }
871
872 DEBUG(errs() << '\n');
873
874 // Look for a suitable register to use to break the anti-dependence.
875 std::map<unsigned, unsigned> RenameMap;
David Goodwin54097832009-11-05 01:19:35 +0000876 if (FindSuitableFreeRegisters(GroupIndex, RenameOrder, RenameMap)) {
David Goodwin34877712009-10-26 19:32:42 +0000877 DEBUG(errs() << "\tBreaking anti-dependence edge on "
878 << TRI->getName(AntiDepReg) << ":");
879
880 // Handle each group register...
881 for (std::map<unsigned, unsigned>::iterator
882 S = RenameMap.begin(), E = RenameMap.end(); S != E; ++S) {
883 unsigned CurrReg = S->first;
884 unsigned NewReg = S->second;
885
886 DEBUG(errs() << " " << TRI->getName(CurrReg) << "->" <<
887 TRI->getName(NewReg) << "(" <<
888 RegRefs.count(CurrReg) << " refs)");
889
890 // Update the references to the old register CurrReg to
891 // refer to the new register NewReg.
David Goodwine10deca2009-10-26 22:31:16 +0000892 std::pair<std::multimap<unsigned,
893 AggressiveAntiDepState::RegisterReference>::iterator,
894 std::multimap<unsigned,
895 AggressiveAntiDepState::RegisterReference>::iterator>
David Goodwin34877712009-10-26 19:32:42 +0000896 Range = RegRefs.equal_range(CurrReg);
David Goodwine10deca2009-10-26 22:31:16 +0000897 for (std::multimap<unsigned, AggressiveAntiDepState::RegisterReference>::iterator
David Goodwin34877712009-10-26 19:32:42 +0000898 Q = Range.first, QE = Range.second; Q != QE; ++Q) {
899 Q->second.Operand->setReg(NewReg);
900 }
901
902 // We just went back in time and modified history; the
903 // liveness information for CurrReg is now inconsistent. Set
904 // the state as if it were dead.
David Goodwine10deca2009-10-26 22:31:16 +0000905 State->UnionGroups(NewReg, 0);
David Goodwin34877712009-10-26 19:32:42 +0000906 RegRefs.erase(NewReg);
907 DefIndices[NewReg] = DefIndices[CurrReg];
908 KillIndices[NewReg] = KillIndices[CurrReg];
909
David Goodwine10deca2009-10-26 22:31:16 +0000910 State->UnionGroups(CurrReg, 0);
David Goodwin34877712009-10-26 19:32:42 +0000911 RegRefs.erase(CurrReg);
912 DefIndices[CurrReg] = KillIndices[CurrReg];
913 KillIndices[CurrReg] = ~0u;
914 assert(((KillIndices[CurrReg] == ~0u) !=
915 (DefIndices[CurrReg] == ~0u)) &&
916 "Kill and Def maps aren't consistent for AntiDepReg!");
917 }
918
919 ++Broken;
920 DEBUG(errs() << '\n');
921 }
922 }
923 }
924
925 ScanInstruction(MI, Count);
926 }
927
928 return Broken;
929}