blob: 94941ecf23b624f8557fb2476893547b034f6195 [file] [log] [blame]
Dan Gohmana629b482008-12-08 17:50:35 +00001//===---- ScheduleDAGInstrs.cpp - MachineInstr Rescheduling ---------------===//
Dan Gohman343f0c02008-11-19 23:18:57 +00002//
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//
Dan Gohmana629b482008-12-08 17:50:35 +000010// This implements the ScheduleDAGInstrs class, which implements re-scheduling
11// of MachineInstrs.
Dan Gohman343f0c02008-11-19 23:18:57 +000012//
13//===----------------------------------------------------------------------===//
14
15#define DEBUG_TYPE "sched-instrs"
Dan Gohman6dc75fe2009-02-06 17:12:10 +000016#include "ScheduleDAGInstrs.h"
Dan Gohman8906f952009-07-17 20:58:59 +000017#include "llvm/Operator.h"
Dan Gohman3311a1f2009-01-30 02:49:14 +000018#include "llvm/Analysis/AliasAnalysis.h"
Dan Gohman5034dd32010-12-15 20:02:24 +000019#include "llvm/Analysis/ValueTracking.h"
Dan Gohman3f237442008-12-16 03:25:46 +000020#include "llvm/CodeGen/MachineFunctionPass.h"
Dan Gohmanc76909a2009-09-25 20:36:54 +000021#include "llvm/CodeGen/MachineMemOperand.h"
Dan Gohman3f237442008-12-16 03:25:46 +000022#include "llvm/CodeGen/MachineRegisterInfo.h"
Dan Gohman6a9041e2008-12-04 01:35:46 +000023#include "llvm/CodeGen/PseudoSourceValue.h"
Dan Gohman343f0c02008-11-19 23:18:57 +000024#include "llvm/Target/TargetMachine.h"
25#include "llvm/Target/TargetInstrInfo.h"
26#include "llvm/Target/TargetRegisterInfo.h"
Dan Gohman3f237442008-12-16 03:25:46 +000027#include "llvm/Target/TargetSubtarget.h"
Dan Gohman343f0c02008-11-19 23:18:57 +000028#include "llvm/Support/Debug.h"
29#include "llvm/Support/raw_ostream.h"
Dan Gohman3f237442008-12-16 03:25:46 +000030#include "llvm/ADT/SmallSet.h"
Dan Gohman343f0c02008-11-19 23:18:57 +000031using namespace llvm;
32
Dan Gohman79ce2762009-01-15 19:20:50 +000033ScheduleDAGInstrs::ScheduleDAGInstrs(MachineFunction &mf,
Dan Gohman3f237442008-12-16 03:25:46 +000034 const MachineLoopInfo &mli,
35 const MachineDominatorTree &mdt)
Evan Cheng3ef1c872010-09-10 01:29:16 +000036 : ScheduleDAG(mf), MLI(mli), MDT(mdt), MFI(mf.getFrameInfo()),
37 InstrItins(mf.getTarget().getInstrItineraryData()),
Devang Patelcf4cc842011-06-02 20:07:12 +000038 Defs(TRI->getNumRegs()), Uses(TRI->getNumRegs()),
Devang Patele29e8e12011-06-02 21:26:52 +000039 LoopRegs(MLI, MDT), FirstDbgValue(0) {
Devang Patelcf4cc842011-06-02 20:07:12 +000040 DbgValues.clear();
Evan Cheng38bdfc62009-10-18 19:58:47 +000041}
Dan Gohman343f0c02008-11-19 23:18:57 +000042
Dan Gohman47ac0f02009-02-11 04:27:20 +000043/// Run - perform scheduling.
44///
45void ScheduleDAGInstrs::Run(MachineBasicBlock *bb,
46 MachineBasicBlock::iterator begin,
47 MachineBasicBlock::iterator end,
48 unsigned endcount) {
49 BB = bb;
50 Begin = begin;
51 InsertPosIndex = endcount;
52
53 ScheduleDAG::Run(bb, end);
54}
55
Dan Gohman3311a1f2009-01-30 02:49:14 +000056/// getUnderlyingObjectFromInt - This is the function that does the work of
57/// looking through basic ptrtoint+arithmetic+inttoptr sequences.
58static const Value *getUnderlyingObjectFromInt(const Value *V) {
59 do {
Dan Gohman8906f952009-07-17 20:58:59 +000060 if (const Operator *U = dyn_cast<Operator>(V)) {
Dan Gohman3311a1f2009-01-30 02:49:14 +000061 // If we find a ptrtoint, we can transfer control back to the
62 // regular getUnderlyingObjectFromInt.
Dan Gohman8906f952009-07-17 20:58:59 +000063 if (U->getOpcode() == Instruction::PtrToInt)
Dan Gohman3311a1f2009-01-30 02:49:14 +000064 return U->getOperand(0);
65 // If we find an add of a constant or a multiplied value, it's
66 // likely that the other operand will lead us to the base
67 // object. We don't have to worry about the case where the
Dan Gohman748f98f2009-08-07 01:26:06 +000068 // object address is somehow being computed by the multiply,
Dan Gohman3311a1f2009-01-30 02:49:14 +000069 // because our callers only care when the result is an
70 // identifibale object.
Dan Gohman8906f952009-07-17 20:58:59 +000071 if (U->getOpcode() != Instruction::Add ||
Dan Gohman3311a1f2009-01-30 02:49:14 +000072 (!isa<ConstantInt>(U->getOperand(1)) &&
Dan Gohman8906f952009-07-17 20:58:59 +000073 Operator::getOpcode(U->getOperand(1)) != Instruction::Mul))
Dan Gohman3311a1f2009-01-30 02:49:14 +000074 return V;
75 V = U->getOperand(0);
76 } else {
77 return V;
78 }
Duncan Sands1df98592010-02-16 11:11:14 +000079 assert(V->getType()->isIntegerTy() && "Unexpected operand type!");
Dan Gohman3311a1f2009-01-30 02:49:14 +000080 } while (1);
81}
82
Dan Gohman5034dd32010-12-15 20:02:24 +000083/// getUnderlyingObject - This is a wrapper around GetUnderlyingObject
Dan Gohman3311a1f2009-01-30 02:49:14 +000084/// and adds support for basic ptrtoint+arithmetic+inttoptr sequences.
85static const Value *getUnderlyingObject(const Value *V) {
86 // First just call Value::getUnderlyingObject to let it do what it does.
87 do {
Dan Gohman5034dd32010-12-15 20:02:24 +000088 V = GetUnderlyingObject(V);
Dan Gohman3311a1f2009-01-30 02:49:14 +000089 // If it found an inttoptr, use special code to continue climing.
Dan Gohman8906f952009-07-17 20:58:59 +000090 if (Operator::getOpcode(V) != Instruction::IntToPtr)
Dan Gohman3311a1f2009-01-30 02:49:14 +000091 break;
92 const Value *O = getUnderlyingObjectFromInt(cast<User>(V)->getOperand(0));
93 // If that succeeded in finding a pointer, continue the search.
Duncan Sands1df98592010-02-16 11:11:14 +000094 if (!O->getType()->isPointerTy())
Dan Gohman3311a1f2009-01-30 02:49:14 +000095 break;
96 V = O;
97 } while (1);
98 return V;
99}
100
101/// getUnderlyingObjectForInstr - If this machine instr has memory reference
102/// information and it can be tracked to a normal reference to a known
103/// object, return the Value for that object. Otherwise return null.
Evan Cheng38bdfc62009-10-18 19:58:47 +0000104static const Value *getUnderlyingObjectForInstr(const MachineInstr *MI,
David Goodwina9e61072009-11-03 20:15:00 +0000105 const MachineFrameInfo *MFI,
106 bool &MayAlias) {
107 MayAlias = true;
Dan Gohman3311a1f2009-01-30 02:49:14 +0000108 if (!MI->hasOneMemOperand() ||
Dan Gohmanc76909a2009-09-25 20:36:54 +0000109 !(*MI->memoperands_begin())->getValue() ||
110 (*MI->memoperands_begin())->isVolatile())
Dan Gohman3311a1f2009-01-30 02:49:14 +0000111 return 0;
112
Dan Gohmanc76909a2009-09-25 20:36:54 +0000113 const Value *V = (*MI->memoperands_begin())->getValue();
Dan Gohman3311a1f2009-01-30 02:49:14 +0000114 if (!V)
115 return 0;
116
117 V = getUnderlyingObject(V);
Evan Chengff89dcb2009-10-18 18:16:27 +0000118 if (const PseudoSourceValue *PSV = dyn_cast<PseudoSourceValue>(V)) {
119 // For now, ignore PseudoSourceValues which may alias LLVM IR values
120 // because the code that uses this function has no way to cope with
121 // such aliases.
Evan Cheng38bdfc62009-10-18 19:58:47 +0000122 if (PSV->isAliased(MFI))
Evan Chengff89dcb2009-10-18 18:16:27 +0000123 return 0;
Andrew Trickf405b1a2011-05-05 19:24:06 +0000124
David Goodwin980d4942009-11-09 19:22:17 +0000125 MayAlias = PSV->mayAlias(MFI);
Evan Chengff89dcb2009-10-18 18:16:27 +0000126 return V;
127 }
Dan Gohman3311a1f2009-01-30 02:49:14 +0000128
Evan Chengff89dcb2009-10-18 18:16:27 +0000129 if (isIdentifiedObject(V))
130 return V;
131
132 return 0;
Dan Gohman3311a1f2009-01-30 02:49:14 +0000133}
134
Dan Gohman9e64bbb2009-02-10 23:27:53 +0000135void ScheduleDAGInstrs::StartBlock(MachineBasicBlock *BB) {
136 if (MachineLoop *ML = MLI.getLoopFor(BB))
137 if (BB == ML->getLoopLatch()) {
138 MachineBasicBlock *Header = ML->getHeader();
139 for (MachineBasicBlock::livein_iterator I = Header->livein_begin(),
140 E = Header->livein_end(); I != E; ++I)
141 LoopLiveInRegs.insert(*I);
142 LoopRegs.VisitLoop(ML);
143 }
144}
145
Evan Chengec6906b2010-10-23 02:10:46 +0000146/// AddSchedBarrierDeps - Add dependencies from instructions in the current
147/// list of instructions being scheduled to scheduling barrier by adding
148/// the exit SU to the register defs and use list. This is because we want to
149/// make sure instructions which define registers that are either used by
150/// the terminator or are live-out are properly scheduled. This is
151/// especially important when the definition latency of the return value(s)
152/// are too high to be hidden by the branch or when the liveout registers
153/// used by instructions in the fallthrough block.
154void ScheduleDAGInstrs::AddSchedBarrierDeps() {
155 MachineInstr *ExitMI = InsertPos != BB->end() ? &*InsertPos : 0;
156 ExitSU.setInstr(ExitMI);
157 bool AllDepKnown = ExitMI &&
158 (ExitMI->getDesc().isCall() || ExitMI->getDesc().isBarrier());
159 if (ExitMI && AllDepKnown) {
160 // If it's a call or a barrier, add dependencies on the defs and uses of
161 // instruction.
162 for (unsigned i = 0, e = ExitMI->getNumOperands(); i != e; ++i) {
163 const MachineOperand &MO = ExitMI->getOperand(i);
164 if (!MO.isReg() || MO.isDef()) continue;
165 unsigned Reg = MO.getReg();
166 if (Reg == 0) continue;
167
168 assert(TRI->isPhysicalRegister(Reg) && "Virtual register encountered!");
169 Uses[Reg].push_back(&ExitSU);
170 }
171 } else {
172 // For others, e.g. fallthrough, conditional branch, assume the exit
Evan Chengde5fa932010-10-27 23:17:17 +0000173 // uses all the registers that are livein to the successor blocks.
174 SmallSet<unsigned, 8> Seen;
175 for (MachineBasicBlock::succ_iterator SI = BB->succ_begin(),
176 SE = BB->succ_end(); SI != SE; ++SI)
177 for (MachineBasicBlock::livein_iterator I = (*SI)->livein_begin(),
Andrew Trickf405b1a2011-05-05 19:24:06 +0000178 E = (*SI)->livein_end(); I != E; ++I) {
Evan Chengde5fa932010-10-27 23:17:17 +0000179 unsigned Reg = *I;
180 if (Seen.insert(Reg))
181 Uses[Reg].push_back(&ExitSU);
182 }
Evan Chengec6906b2010-10-23 02:10:46 +0000183 }
184}
185
Dan Gohmana70dca12009-10-09 23:27:56 +0000186void ScheduleDAGInstrs::BuildSchedGraph(AliasAnalysis *AA) {
Dan Gohman9e64bbb2009-02-10 23:27:53 +0000187 // We'll be allocating one SUnit for each instruction, plus one for
188 // the region exit node.
Dan Gohman343f0c02008-11-19 23:18:57 +0000189 SUnits.reserve(BB->size());
190
Dan Gohman6a9041e2008-12-04 01:35:46 +0000191 // We build scheduling units by walking a block's instruction list from bottom
192 // to top.
193
David Goodwin980d4942009-11-09 19:22:17 +0000194 // Remember where a generic side-effecting instruction is as we procede.
195 SUnit *BarrierChain = 0, *AliasChain = 0;
Dan Gohman6a9041e2008-12-04 01:35:46 +0000196
David Goodwin980d4942009-11-09 19:22:17 +0000197 // Memory references to specific known memory locations are tracked
198 // so that they can be given more precise dependencies. We track
199 // separately the known memory locations that may alias and those
200 // that are known not to alias
201 std::map<const Value *, SUnit *> AliasMemDefs, NonAliasMemDefs;
202 std::map<const Value *, std::vector<SUnit *> > AliasMemUses, NonAliasMemUses;
Dan Gohman6a9041e2008-12-04 01:35:46 +0000203
Dan Gohman3f237442008-12-16 03:25:46 +0000204 // Check to see if the scheduler cares about latencies.
205 bool UnitLatencies = ForceUnitLatencies();
206
Dan Gohman8749b612008-12-16 03:35:01 +0000207 // Ask the target if address-backscheduling is desirable, and if so how much.
David Goodwin71046162009-08-13 16:05:04 +0000208 const TargetSubtarget &ST = TM.getSubtarget<TargetSubtarget>();
209 unsigned SpecialAddressLatency = ST.getSpecialAddressLatency();
Dan Gohman8749b612008-12-16 03:35:01 +0000210
Dale Johannesenbfdf7f32010-03-10 22:13:47 +0000211 // Remove any stale debug info; sometimes BuildSchedGraph is called again
212 // without emitting the info from the previous call.
Devang Patelcf4cc842011-06-02 20:07:12 +0000213 DbgValues.clear();
214 FirstDbgValue = NULL;
Dale Johannesenbfdf7f32010-03-10 22:13:47 +0000215
Evan Chengec6906b2010-10-23 02:10:46 +0000216 // Model data dependencies between instructions being scheduled and the
217 // ExitSU.
218 AddSchedBarrierDeps();
219
Andrew Trick9b668532011-05-06 21:52:52 +0000220 for (int i = 0, e = TRI->getNumRegs(); i != e; ++i) {
221 assert(Defs[i].empty() && "Only BuildGraph should push/pop Defs");
222 }
223
Dan Gohman9e64bbb2009-02-10 23:27:53 +0000224 // Walk the list of instructions, from bottom moving up.
Devang Patelcf4cc842011-06-02 20:07:12 +0000225 MachineInstr *PrevMI = NULL;
Dan Gohman47ac0f02009-02-11 04:27:20 +0000226 for (MachineBasicBlock::iterator MII = InsertPos, MIE = Begin;
Dan Gohman343f0c02008-11-19 23:18:57 +0000227 MII != MIE; --MII) {
228 MachineInstr *MI = prior(MII);
Devang Patelcf4cc842011-06-02 20:07:12 +0000229 if (MI && PrevMI) {
230 DbgValues.push_back(std::make_pair(PrevMI, MI));
231 PrevMI = NULL;
232 }
233
Dale Johannesenbfdf7f32010-03-10 22:13:47 +0000234 if (MI->isDebugValue()) {
Devang Patelcf4cc842011-06-02 20:07:12 +0000235 PrevMI = MI;
Dale Johannesenbfdf7f32010-03-10 22:13:47 +0000236 continue;
237 }
Devang Patelcf4cc842011-06-02 20:07:12 +0000238
Evan Chenge837dea2011-06-28 19:10:37 +0000239 const MCInstrDesc &MCID = MI->getDesc();
240 assert(!MCID.isTerminator() && !MI->isLabel() &&
Dan Gohman9e64bbb2009-02-10 23:27:53 +0000241 "Cannot schedule terminators or labels!");
242 // Create the SUnit for this MI.
Dan Gohman343f0c02008-11-19 23:18:57 +0000243 SUnit *SU = NewSUnit(MI);
Evan Chenge837dea2011-06-28 19:10:37 +0000244 SU->isCall = MCID.isCall();
245 SU->isCommutable = MCID.isCommutable();
Dan Gohman343f0c02008-11-19 23:18:57 +0000246
Dan Gohman54e4c362008-12-09 22:54:47 +0000247 // Assign the Latency field of SU using target-provided information.
Dan Gohman3f237442008-12-16 03:25:46 +0000248 if (UnitLatencies)
249 SU->Latency = 1;
250 else
251 ComputeLatency(SU);
Dan Gohman54e4c362008-12-09 22:54:47 +0000252
Dan Gohman6a9041e2008-12-04 01:35:46 +0000253 // Add register-based dependencies (data, anti, and output).
Dan Gohman343f0c02008-11-19 23:18:57 +0000254 for (unsigned j = 0, n = MI->getNumOperands(); j != n; ++j) {
255 const MachineOperand &MO = MI->getOperand(j);
256 if (!MO.isReg()) continue;
257 unsigned Reg = MO.getReg();
258 if (Reg == 0) continue;
259
260 assert(TRI->isPhysicalRegister(Reg) && "Virtual register encountered!");
Dale Johannesenbfdf7f32010-03-10 22:13:47 +0000261
Dan Gohman343f0c02008-11-19 23:18:57 +0000262 std::vector<SUnit *> &UseList = Uses[Reg];
Andrew Trick9b668532011-05-06 21:52:52 +0000263 // Defs are push in the order they are visited and never reordered.
Dan Gohman3f237442008-12-16 03:25:46 +0000264 std::vector<SUnit *> &DefList = Defs[Reg];
David Goodwind94a4e52009-08-10 15:55:25 +0000265 // Optionally add output and anti dependencies. For anti
266 // dependencies we use a latency of 0 because for a multi-issue
267 // target we want to allow the defining instruction to issue
268 // in the same cycle as the using instruction.
269 // TODO: Using a latency of 1 here for output dependencies assumes
270 // there's no cost for reusing registers.
Dan Gohman54e4c362008-12-09 22:54:47 +0000271 SDep::Kind Kind = MO.isUse() ? SDep::Anti : SDep::Output;
David Goodwind94a4e52009-08-10 15:55:25 +0000272 unsigned AOLatency = (Kind == SDep::Anti) ? 0 : 1;
Dan Gohman3f237442008-12-16 03:25:46 +0000273 for (unsigned i = 0, e = DefList.size(); i != e; ++i) {
274 SUnit *DefSU = DefList[i];
Evan Chengec6906b2010-10-23 02:10:46 +0000275 if (DefSU == &ExitSU)
276 continue;
Dan Gohman3f237442008-12-16 03:25:46 +0000277 if (DefSU != SU &&
278 (Kind != SDep::Output || !MO.isDead() ||
279 !DefSU->getInstr()->registerDefIsDead(Reg)))
David Goodwind94a4e52009-08-10 15:55:25 +0000280 DefSU->addPred(SDep(SU, Kind, AOLatency, /*Reg=*/Reg));
Dan Gohman3f237442008-12-16 03:25:46 +0000281 }
Dan Gohman343f0c02008-11-19 23:18:57 +0000282 for (const unsigned *Alias = TRI->getAliasSet(Reg); *Alias; ++Alias) {
Andrew Trick9b668532011-05-06 21:52:52 +0000283 std::vector<SUnit *> &MemDefList = Defs[*Alias];
284 for (unsigned i = 0, e = MemDefList.size(); i != e; ++i) {
285 SUnit *DefSU = MemDefList[i];
Evan Chengec6906b2010-10-23 02:10:46 +0000286 if (DefSU == &ExitSU)
287 continue;
Dan Gohman3f237442008-12-16 03:25:46 +0000288 if (DefSU != SU &&
289 (Kind != SDep::Output || !MO.isDead() ||
Dan Gohman91203cf2009-10-26 18:26:18 +0000290 !DefSU->getInstr()->registerDefIsDead(*Alias)))
David Goodwind94a4e52009-08-10 15:55:25 +0000291 DefSU->addPred(SDep(SU, Kind, AOLatency, /*Reg=*/ *Alias));
Dan Gohman3f237442008-12-16 03:25:46 +0000292 }
Dan Gohman343f0c02008-11-19 23:18:57 +0000293 }
294
295 if (MO.isDef()) {
296 // Add any data dependencies.
Dan Gohman3f237442008-12-16 03:25:46 +0000297 unsigned DataLatency = SU->Latency;
298 for (unsigned i = 0, e = UseList.size(); i != e; ++i) {
299 SUnit *UseSU = UseList[i];
Evan Chenga69ec092010-03-22 21:24:33 +0000300 if (UseSU == SU)
301 continue;
302 unsigned LDataLatency = DataLatency;
303 // Optionally add in a special extra latency for nodes that
304 // feed addresses.
305 // TODO: Do this for register aliases too.
306 // TODO: Perhaps we should get rid of
307 // SpecialAddressLatency and just move this into
308 // adjustSchedDependency for the targets that care about it.
Evan Chengec6906b2010-10-23 02:10:46 +0000309 if (SpecialAddressLatency != 0 && !UnitLatencies &&
310 UseSU != &ExitSU) {
Evan Chenga69ec092010-03-22 21:24:33 +0000311 MachineInstr *UseMI = UseSU->getInstr();
Evan Chenge837dea2011-06-28 19:10:37 +0000312 const MCInstrDesc &UseMCID = UseMI->getDesc();
Evan Chenga69ec092010-03-22 21:24:33 +0000313 int RegUseIndex = UseMI->findRegisterUseOperandIdx(Reg);
314 assert(RegUseIndex >= 0 && "UseMI doesn's use register!");
Evan Chengec6906b2010-10-23 02:10:46 +0000315 if (RegUseIndex >= 0 &&
Evan Chenge837dea2011-06-28 19:10:37 +0000316 (UseMCID.mayLoad() || UseMCID.mayStore()) &&
317 (unsigned)RegUseIndex < UseMCID.getNumOperands() &&
318 UseMCID.OpInfo[RegUseIndex].isLookupPtrRegClass())
Evan Chenga69ec092010-03-22 21:24:33 +0000319 LDataLatency += SpecialAddressLatency;
Dan Gohman3f237442008-12-16 03:25:46 +0000320 }
Evan Chenga69ec092010-03-22 21:24:33 +0000321 // Adjust the dependence latency using operand def/use
322 // information (if any), and then allow the target to
323 // perform its own adjustments.
324 const SDep& dep = SDep(SU, SDep::Data, LDataLatency, Reg);
325 if (!UnitLatencies) {
Dan Gohman3fb150a2010-04-17 17:42:52 +0000326 ComputeOperandLatency(SU, UseSU, const_cast<SDep &>(dep));
327 ST.adjustSchedDependency(SU, UseSU, const_cast<SDep &>(dep));
Evan Chenga69ec092010-03-22 21:24:33 +0000328 }
329 UseSU->addPred(dep);
Dan Gohman3f237442008-12-16 03:25:46 +0000330 }
Dan Gohman343f0c02008-11-19 23:18:57 +0000331 for (const unsigned *Alias = TRI->getAliasSet(Reg); *Alias; ++Alias) {
332 std::vector<SUnit *> &UseList = Uses[*Alias];
Dan Gohman3f237442008-12-16 03:25:46 +0000333 for (unsigned i = 0, e = UseList.size(); i != e; ++i) {
334 SUnit *UseSU = UseList[i];
Evan Chenga69ec092010-03-22 21:24:33 +0000335 if (UseSU == SU)
336 continue;
337 const SDep& dep = SDep(SU, SDep::Data, DataLatency, *Alias);
338 if (!UnitLatencies) {
Dan Gohman3fb150a2010-04-17 17:42:52 +0000339 ComputeOperandLatency(SU, UseSU, const_cast<SDep &>(dep));
340 ST.adjustSchedDependency(SU, UseSU, const_cast<SDep &>(dep));
David Goodwin71046162009-08-13 16:05:04 +0000341 }
Evan Chenga69ec092010-03-22 21:24:33 +0000342 UseSU->addPred(dep);
Dan Gohman3f237442008-12-16 03:25:46 +0000343 }
Dan Gohman343f0c02008-11-19 23:18:57 +0000344 }
345
Dan Gohman8749b612008-12-16 03:35:01 +0000346 // If a def is going to wrap back around to the top of the loop,
347 // backschedule it.
Dan Gohman9e64bbb2009-02-10 23:27:53 +0000348 if (!UnitLatencies && DefList.empty()) {
Dan Gohman8749b612008-12-16 03:35:01 +0000349 LoopDependencies::LoopDeps::iterator I = LoopRegs.Deps.find(Reg);
350 if (I != LoopRegs.Deps.end()) {
351 const MachineOperand *UseMO = I->second.first;
352 unsigned Count = I->second.second;
353 const MachineInstr *UseMI = UseMO->getParent();
354 unsigned UseMOIdx = UseMO - &UseMI->getOperand(0);
Evan Chenge837dea2011-06-28 19:10:37 +0000355 const MCInstrDesc &UseMCID = UseMI->getDesc();
Dan Gohman8749b612008-12-16 03:35:01 +0000356 // TODO: If we knew the total depth of the region here, we could
357 // handle the case where the whole loop is inside the region but
358 // is large enough that the isScheduleHigh trick isn't needed.
Evan Chenge837dea2011-06-28 19:10:37 +0000359 if (UseMOIdx < UseMCID.getNumOperands()) {
Dan Gohman8749b612008-12-16 03:35:01 +0000360 // Currently, we only support scheduling regions consisting of
361 // single basic blocks. Check to see if the instruction is in
362 // the same region by checking to see if it has the same parent.
363 if (UseMI->getParent() != MI->getParent()) {
364 unsigned Latency = SU->Latency;
Evan Chenge837dea2011-06-28 19:10:37 +0000365 if (UseMCID.OpInfo[UseMOIdx].isLookupPtrRegClass())
Dan Gohman8749b612008-12-16 03:35:01 +0000366 Latency += SpecialAddressLatency;
367 // This is a wild guess as to the portion of the latency which
368 // will be overlapped by work done outside the current
369 // scheduling region.
370 Latency -= std::min(Latency, Count);
Chris Lattner7a2bdde2011-04-15 05:18:47 +0000371 // Add the artificial edge.
Dan Gohman9e64bbb2009-02-10 23:27:53 +0000372 ExitSU.addPred(SDep(SU, SDep::Order, Latency,
373 /*Reg=*/0, /*isNormalMemory=*/false,
374 /*isMustAlias=*/false,
375 /*isArtificial=*/true));
Dan Gohman8749b612008-12-16 03:35:01 +0000376 } else if (SpecialAddressLatency > 0 &&
Evan Chenge837dea2011-06-28 19:10:37 +0000377 UseMCID.OpInfo[UseMOIdx].isLookupPtrRegClass()) {
Dan Gohman8749b612008-12-16 03:35:01 +0000378 // The entire loop body is within the current scheduling region
379 // and the latency of this operation is assumed to be greater
380 // than the latency of the loop.
381 // TODO: Recursively mark data-edge predecessors as
382 // isScheduleHigh too.
383 SU->isScheduleHigh = true;
384 }
385 }
386 LoopRegs.Deps.erase(I);
387 }
388 }
389
Dan Gohman343f0c02008-11-19 23:18:57 +0000390 UseList.clear();
Dan Gohman3f237442008-12-16 03:25:46 +0000391 if (!MO.isDead())
392 DefList.clear();
Andrew Trickee109152011-05-05 19:32:21 +0000393
394 // Calls will not be reordered because of chain dependencies (see
395 // below). Since call operands are dead, calls may continue to be added
396 // to the DefList making dependence checking quadratic in the size of
397 // the block. Instead, we leave only one call at the back of the
398 // DefList.
Andrew Trickee109152011-05-05 19:32:21 +0000399 if (SU->isCall) {
400 while (!DefList.empty() && DefList.back()->isCall)
401 DefList.pop_back();
402 }
Dan Gohman3f237442008-12-16 03:25:46 +0000403 DefList.push_back(SU);
Dan Gohman343f0c02008-11-19 23:18:57 +0000404 } else {
405 UseList.push_back(SU);
406 }
407 }
Dan Gohman6a9041e2008-12-04 01:35:46 +0000408
409 // Add chain dependencies.
David Goodwin7c9b1ac2009-11-02 17:06:28 +0000410 // Chain dependencies used to enforce memory order should have
411 // latency of 0 (except for true dependency of Store followed by
412 // aliased Load... we estimate that with a single cycle of latency
413 // assuming the hardware will bypass)
Dan Gohman6a9041e2008-12-04 01:35:46 +0000414 // Note that isStoreToStackSlot and isLoadFromStackSLot are not usable
415 // after stack slots are lowered to actual addresses.
416 // TODO: Use an AliasAnalysis and do real alias-analysis queries, and
417 // produce more precise dependence information.
David Goodwin7c9b1ac2009-11-02 17:06:28 +0000418#define STORE_LOAD_LATENCY 1
419 unsigned TrueMemOrderLatency = 0;
Evan Chenge837dea2011-06-28 19:10:37 +0000420 if (MCID.isCall() || MI->hasUnmodeledSideEffects() ||
Andrew Trickf405b1a2011-05-05 19:24:06 +0000421 (MI->hasVolatileMemoryRef() &&
Evan Chenge837dea2011-06-28 19:10:37 +0000422 (!MCID.mayLoad() || !MI->isInvariantLoad(AA)))) {
David Goodwin980d4942009-11-09 19:22:17 +0000423 // Be conservative with these and add dependencies on all memory
424 // references, even those that are known to not alias.
Andrew Trickf405b1a2011-05-05 19:24:06 +0000425 for (std::map<const Value *, SUnit *>::iterator I =
David Goodwin980d4942009-11-09 19:22:17 +0000426 NonAliasMemDefs.begin(), E = NonAliasMemDefs.end(); I != E; ++I) {
David Goodwin7c9b1ac2009-11-02 17:06:28 +0000427 I->second->addPred(SDep(SU, SDep::Order, /*Latency=*/0));
Dan Gohman6a9041e2008-12-04 01:35:46 +0000428 }
429 for (std::map<const Value *, std::vector<SUnit *> >::iterator I =
David Goodwin980d4942009-11-09 19:22:17 +0000430 NonAliasMemUses.begin(), E = NonAliasMemUses.end(); I != E; ++I) {
Dan Gohman6a9041e2008-12-04 01:35:46 +0000431 for (unsigned i = 0, e = I->second.size(); i != e; ++i)
David Goodwin7c9b1ac2009-11-02 17:06:28 +0000432 I->second[i]->addPred(SDep(SU, SDep::Order, TrueMemOrderLatency));
Dan Gohman6a9041e2008-12-04 01:35:46 +0000433 }
David Goodwin980d4942009-11-09 19:22:17 +0000434 NonAliasMemDefs.clear();
435 NonAliasMemUses.clear();
436 // Add SU to the barrier chain.
437 if (BarrierChain)
438 BarrierChain->addPred(SDep(SU, SDep::Order, /*Latency=*/0));
439 BarrierChain = SU;
440
441 // fall-through
442 new_alias_chain:
443 // Chain all possibly aliasing memory references though SU.
444 if (AliasChain)
445 AliasChain->addPred(SDep(SU, SDep::Order, /*Latency=*/0));
446 AliasChain = SU;
447 for (unsigned k = 0, m = PendingLoads.size(); k != m; ++k)
448 PendingLoads[k]->addPred(SDep(SU, SDep::Order, TrueMemOrderLatency));
449 for (std::map<const Value *, SUnit *>::iterator I = AliasMemDefs.begin(),
450 E = AliasMemDefs.end(); I != E; ++I) {
451 I->second->addPred(SDep(SU, SDep::Order, /*Latency=*/0));
452 }
453 for (std::map<const Value *, std::vector<SUnit *> >::iterator I =
454 AliasMemUses.begin(), E = AliasMemUses.end(); I != E; ++I) {
455 for (unsigned i = 0, e = I->second.size(); i != e; ++i)
456 I->second[i]->addPred(SDep(SU, SDep::Order, TrueMemOrderLatency));
457 }
458 PendingLoads.clear();
459 AliasMemDefs.clear();
460 AliasMemUses.clear();
Evan Chenge837dea2011-06-28 19:10:37 +0000461 } else if (MCID.mayStore()) {
David Goodwina9e61072009-11-03 20:15:00 +0000462 bool MayAlias = true;
David Goodwin7c9b1ac2009-11-02 17:06:28 +0000463 TrueMemOrderLatency = STORE_LOAD_LATENCY;
David Goodwina9e61072009-11-03 20:15:00 +0000464 if (const Value *V = getUnderlyingObjectForInstr(MI, MFI, MayAlias)) {
Dan Gohman6a9041e2008-12-04 01:35:46 +0000465 // A store to a specific PseudoSourceValue. Add precise dependencies.
David Goodwin980d4942009-11-09 19:22:17 +0000466 // Record the def in MemDefs, first adding a dep if there is
467 // an existing def.
Andrew Trickf405b1a2011-05-05 19:24:06 +0000468 std::map<const Value *, SUnit *>::iterator I =
David Goodwin980d4942009-11-09 19:22:17 +0000469 ((MayAlias) ? AliasMemDefs.find(V) : NonAliasMemDefs.find(V));
Andrew Trickf405b1a2011-05-05 19:24:06 +0000470 std::map<const Value *, SUnit *>::iterator IE =
David Goodwin980d4942009-11-09 19:22:17 +0000471 ((MayAlias) ? AliasMemDefs.end() : NonAliasMemDefs.end());
472 if (I != IE) {
David Goodwin7c9b1ac2009-11-02 17:06:28 +0000473 I->second->addPred(SDep(SU, SDep::Order, /*Latency=*/0, /*Reg=*/0,
Dan Gohman54e4c362008-12-09 22:54:47 +0000474 /*isNormalMemory=*/true));
Dan Gohman6a9041e2008-12-04 01:35:46 +0000475 I->second = SU;
476 } else {
David Goodwin980d4942009-11-09 19:22:17 +0000477 if (MayAlias)
478 AliasMemDefs[V] = SU;
479 else
480 NonAliasMemDefs[V] = SU;
Dan Gohman6a9041e2008-12-04 01:35:46 +0000481 }
482 // Handle the uses in MemUses, if there are any.
Dan Gohmana629b482008-12-08 17:50:35 +0000483 std::map<const Value *, std::vector<SUnit *> >::iterator J =
David Goodwin980d4942009-11-09 19:22:17 +0000484 ((MayAlias) ? AliasMemUses.find(V) : NonAliasMemUses.find(V));
485 std::map<const Value *, std::vector<SUnit *> >::iterator JE =
486 ((MayAlias) ? AliasMemUses.end() : NonAliasMemUses.end());
487 if (J != JE) {
Dan Gohman6a9041e2008-12-04 01:35:46 +0000488 for (unsigned i = 0, e = J->second.size(); i != e; ++i)
David Goodwin7c9b1ac2009-11-02 17:06:28 +0000489 J->second[i]->addPred(SDep(SU, SDep::Order, TrueMemOrderLatency,
490 /*Reg=*/0, /*isNormalMemory=*/true));
Dan Gohman6a9041e2008-12-04 01:35:46 +0000491 J->second.clear();
492 }
David Goodwina9e61072009-11-03 20:15:00 +0000493 if (MayAlias) {
David Goodwin980d4942009-11-09 19:22:17 +0000494 // Add dependencies from all the PendingLoads, i.e. loads
495 // with no underlying object.
David Goodwina9e61072009-11-03 20:15:00 +0000496 for (unsigned k = 0, m = PendingLoads.size(); k != m; ++k)
497 PendingLoads[k]->addPred(SDep(SU, SDep::Order, TrueMemOrderLatency));
David Goodwin980d4942009-11-09 19:22:17 +0000498 // Add dependence on alias chain, if needed.
499 if (AliasChain)
500 AliasChain->addPred(SDep(SU, SDep::Order, /*Latency=*/0));
David Goodwina9e61072009-11-03 20:15:00 +0000501 }
David Goodwin980d4942009-11-09 19:22:17 +0000502 // Add dependence on barrier chain, if needed.
503 if (BarrierChain)
504 BarrierChain->addPred(SDep(SU, SDep::Order, /*Latency=*/0));
David Goodwin5be870a2009-11-05 00:16:44 +0000505 } else {
Dan Gohman6a9041e2008-12-04 01:35:46 +0000506 // Treat all other stores conservatively.
David Goodwin980d4942009-11-09 19:22:17 +0000507 goto new_alias_chain;
David Goodwin7c9b1ac2009-11-02 17:06:28 +0000508 }
Evan Chengec6906b2010-10-23 02:10:46 +0000509
510 if (!ExitSU.isPred(SU))
511 // Push store's up a bit to avoid them getting in between cmp
512 // and branches.
513 ExitSU.addPred(SDep(SU, SDep::Order, 0,
514 /*Reg=*/0, /*isNormalMemory=*/false,
515 /*isMustAlias=*/false,
516 /*isArtificial=*/true));
Evan Chenge837dea2011-06-28 19:10:37 +0000517 } else if (MCID.mayLoad()) {
David Goodwina9e61072009-11-03 20:15:00 +0000518 bool MayAlias = true;
David Goodwin7c9b1ac2009-11-02 17:06:28 +0000519 TrueMemOrderLatency = 0;
Dan Gohmana70dca12009-10-09 23:27:56 +0000520 if (MI->isInvariantLoad(AA)) {
Dan Gohman6a9041e2008-12-04 01:35:46 +0000521 // Invariant load, no chain dependencies needed!
David Goodwin5be870a2009-11-05 00:16:44 +0000522 } else {
Andrew Trickf405b1a2011-05-05 19:24:06 +0000523 if (const Value *V =
David Goodwin980d4942009-11-09 19:22:17 +0000524 getUnderlyingObjectForInstr(MI, MFI, MayAlias)) {
525 // A load from a specific PseudoSourceValue. Add precise dependencies.
Andrew Trickf405b1a2011-05-05 19:24:06 +0000526 std::map<const Value *, SUnit *>::iterator I =
David Goodwin980d4942009-11-09 19:22:17 +0000527 ((MayAlias) ? AliasMemDefs.find(V) : NonAliasMemDefs.find(V));
Andrew Trickf405b1a2011-05-05 19:24:06 +0000528 std::map<const Value *, SUnit *>::iterator IE =
David Goodwin980d4942009-11-09 19:22:17 +0000529 ((MayAlias) ? AliasMemDefs.end() : NonAliasMemDefs.end());
530 if (I != IE)
531 I->second->addPred(SDep(SU, SDep::Order, /*Latency=*/0, /*Reg=*/0,
532 /*isNormalMemory=*/true));
533 if (MayAlias)
534 AliasMemUses[V].push_back(SU);
Andrew Trickf405b1a2011-05-05 19:24:06 +0000535 else
David Goodwin980d4942009-11-09 19:22:17 +0000536 NonAliasMemUses[V].push_back(SU);
537 } else {
538 // A load with no underlying object. Depend on all
539 // potentially aliasing stores.
Andrew Trickf405b1a2011-05-05 19:24:06 +0000540 for (std::map<const Value *, SUnit *>::iterator I =
David Goodwin980d4942009-11-09 19:22:17 +0000541 AliasMemDefs.begin(), E = AliasMemDefs.end(); I != E; ++I)
542 I->second->addPred(SDep(SU, SDep::Order, /*Latency=*/0));
Andrew Trickf405b1a2011-05-05 19:24:06 +0000543
David Goodwin980d4942009-11-09 19:22:17 +0000544 PendingLoads.push_back(SU);
545 MayAlias = true;
David Goodwina9e61072009-11-03 20:15:00 +0000546 }
Andrew Trickf405b1a2011-05-05 19:24:06 +0000547
David Goodwin980d4942009-11-09 19:22:17 +0000548 // Add dependencies on alias and barrier chains, if needed.
549 if (MayAlias && AliasChain)
550 AliasChain->addPred(SDep(SU, SDep::Order, /*Latency=*/0));
551 if (BarrierChain)
552 BarrierChain->addPred(SDep(SU, SDep::Order, /*Latency=*/0));
Andrew Trickf405b1a2011-05-05 19:24:06 +0000553 }
Dan Gohman343f0c02008-11-19 23:18:57 +0000554 }
Dan Gohman343f0c02008-11-19 23:18:57 +0000555 }
Devang Patelcf4cc842011-06-02 20:07:12 +0000556 if (PrevMI)
557 FirstDbgValue = PrevMI;
Dan Gohman79ce2762009-01-15 19:20:50 +0000558
559 for (int i = 0, e = TRI->getNumRegs(); i != e; ++i) {
560 Defs[i].clear();
561 Uses[i].clear();
562 }
563 PendingLoads.clear();
Dan Gohman343f0c02008-11-19 23:18:57 +0000564}
565
Dan Gohman9e64bbb2009-02-10 23:27:53 +0000566void ScheduleDAGInstrs::FinishBlock() {
567 // Nothing to do.
568}
569
Dan Gohmanc8c28272008-11-21 00:12:10 +0000570void ScheduleDAGInstrs::ComputeLatency(SUnit *SU) {
David Goodwind94a4e52009-08-10 15:55:25 +0000571 // Compute the latency for the node.
Evan Cheng3ef1c872010-09-10 01:29:16 +0000572 if (!InstrItins || InstrItins->isEmpty()) {
573 SU->Latency = 1;
Dan Gohman4ea8e852008-12-16 02:38:22 +0000574
Evan Cheng3ef1c872010-09-10 01:29:16 +0000575 // Simplistic target-independent heuristic: assume that loads take
576 // extra time.
Dan Gohman4ea8e852008-12-16 02:38:22 +0000577 if (SU->getInstr()->getDesc().mayLoad())
578 SU->Latency += 2;
Evan Cheng8239daf2010-11-03 00:45:17 +0000579 } else {
580 SU->Latency = TII->getInstrLatency(InstrItins, SU->getInstr());
581 }
Dan Gohmanc8c28272008-11-21 00:12:10 +0000582}
583
Andrew Trickf405b1a2011-05-05 19:24:06 +0000584void ScheduleDAGInstrs::ComputeOperandLatency(SUnit *Def, SUnit *Use,
David Goodwindc4bdcd2009-08-19 16:08:58 +0000585 SDep& dep) const {
Evan Cheng3ef1c872010-09-10 01:29:16 +0000586 if (!InstrItins || InstrItins->isEmpty())
David Goodwindc4bdcd2009-08-19 16:08:58 +0000587 return;
Andrew Trickf405b1a2011-05-05 19:24:06 +0000588
David Goodwindc4bdcd2009-08-19 16:08:58 +0000589 // For a data dependency with a known register...
590 if ((dep.getKind() != SDep::Data) || (dep.getReg() == 0))
591 return;
592
593 const unsigned Reg = dep.getReg();
594
595 // ... find the definition of the register in the defining
596 // instruction
597 MachineInstr *DefMI = Def->getInstr();
598 int DefIdx = DefMI->findRegisterDefOperandIdx(Reg);
599 if (DefIdx != -1) {
Evan Cheng1aca5bc2010-10-08 18:42:25 +0000600 const MachineOperand &MO = DefMI->getOperand(DefIdx);
601 if (MO.isReg() && MO.isImplicit() &&
Evan Chengd82de832010-10-08 23:01:57 +0000602 DefIdx >= (int)DefMI->getDesc().getNumOperands()) {
Evan Cheng1aca5bc2010-10-08 18:42:25 +0000603 // This is an implicit def, getOperandLatency() won't return the correct
604 // latency. e.g.
605 // %D6<def>, %D7<def> = VLD1q16 %R2<kill>, 0, ..., %Q3<imp-def>
606 // %Q1<def> = VMULv8i16 %Q1<kill>, %Q3<kill>, ...
607 // What we want is to compute latency between def of %D6/%D7 and use of
608 // %Q3 instead.
609 DefIdx = DefMI->findRegisterDefOperandIdx(Reg, false, true, TRI);
610 }
Evan Chenga0792de2010-10-06 06:27:31 +0000611 MachineInstr *UseMI = Use->getInstr();
Evan Cheng3881cb72010-09-29 22:42:35 +0000612 // For all uses of the register, calculate the maxmimum latency
613 int Latency = -1;
Evan Chengec6906b2010-10-23 02:10:46 +0000614 if (UseMI) {
615 for (unsigned i = 0, e = UseMI->getNumOperands(); i != e; ++i) {
616 const MachineOperand &MO = UseMI->getOperand(i);
617 if (!MO.isReg() || !MO.isUse())
618 continue;
619 unsigned MOReg = MO.getReg();
620 if (MOReg != Reg)
621 continue;
David Goodwindc4bdcd2009-08-19 16:08:58 +0000622
Evan Chengec6906b2010-10-23 02:10:46 +0000623 int UseCycle = TII->getOperandLatency(InstrItins, DefMI, DefIdx,
624 UseMI, i);
625 Latency = std::max(Latency, UseCycle);
626 }
627 } else {
628 // UseMI is null, then it must be a scheduling barrier.
629 if (!InstrItins || InstrItins->isEmpty())
630 return;
631 unsigned DefClass = DefMI->getDesc().getSchedClass();
632 Latency = InstrItins->getOperandCycle(DefClass, DefIdx);
David Goodwindc4bdcd2009-08-19 16:08:58 +0000633 }
Evan Chengec6906b2010-10-23 02:10:46 +0000634
635 // If we found a latency, then replace the existing dependence latency.
636 if (Latency >= 0)
637 dep.setLatency(Latency);
David Goodwindc4bdcd2009-08-19 16:08:58 +0000638 }
639}
640
Dan Gohman343f0c02008-11-19 23:18:57 +0000641void ScheduleDAGInstrs::dumpNode(const SUnit *SU) const {
642 SU->getInstr()->dump();
643}
644
645std::string ScheduleDAGInstrs::getGraphNodeLabel(const SUnit *SU) const {
646 std::string s;
647 raw_string_ostream oss(s);
Dan Gohman9e64bbb2009-02-10 23:27:53 +0000648 if (SU == &EntrySU)
649 oss << "<entry>";
650 else if (SU == &ExitSU)
651 oss << "<exit>";
652 else
653 SU->getInstr()->print(oss);
Dan Gohman343f0c02008-11-19 23:18:57 +0000654 return oss.str();
655}
656
657// EmitSchedule - Emit the machine code in scheduled order.
Dan Gohmanaf1d8ca2010-05-01 00:01:06 +0000658MachineBasicBlock *ScheduleDAGInstrs::EmitSchedule() {
Dan Gohman343f0c02008-11-19 23:18:57 +0000659 // For MachineInstr-based scheduling, we're rescheduling the instructions in
660 // the block, so start by removing them from the block.
Dan Gohman47ac0f02009-02-11 04:27:20 +0000661 while (Begin != InsertPos) {
Dan Gohmanf7119392009-01-16 22:10:20 +0000662 MachineBasicBlock::iterator I = Begin;
663 ++Begin;
664 BB->remove(I);
665 }
Dan Gohman343f0c02008-11-19 23:18:57 +0000666
Devang Patelcf4cc842011-06-02 20:07:12 +0000667 // If first instruction was a DBG_VALUE then put it back.
668 if (FirstDbgValue)
669 BB->insert(InsertPos, FirstDbgValue);
Dale Johannesenbfdf7f32010-03-10 22:13:47 +0000670
Dan Gohman0b1d4a72008-12-23 21:37:04 +0000671 // Then re-insert them according to the given schedule.
Dan Gohman343f0c02008-11-19 23:18:57 +0000672 for (unsigned i = 0, e = Sequence.size(); i != e; i++) {
Devang Patelee1f8782011-06-02 21:31:00 +0000673 if (SUnit *SU = Sequence[i])
674 BB->insert(InsertPos, SU->getInstr());
675 else
Dan Gohman343f0c02008-11-19 23:18:57 +0000676 // Null SUnit* is a noop.
677 EmitNoop();
Dan Gohman343f0c02008-11-19 23:18:57 +0000678 }
679
Dan Gohman9e64bbb2009-02-10 23:27:53 +0000680 // Update the Begin iterator, as the first instruction in the block
681 // may have been scheduled later.
Devang Patelcf4cc842011-06-02 20:07:12 +0000682 if (!Sequence.empty())
Dan Gohman9e64bbb2009-02-10 23:27:53 +0000683 Begin = Sequence[0]->getInstr();
684
Devang Patelcf4cc842011-06-02 20:07:12 +0000685 // Reinsert any remaining debug_values.
686 for (std::vector<std::pair<MachineInstr *, MachineInstr *> >::iterator
687 DI = DbgValues.end(), DE = DbgValues.begin(); DI != DE; --DI) {
688 std::pair<MachineInstr *, MachineInstr *> P = *prior(DI);
689 MachineInstr *DbgValue = P.first;
690 MachineInstr *OrigPrivMI = P.second;
691 BB->insertAfter(OrigPrivMI, DbgValue);
692 }
693 DbgValues.clear();
694 FirstDbgValue = NULL;
Dan Gohman343f0c02008-11-19 23:18:57 +0000695 return BB;
696}