File: | lib/CodeGen/LiveDebugValues.cpp |
Location: | line 399, column 9 |
Description: | Value stored to 'MBBJoined' is never read |
1 | //===------ LiveDebugValues.cpp - Tracking Debug Value MIs ----------------===// |
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 pass implements a data flow analysis that propagates debug location |
11 | /// information by inserting additional DBG_VALUE instructions into the machine |
12 | /// instruction stream. The pass internally builds debug location liveness |
13 | /// ranges to determine the points where additional DBG_VALUEs need to be |
14 | /// inserted. |
15 | /// |
16 | /// This is a separate pass from DbgValueHistoryCalculator to facilitate |
17 | /// testing and improve modularity. |
18 | /// |
19 | //===----------------------------------------------------------------------===// |
20 | |
21 | #include "llvm/ADT/PostOrderIterator.h" |
22 | #include "llvm/ADT/SmallPtrSet.h" |
23 | #include "llvm/ADT/Statistic.h" |
24 | #include "llvm/CodeGen/MachineFunction.h" |
25 | #include "llvm/CodeGen/MachineFunctionPass.h" |
26 | #include "llvm/CodeGen/MachineInstrBuilder.h" |
27 | #include "llvm/CodeGen/Passes.h" |
28 | #include "llvm/IR/DebugInfo.h" |
29 | #include "llvm/Support/Debug.h" |
30 | #include "llvm/Support/raw_ostream.h" |
31 | #include "llvm/Target/TargetInstrInfo.h" |
32 | #include "llvm/Target/TargetLowering.h" |
33 | #include "llvm/Target/TargetRegisterInfo.h" |
34 | #include "llvm/Target/TargetSubtargetInfo.h" |
35 | #include <list> |
36 | #include <queue> |
37 | |
38 | using namespace llvm; |
39 | |
40 | #define DEBUG_TYPE"live-debug-values" "live-debug-values" |
41 | |
42 | STATISTIC(NumInserted, "Number of DBG_VALUE instructions inserted")static llvm::Statistic NumInserted = { "live-debug-values", "Number of DBG_VALUE instructions inserted" , 0, 0 }; |
43 | |
44 | namespace { |
45 | |
46 | class LiveDebugValues : public MachineFunctionPass { |
47 | |
48 | private: |
49 | const TargetRegisterInfo *TRI; |
50 | const TargetInstrInfo *TII; |
51 | |
52 | typedef std::pair<const DILocalVariable *, const DILocation *> |
53 | InlinedVariable; |
54 | |
55 | /// A potentially inlined instance of a variable. |
56 | struct DebugVariable { |
57 | const DILocalVariable *Var; |
58 | const DILocation *InlinedAt; |
59 | |
60 | DebugVariable(const DILocalVariable *_var, const DILocation *_inlinedAt) |
61 | : Var(_var), InlinedAt(_inlinedAt) {} |
62 | |
63 | bool operator==(const DebugVariable &DV) const { |
64 | return (Var == DV.Var) && (InlinedAt == DV.InlinedAt); |
65 | } |
66 | }; |
67 | |
68 | /// Member variables and functions for Range Extension across basic blocks. |
69 | struct VarLoc { |
70 | DebugVariable Var; |
71 | const MachineInstr *MI; // MachineInstr should be a DBG_VALUE instr. |
72 | |
73 | VarLoc(DebugVariable _var, const MachineInstr *_mi) : Var(_var), MI(_mi) {} |
74 | |
75 | bool operator==(const VarLoc &V) const; |
76 | }; |
77 | |
78 | typedef std::list<VarLoc> VarLocList; |
79 | typedef SmallDenseMap<const MachineBasicBlock *, VarLocList> VarLocInMBB; |
80 | |
81 | void transferDebugValue(MachineInstr &MI, VarLocList &OpenRanges); |
82 | void transferRegisterDef(MachineInstr &MI, VarLocList &OpenRanges); |
83 | bool transferTerminatorInst(MachineInstr &MI, VarLocList &OpenRanges, |
84 | VarLocInMBB &OutLocs); |
85 | bool transfer(MachineInstr &MI, VarLocList &OpenRanges, VarLocInMBB &OutLocs); |
86 | |
87 | bool join(MachineBasicBlock &MBB, VarLocInMBB &OutLocs, VarLocInMBB &InLocs); |
88 | |
89 | bool ExtendRanges(MachineFunction &MF); |
90 | |
91 | public: |
92 | static char ID; |
93 | |
94 | /// Default construct and initialize the pass. |
95 | LiveDebugValues(); |
96 | |
97 | /// Tell the pass manager which passes we depend on and what |
98 | /// information we preserve. |
99 | void getAnalysisUsage(AnalysisUsage &AU) const override; |
100 | |
101 | MachineFunctionProperties getRequiredProperties() const override { |
102 | return MachineFunctionProperties().set( |
103 | MachineFunctionProperties::Property::AllVRegsAllocated); |
104 | } |
105 | |
106 | /// Print to ostream with a message. |
107 | void printVarLocInMBB(const VarLocInMBB &V, const char *msg, |
108 | raw_ostream &Out) const; |
109 | |
110 | /// Calculate the liveness information for the given machine function. |
111 | bool runOnMachineFunction(MachineFunction &MF) override; |
112 | }; |
113 | } // namespace |
114 | |
115 | //===----------------------------------------------------------------------===// |
116 | // Implementation |
117 | //===----------------------------------------------------------------------===// |
118 | |
119 | char LiveDebugValues::ID = 0; |
120 | char &llvm::LiveDebugValuesID = LiveDebugValues::ID; |
121 | INITIALIZE_PASS(LiveDebugValues, "livedebugvalues", "Live DEBUG_VALUE analysis",static void* initializeLiveDebugValuesPassOnce(PassRegistry & Registry) { PassInfo *PI = new PassInfo("Live DEBUG_VALUE analysis" , "livedebugvalues", & LiveDebugValues ::ID, PassInfo::NormalCtor_t (callDefaultCtor< LiveDebugValues >), false, false); Registry .registerPass(*PI, true); return PI; } void llvm::initializeLiveDebugValuesPass (PassRegistry &Registry) { static volatile sys::cas_flag initialized = 0; sys::cas_flag old_val = sys::CompareAndSwap(&initialized , 1, 0); if (old_val == 0) { initializeLiveDebugValuesPassOnce (Registry); sys::MemoryFence(); ; ; initialized = 2; ; } else { sys::cas_flag tmp = initialized; sys::MemoryFence(); while (tmp != 2) { tmp = initialized; sys::MemoryFence(); } } ; } |
122 | false, false)static void* initializeLiveDebugValuesPassOnce(PassRegistry & Registry) { PassInfo *PI = new PassInfo("Live DEBUG_VALUE analysis" , "livedebugvalues", & LiveDebugValues ::ID, PassInfo::NormalCtor_t (callDefaultCtor< LiveDebugValues >), false, false); Registry .registerPass(*PI, true); return PI; } void llvm::initializeLiveDebugValuesPass (PassRegistry &Registry) { static volatile sys::cas_flag initialized = 0; sys::cas_flag old_val = sys::CompareAndSwap(&initialized , 1, 0); if (old_val == 0) { initializeLiveDebugValuesPassOnce (Registry); sys::MemoryFence(); ; ; initialized = 2; ; } else { sys::cas_flag tmp = initialized; sys::MemoryFence(); while (tmp != 2) { tmp = initialized; sys::MemoryFence(); } } ; } |
123 | |
124 | /// Default construct and initialize the pass. |
125 | LiveDebugValues::LiveDebugValues() : MachineFunctionPass(ID) { |
126 | initializeLiveDebugValuesPass(*PassRegistry::getPassRegistry()); |
127 | } |
128 | |
129 | /// Tell the pass manager which passes we depend on and what information we |
130 | /// preserve. |
131 | void LiveDebugValues::getAnalysisUsage(AnalysisUsage &AU) const { |
132 | MachineFunctionPass::getAnalysisUsage(AU); |
133 | } |
134 | |
135 | // \brief If @MI is a DBG_VALUE with debug value described by a defined |
136 | // register, returns the number of this register. In the other case, returns 0. |
137 | static unsigned isDescribedByReg(const MachineInstr &MI) { |
138 | assert(MI.isDebugValue())((MI.isDebugValue()) ? static_cast<void> (0) : __assert_fail ("MI.isDebugValue()", "/tmp/buildd/llvm-toolchain-snapshot-3.9~svn270603/lib/CodeGen/LiveDebugValues.cpp" , 138, __PRETTY_FUNCTION__)); |
139 | assert(MI.getNumOperands() == 4)((MI.getNumOperands() == 4) ? static_cast<void> (0) : __assert_fail ("MI.getNumOperands() == 4", "/tmp/buildd/llvm-toolchain-snapshot-3.9~svn270603/lib/CodeGen/LiveDebugValues.cpp" , 139, __PRETTY_FUNCTION__)); |
140 | // If location of variable is described using a register (directly or |
141 | // indirecltly), this register is always a first operand. |
142 | return MI.getOperand(0).isReg() ? MI.getOperand(0).getReg() : 0; |
143 | } |
144 | |
145 | // \brief This function takes two DBG_VALUE instructions and returns true |
146 | // if their offsets are equal; otherwise returns false. |
147 | static bool areOffsetsEqual(const MachineInstr &MI1, const MachineInstr &MI2) { |
148 | assert(MI1.isDebugValue())((MI1.isDebugValue()) ? static_cast<void> (0) : __assert_fail ("MI1.isDebugValue()", "/tmp/buildd/llvm-toolchain-snapshot-3.9~svn270603/lib/CodeGen/LiveDebugValues.cpp" , 148, __PRETTY_FUNCTION__)); |
149 | assert(MI1.getNumOperands() == 4)((MI1.getNumOperands() == 4) ? static_cast<void> (0) : __assert_fail ("MI1.getNumOperands() == 4", "/tmp/buildd/llvm-toolchain-snapshot-3.9~svn270603/lib/CodeGen/LiveDebugValues.cpp" , 149, __PRETTY_FUNCTION__)); |
150 | |
151 | assert(MI2.isDebugValue())((MI2.isDebugValue()) ? static_cast<void> (0) : __assert_fail ("MI2.isDebugValue()", "/tmp/buildd/llvm-toolchain-snapshot-3.9~svn270603/lib/CodeGen/LiveDebugValues.cpp" , 151, __PRETTY_FUNCTION__)); |
152 | assert(MI2.getNumOperands() == 4)((MI2.getNumOperands() == 4) ? static_cast<void> (0) : __assert_fail ("MI2.getNumOperands() == 4", "/tmp/buildd/llvm-toolchain-snapshot-3.9~svn270603/lib/CodeGen/LiveDebugValues.cpp" , 152, __PRETTY_FUNCTION__)); |
153 | |
154 | if (!MI1.isIndirectDebugValue() && !MI2.isIndirectDebugValue()) |
155 | return true; |
156 | |
157 | // Check if both MIs are indirect and they are equal. |
158 | if (MI1.isIndirectDebugValue() && MI2.isIndirectDebugValue()) |
159 | return MI1.getOperand(1).getImm() == MI2.getOperand(1).getImm(); |
160 | |
161 | return false; |
162 | } |
163 | |
164 | //===----------------------------------------------------------------------===// |
165 | // Debug Range Extension Implementation |
166 | //===----------------------------------------------------------------------===// |
167 | |
168 | void LiveDebugValues::printVarLocInMBB(const VarLocInMBB &V, const char *msg, |
169 | raw_ostream &Out) const { |
170 | Out << "Printing " << msg << ":\n"; |
171 | for (const auto &L : V) { |
172 | Out << "MBB: " << L.first->getName() << ":\n"; |
173 | for (const auto &VLL : L.second) { |
174 | Out << " Var: " << VLL.Var.Var->getName(); |
175 | Out << " MI: "; |
176 | (*VLL.MI).dump(); |
177 | Out << "\n"; |
178 | } |
179 | } |
180 | Out << "\n"; |
181 | } |
182 | |
183 | bool LiveDebugValues::VarLoc::operator==(const VarLoc &V) const { |
184 | return (Var == V.Var) && (isDescribedByReg(*MI) == isDescribedByReg(*V.MI)) && |
185 | (areOffsetsEqual(*MI, *V.MI)); |
186 | } |
187 | |
188 | /// End all previous ranges related to @MI and start a new range from @MI |
189 | /// if it is a DBG_VALUE instr. |
190 | void LiveDebugValues::transferDebugValue(MachineInstr &MI, |
191 | VarLocList &OpenRanges) { |
192 | if (!MI.isDebugValue()) |
193 | return; |
194 | const DILocalVariable *RawVar = MI.getDebugVariable(); |
195 | assert(RawVar->isValidLocationForIntrinsic(MI.getDebugLoc()) &&((RawVar->isValidLocationForIntrinsic(MI.getDebugLoc()) && "Expected inlined-at fields to agree") ? static_cast<void > (0) : __assert_fail ("RawVar->isValidLocationForIntrinsic(MI.getDebugLoc()) && \"Expected inlined-at fields to agree\"" , "/tmp/buildd/llvm-toolchain-snapshot-3.9~svn270603/lib/CodeGen/LiveDebugValues.cpp" , 196, __PRETTY_FUNCTION__)) |
196 | "Expected inlined-at fields to agree")((RawVar->isValidLocationForIntrinsic(MI.getDebugLoc()) && "Expected inlined-at fields to agree") ? static_cast<void > (0) : __assert_fail ("RawVar->isValidLocationForIntrinsic(MI.getDebugLoc()) && \"Expected inlined-at fields to agree\"" , "/tmp/buildd/llvm-toolchain-snapshot-3.9~svn270603/lib/CodeGen/LiveDebugValues.cpp" , 196, __PRETTY_FUNCTION__)); |
197 | DebugVariable Var(RawVar, MI.getDebugLoc()->getInlinedAt()); |
198 | |
199 | // End all previous ranges of Var. |
200 | OpenRanges.erase( |
201 | std::remove_if(OpenRanges.begin(), OpenRanges.end(), |
202 | [&](const VarLoc &V) { return (Var == V.Var); }), |
203 | OpenRanges.end()); |
204 | |
205 | // Add Var to OpenRanges from this DBG_VALUE. |
206 | // TODO: Currently handles DBG_VALUE which has only reg as location. |
207 | if (isDescribedByReg(MI)) { |
208 | VarLoc V(Var, &MI); |
209 | OpenRanges.push_back(std::move(V)); |
210 | } |
211 | } |
212 | |
213 | /// A definition of a register may mark the end of a range. |
214 | void LiveDebugValues::transferRegisterDef(MachineInstr &MI, |
215 | VarLocList &OpenRanges) { |
216 | MachineFunction *MF = MI.getParent()->getParent(); |
217 | const TargetLowering *TLI = MF->getSubtarget().getTargetLowering(); |
218 | unsigned SP = TLI->getStackPointerRegisterToSaveRestore(); |
219 | for (const MachineOperand &MO : MI.operands()) { |
220 | if (MO.isReg() && MO.isDef() && MO.getReg() && |
221 | TRI->isPhysicalRegister(MO.getReg())) { |
222 | // Remove ranges of all aliased registers. |
223 | for (MCRegAliasIterator RAI(MO.getReg(), TRI, true); RAI.isValid(); ++RAI) |
224 | OpenRanges.erase(std::remove_if(OpenRanges.begin(), OpenRanges.end(), |
225 | [&](const VarLoc &V) { |
226 | return (*RAI == |
227 | isDescribedByReg(*V.MI)); |
228 | }), |
229 | OpenRanges.end()); |
230 | } else if (MO.isRegMask()) { |
231 | // Remove ranges of all clobbered registers. Register masks don't usually |
232 | // list SP as preserved. While the debug info may be off for an |
233 | // instruction or two around callee-cleanup calls, transferring the |
234 | // DEBUG_VALUE across the call is still a better user experience. |
235 | OpenRanges.erase(std::remove_if(OpenRanges.begin(), OpenRanges.end(), |
236 | [&](const VarLoc &V) { |
237 | unsigned Reg = isDescribedByReg(*V.MI); |
238 | return Reg && Reg != SP && |
239 | MO.clobbersPhysReg(Reg); |
240 | }), |
241 | OpenRanges.end()); |
242 | } |
243 | } |
244 | } |
245 | |
246 | /// Terminate all open ranges at the end of the current basic block. |
247 | bool LiveDebugValues::transferTerminatorInst(MachineInstr &MI, |
248 | VarLocList &OpenRanges, |
249 | VarLocInMBB &OutLocs) { |
250 | bool Changed = false; |
251 | const MachineBasicBlock *CurMBB = MI.getParent(); |
252 | if (!(MI.isTerminator() || (&MI == &CurMBB->instr_back()))) |
253 | return false; |
254 | |
255 | if (OpenRanges.empty()) |
256 | return false; |
257 | |
258 | VarLocList &VLL = OutLocs[CurMBB]; |
259 | |
260 | for (auto OR : OpenRanges) { |
261 | // Copy OpenRanges to OutLocs, if not already present. |
262 | assert(OR.MI->isDebugValue())((OR.MI->isDebugValue()) ? static_cast<void> (0) : __assert_fail ("OR.MI->isDebugValue()", "/tmp/buildd/llvm-toolchain-snapshot-3.9~svn270603/lib/CodeGen/LiveDebugValues.cpp" , 262, __PRETTY_FUNCTION__)); |
263 | DEBUG(dbgs() << "Add to OutLocs: "; OR.MI->dump();)do { if (::llvm::DebugFlag && ::llvm::isCurrentDebugType ("live-debug-values")) { dbgs() << "Add to OutLocs: "; OR .MI->dump();; } } while (0); |
264 | if (std::find_if(VLL.begin(), VLL.end(), |
265 | [&](const VarLoc &V) { return (OR == V); }) == VLL.end()) { |
266 | VLL.push_back(std::move(OR)); |
267 | Changed = true; |
268 | } |
269 | } |
270 | OpenRanges.clear(); |
271 | return Changed; |
272 | } |
273 | |
274 | /// This routine creates OpenRanges and OutLocs. |
275 | bool LiveDebugValues::transfer(MachineInstr &MI, VarLocList &OpenRanges, |
276 | VarLocInMBB &OutLocs) { |
277 | bool Changed = false; |
278 | transferDebugValue(MI, OpenRanges); |
279 | transferRegisterDef(MI, OpenRanges); |
280 | Changed = transferTerminatorInst(MI, OpenRanges, OutLocs); |
281 | return Changed; |
282 | } |
283 | |
284 | /// This routine joins the analysis results of all incoming edges in @MBB by |
285 | /// inserting a new DBG_VALUE instruction at the start of the @MBB - if the same |
286 | /// source variable in all the predecessors of @MBB reside in the same location. |
287 | bool LiveDebugValues::join(MachineBasicBlock &MBB, VarLocInMBB &OutLocs, |
288 | VarLocInMBB &InLocs) { |
289 | DEBUG(dbgs() << "join MBB: " << MBB.getName() << "\n")do { if (::llvm::DebugFlag && ::llvm::isCurrentDebugType ("live-debug-values")) { dbgs() << "join MBB: " << MBB.getName() << "\n"; } } while (0); |
290 | bool Changed = false; |
291 | |
292 | VarLocList InLocsT; // Temporary incoming locations. |
293 | |
294 | // For all predecessors of this MBB, find the set of VarLocs that can be |
295 | // joined. |
296 | for (auto p : MBB.predecessors()) { |
297 | auto OL = OutLocs.find(p); |
298 | // Join is null in case of empty OutLocs from any of the pred. |
299 | if (OL == OutLocs.end()) |
300 | return false; |
301 | |
302 | // Just copy over the Out locs to incoming locs for the first predecessor. |
303 | if (p == *MBB.pred_begin()) { |
304 | InLocsT = OL->second; |
305 | continue; |
306 | } |
307 | |
308 | // Join with this predecessor. |
309 | VarLocList &VLL = OL->second; |
310 | InLocsT.erase( |
311 | std::remove_if(InLocsT.begin(), InLocsT.end(), [&](VarLoc &ILT) { |
312 | return (std::find_if(VLL.begin(), VLL.end(), [&](const VarLoc &V) { |
313 | return (ILT == V); |
314 | }) == VLL.end()); |
315 | }), InLocsT.end()); |
316 | } |
317 | |
318 | if (InLocsT.empty()) |
319 | return false; |
320 | |
321 | VarLocList &ILL = InLocs[&MBB]; |
322 | |
323 | // Insert DBG_VALUE instructions, if not already inserted. |
324 | for (auto ILT : InLocsT) { |
325 | if (std::find_if(ILL.begin(), ILL.end(), [&](const VarLoc &I) { |
326 | return (ILT == I); |
327 | }) == ILL.end()) { |
328 | // This VarLoc is not found in InLocs i.e. it is not yet inserted. So, a |
329 | // new range is started for the var from the mbb's beginning by inserting |
330 | // a new DBG_VALUE. transfer() will end this range however appropriate. |
331 | const MachineInstr *DMI = ILT.MI; |
332 | MachineInstr *MI = |
333 | BuildMI(MBB, MBB.instr_begin(), DMI->getDebugLoc(), DMI->getDesc(), |
334 | DMI->isIndirectDebugValue(), DMI->getOperand(0).getReg(), 0, |
335 | DMI->getDebugVariable(), DMI->getDebugExpression()); |
336 | if (DMI->isIndirectDebugValue()) |
337 | MI->getOperand(1).setImm(DMI->getOperand(1).getImm()); |
338 | DEBUG(dbgs() << "Inserted: "; MI->dump();)do { if (::llvm::DebugFlag && ::llvm::isCurrentDebugType ("live-debug-values")) { dbgs() << "Inserted: "; MI-> dump();; } } while (0); |
339 | ++NumInserted; |
340 | Changed = true; |
341 | |
342 | VarLoc V(ILT.Var, MI); |
343 | ILL.push_back(std::move(V)); |
344 | } |
345 | } |
346 | return Changed; |
347 | } |
348 | |
349 | /// Calculate the liveness information for the given machine function and |
350 | /// extend ranges across basic blocks. |
351 | bool LiveDebugValues::ExtendRanges(MachineFunction &MF) { |
352 | |
353 | DEBUG(dbgs() << "\nDebug Range Extension\n")do { if (::llvm::DebugFlag && ::llvm::isCurrentDebugType ("live-debug-values")) { dbgs() << "\nDebug Range Extension\n" ; } } while (0); |
354 | |
355 | bool Changed = false; |
356 | bool OLChanged = false; |
357 | bool MBBJoined = false; |
358 | |
359 | VarLocList OpenRanges; // Ranges that are open until end of bb. |
360 | VarLocInMBB OutLocs; // Ranges that exist beyond bb. |
361 | VarLocInMBB InLocs; // Ranges that are incoming after joining. |
362 | |
363 | DenseMap<unsigned int, MachineBasicBlock *> OrderToBB; |
364 | DenseMap<MachineBasicBlock *, unsigned int> BBToOrder; |
365 | std::priority_queue<unsigned int, std::vector<unsigned int>, |
366 | std::greater<unsigned int>> Worklist; |
367 | std::priority_queue<unsigned int, std::vector<unsigned int>, |
368 | std::greater<unsigned int>> Pending; |
369 | // Initialize every mbb with OutLocs. |
370 | for (auto &MBB : MF) |
371 | for (auto &MI : MBB) |
372 | transfer(MI, OpenRanges, OutLocs); |
373 | DEBUG(printVarLocInMBB(OutLocs, "OutLocs after initialization", dbgs()))do { if (::llvm::DebugFlag && ::llvm::isCurrentDebugType ("live-debug-values")) { printVarLocInMBB(OutLocs, "OutLocs after initialization" , dbgs()); } } while (0); |
374 | |
375 | ReversePostOrderTraversal<MachineFunction *> RPOT(&MF); |
376 | unsigned int RPONumber = 0; |
377 | for (auto RI = RPOT.begin(), RE = RPOT.end(); RI != RE; ++RI) { |
378 | OrderToBB[RPONumber] = *RI; |
379 | BBToOrder[*RI] = RPONumber; |
380 | Worklist.push(RPONumber); |
381 | ++RPONumber; |
382 | } |
383 | |
384 | // This is a standard "union of predecessor outs" dataflow problem. |
385 | // To solve it, we perform join() and transfer() using the two worklist method |
386 | // until the ranges converge. |
387 | // Ranges have converged when both worklists are empty. |
388 | while (!Worklist.empty() || !Pending.empty()) { |
389 | // We track what is on the pending worklist to avoid inserting the same |
390 | // thing twice. We could avoid this with a custom priority queue, but this |
391 | // is probably not worth it. |
392 | SmallPtrSet<MachineBasicBlock *, 16> OnPending; |
393 | while (!Worklist.empty()) { |
394 | MachineBasicBlock *MBB = OrderToBB[Worklist.top()]; |
395 | Worklist.pop(); |
396 | MBBJoined = join(*MBB, OutLocs, InLocs); |
397 | |
398 | if (MBBJoined) { |
399 | MBBJoined = false; |
Value stored to 'MBBJoined' is never read | |
400 | Changed = true; |
401 | for (auto &MI : *MBB) |
402 | OLChanged |= transfer(MI, OpenRanges, OutLocs); |
403 | DEBUG(printVarLocInMBB(OutLocs, "OutLocs after propagating", dbgs()))do { if (::llvm::DebugFlag && ::llvm::isCurrentDebugType ("live-debug-values")) { printVarLocInMBB(OutLocs, "OutLocs after propagating" , dbgs()); } } while (0); |
404 | DEBUG(printVarLocInMBB(InLocs, "InLocs after propagating", dbgs()))do { if (::llvm::DebugFlag && ::llvm::isCurrentDebugType ("live-debug-values")) { printVarLocInMBB(InLocs, "InLocs after propagating" , dbgs()); } } while (0); |
405 | |
406 | if (OLChanged) { |
407 | OLChanged = false; |
408 | for (auto s : MBB->successors()) |
409 | if (!OnPending.count(s)) { |
410 | OnPending.insert(s); |
411 | Pending.push(BBToOrder[s]); |
412 | } |
413 | } |
414 | } |
415 | } |
416 | Worklist.swap(Pending); |
417 | // At this point, pending must be empty, since it was just the empty |
418 | // worklist |
419 | assert(Pending.empty() && "Pending should be empty")((Pending.empty() && "Pending should be empty") ? static_cast <void> (0) : __assert_fail ("Pending.empty() && \"Pending should be empty\"" , "/tmp/buildd/llvm-toolchain-snapshot-3.9~svn270603/lib/CodeGen/LiveDebugValues.cpp" , 419, __PRETTY_FUNCTION__)); |
420 | } |
421 | |
422 | DEBUG(printVarLocInMBB(OutLocs, "Final OutLocs", dbgs()))do { if (::llvm::DebugFlag && ::llvm::isCurrentDebugType ("live-debug-values")) { printVarLocInMBB(OutLocs, "Final OutLocs" , dbgs()); } } while (0); |
423 | DEBUG(printVarLocInMBB(InLocs, "Final InLocs", dbgs()))do { if (::llvm::DebugFlag && ::llvm::isCurrentDebugType ("live-debug-values")) { printVarLocInMBB(InLocs, "Final InLocs" , dbgs()); } } while (0); |
424 | return Changed; |
425 | } |
426 | |
427 | bool LiveDebugValues::runOnMachineFunction(MachineFunction &MF) { |
428 | TRI = MF.getSubtarget().getRegisterInfo(); |
429 | TII = MF.getSubtarget().getInstrInfo(); |
430 | |
431 | bool Changed = false; |
432 | |
433 | Changed |= ExtendRanges(MF); |
434 | |
435 | return Changed; |
436 | } |