1 //=- LiveVariables.cpp - Live Variable Analysis for Source CFGs ----------*-==//
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 Live Variables analysis for source-level CFGs.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "clang/Analysis/Analyses/LiveVariables.h"
15 #include "clang/AST/Stmt.h"
16 #include "clang/AST/StmtVisitor.h"
17 #include "clang/Analysis/Analyses/PostOrderCFGView.h"
18 #include "clang/Analysis/AnalysisContext.h"
19 #include "clang/Analysis/CFG.h"
20 #include "llvm/ADT/DenseMap.h"
21 #include "llvm/ADT/PostOrderIterator.h"
22 #include "llvm/Support/raw_ostream.h"
23 #include <algorithm>
24 #include <vector>
25 
26 using namespace clang;
27 
28 namespace {
29 
30 class DataflowWorklist {
31   SmallVector<const CFGBlock *, 20> worklist;
32   llvm::BitVector enqueuedBlocks;
33   PostOrderCFGView *POV;
34 public:
35   DataflowWorklist(const CFG &cfg, AnalysisDeclContext &Ctx)
36     : enqueuedBlocks(cfg.getNumBlockIDs()),
37       POV(Ctx.getAnalysis<PostOrderCFGView>()) {}
38 
39   void enqueueBlock(const CFGBlock *block);
40   void enqueueSuccessors(const CFGBlock *block);
41   void enqueuePredecessors(const CFGBlock *block);
42 
43   const CFGBlock *dequeue();
44 
45   void sortWorklist();
46 };
47 
48 }
49 
50 void DataflowWorklist::enqueueBlock(const clang::CFGBlock *block) {
51   if (block && !enqueuedBlocks[block->getBlockID()]) {
52     enqueuedBlocks[block->getBlockID()] = true;
53     worklist.push_back(block);
54   }
55 }
56 
57 void DataflowWorklist::enqueueSuccessors(const clang::CFGBlock *block) {
58   const unsigned OldWorklistSize = worklist.size();
59   for (CFGBlock::const_succ_iterator I = block->succ_begin(),
60        E = block->succ_end(); I != E; ++I) {
61     enqueueBlock(*I);
62   }
63 
64   if (OldWorklistSize == 0 || OldWorklistSize == worklist.size())
65     return;
66 
67   sortWorklist();
68 }
69 
70 void DataflowWorklist::enqueuePredecessors(const clang::CFGBlock *block) {
71   const unsigned OldWorklistSize = worklist.size();
72   for (CFGBlock::const_pred_iterator I = block->pred_begin(),
73        E = block->pred_end(); I != E; ++I) {
74     enqueueBlock(*I);
75   }
76 
77   if (OldWorklistSize == 0 || OldWorklistSize == worklist.size())
78     return;
79 
80   sortWorklist();
81 }
82 
83 void DataflowWorklist::sortWorklist() {
84   std::sort(worklist.begin(), worklist.end(), POV->getComparator());
85 }
86 
87 const CFGBlock *DataflowWorklist::dequeue() {
88   if (worklist.empty())
89     return 0;
90   const CFGBlock *b = worklist.pop_back_val();
91   enqueuedBlocks[b->getBlockID()] = false;
92   return b;
93 }
94 
95 namespace {
96 class LiveVariablesImpl {
97 public:
98   AnalysisDeclContext &analysisContext;
99   std::vector<LiveVariables::LivenessValues> cfgBlockValues;
100   llvm::ImmutableSet<const Stmt *>::Factory SSetFact;
101   llvm::ImmutableSet<const VarDecl *>::Factory DSetFact;
102   llvm::DenseMap<const CFGBlock *, LiveVariables::LivenessValues> blocksEndToLiveness;
103   llvm::DenseMap<const CFGBlock *, LiveVariables::LivenessValues> blocksBeginToLiveness;
104   llvm::DenseMap<const Stmt *, LiveVariables::LivenessValues> stmtsToLiveness;
105   llvm::DenseMap<const DeclRefExpr *, unsigned> inAssignment;
106   const bool killAtAssign;
107 
108   LiveVariables::LivenessValues
109   merge(LiveVariables::LivenessValues valsA,
110         LiveVariables::LivenessValues valsB);
111 
112   LiveVariables::LivenessValues runOnBlock(const CFGBlock *block,
113                                            LiveVariables::LivenessValues val,
114                                            LiveVariables::Observer *obs = 0);
115 
116   void dumpBlockLiveness(const SourceManager& M);
117 
118   LiveVariablesImpl(AnalysisDeclContext &ac, bool KillAtAssign)
119     : analysisContext(ac),
120       SSetFact(false), // Do not canonicalize ImmutableSets by default.
121       DSetFact(false), // This is a *major* performance win.
122       killAtAssign(KillAtAssign) {}
123 };
124 }
125 
126 static LiveVariablesImpl &getImpl(void *x) {
127   return *((LiveVariablesImpl *) x);
128 }
129 
130 //===----------------------------------------------------------------------===//
131 // Operations and queries on LivenessValues.
132 //===----------------------------------------------------------------------===//
133 
134 bool LiveVariables::LivenessValues::isLive(const Stmt *S) const {
135   return liveStmts.contains(S);
136 }
137 
138 bool LiveVariables::LivenessValues::isLive(const VarDecl *D) const {
139   return liveDecls.contains(D);
140 }
141 
142 namespace {
143   template <typename SET>
144   SET mergeSets(SET A, SET B) {
145     if (A.isEmpty())
146       return B;
147 
148     for (typename SET::iterator it = B.begin(), ei = B.end(); it != ei; ++it) {
149       A = A.add(*it);
150     }
151     return A;
152   }
153 }
154 
155 void LiveVariables::Observer::anchor() { }
156 
157 LiveVariables::LivenessValues
158 LiveVariablesImpl::merge(LiveVariables::LivenessValues valsA,
159                          LiveVariables::LivenessValues valsB) {
160 
161   llvm::ImmutableSetRef<const Stmt *>
162     SSetRefA(valsA.liveStmts.getRootWithoutRetain(), SSetFact.getTreeFactory()),
163     SSetRefB(valsB.liveStmts.getRootWithoutRetain(), SSetFact.getTreeFactory());
164 
165 
166   llvm::ImmutableSetRef<const VarDecl *>
167     DSetRefA(valsA.liveDecls.getRootWithoutRetain(), DSetFact.getTreeFactory()),
168     DSetRefB(valsB.liveDecls.getRootWithoutRetain(), DSetFact.getTreeFactory());
169 
170 
171   SSetRefA = mergeSets(SSetRefA, SSetRefB);
172   DSetRefA = mergeSets(DSetRefA, DSetRefB);
173 
174   // asImmutableSet() canonicalizes the tree, allowing us to do an easy
175   // comparison afterwards.
176   return LiveVariables::LivenessValues(SSetRefA.asImmutableSet(),
177                                        DSetRefA.asImmutableSet());
178 }
179 
180 bool LiveVariables::LivenessValues::equals(const LivenessValues &V) const {
181   return liveStmts == V.liveStmts && liveDecls == V.liveDecls;
182 }
183 
184 //===----------------------------------------------------------------------===//
185 // Query methods.
186 //===----------------------------------------------------------------------===//
187 
188 static bool isAlwaysAlive(const VarDecl *D) {
189   return D->hasGlobalStorage();
190 }
191 
192 bool LiveVariables::isLive(const CFGBlock *B, const VarDecl *D) {
193   return isAlwaysAlive(D) || getImpl(impl).blocksEndToLiveness[B].isLive(D);
194 }
195 
196 bool LiveVariables::isLive(const Stmt *S, const VarDecl *D) {
197   return isAlwaysAlive(D) || getImpl(impl).stmtsToLiveness[S].isLive(D);
198 }
199 
200 bool LiveVariables::isLive(const Stmt *Loc, const Stmt *S) {
201   return getImpl(impl).stmtsToLiveness[Loc].isLive(S);
202 }
203 
204 //===----------------------------------------------------------------------===//
205 // Dataflow computation.
206 //===----------------------------------------------------------------------===//
207 
208 namespace {
209 class TransferFunctions : public StmtVisitor<TransferFunctions> {
210   LiveVariablesImpl &LV;
211   LiveVariables::LivenessValues &val;
212   LiveVariables::Observer *observer;
213   const CFGBlock *currentBlock;
214 public:
215   TransferFunctions(LiveVariablesImpl &im,
216                     LiveVariables::LivenessValues &Val,
217                     LiveVariables::Observer *Observer,
218                     const CFGBlock *CurrentBlock)
219   : LV(im), val(Val), observer(Observer), currentBlock(CurrentBlock) {}
220 
221   void VisitBinaryOperator(BinaryOperator *BO);
222   void VisitBlockExpr(BlockExpr *BE);
223   void VisitDeclRefExpr(DeclRefExpr *DR);
224   void VisitDeclStmt(DeclStmt *DS);
225   void VisitObjCForCollectionStmt(ObjCForCollectionStmt *OS);
226   void VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *UE);
227   void VisitUnaryOperator(UnaryOperator *UO);
228   void Visit(Stmt *S);
229 };
230 }
231 
232 static const VariableArrayType *FindVA(QualType Ty) {
233   const Type *ty = Ty.getTypePtr();
234   while (const ArrayType *VT = dyn_cast<ArrayType>(ty)) {
235     if (const VariableArrayType *VAT = dyn_cast<VariableArrayType>(VT))
236       if (VAT->getSizeExpr())
237         return VAT;
238 
239     ty = VT->getElementType().getTypePtr();
240   }
241 
242   return 0;
243 }
244 
245 static const Stmt *LookThroughStmt(const Stmt *S) {
246   while (S) {
247     if (const Expr *Ex = dyn_cast<Expr>(S))
248       S = Ex->IgnoreParens();
249     if (const ExprWithCleanups *EWC = dyn_cast<ExprWithCleanups>(S)) {
250       S = EWC->getSubExpr();
251       continue;
252     }
253     if (const OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(S)) {
254       S = OVE->getSourceExpr();
255       continue;
256     }
257     break;
258   }
259   return S;
260 }
261 
262 static void AddLiveStmt(llvm::ImmutableSet<const Stmt *> &Set,
263                         llvm::ImmutableSet<const Stmt *>::Factory &F,
264                         const Stmt *S) {
265   Set = F.add(Set, LookThroughStmt(S));
266 }
267 
268 void TransferFunctions::Visit(Stmt *S) {
269   if (observer)
270     observer->observeStmt(S, currentBlock, val);
271 
272   StmtVisitor<TransferFunctions>::Visit(S);
273 
274   if (isa<Expr>(S)) {
275     val.liveStmts = LV.SSetFact.remove(val.liveStmts, S);
276   }
277 
278   // Mark all children expressions live.
279 
280   switch (S->getStmtClass()) {
281     default:
282       break;
283     case Stmt::StmtExprClass: {
284       // For statement expressions, look through the compound statement.
285       S = cast<StmtExpr>(S)->getSubStmt();
286       break;
287     }
288     case Stmt::CXXMemberCallExprClass: {
289       // Include the implicit "this" pointer as being live.
290       CXXMemberCallExpr *CE = cast<CXXMemberCallExpr>(S);
291       if (Expr *ImplicitObj = CE->getImplicitObjectArgument()) {
292         AddLiveStmt(val.liveStmts, LV.SSetFact, ImplicitObj);
293       }
294       break;
295     }
296     case Stmt::ObjCMessageExprClass: {
297       // In calls to super, include the implicit "self" pointer as being live.
298       ObjCMessageExpr *CE = cast<ObjCMessageExpr>(S);
299       if (CE->getReceiverKind() == ObjCMessageExpr::SuperInstance)
300         val.liveDecls = LV.DSetFact.add(val.liveDecls,
301                                         LV.analysisContext.getSelfDecl());
302       break;
303     }
304     case Stmt::DeclStmtClass: {
305       const DeclStmt *DS = cast<DeclStmt>(S);
306       if (const VarDecl *VD = dyn_cast<VarDecl>(DS->getSingleDecl())) {
307         for (const VariableArrayType* VA = FindVA(VD->getType());
308              VA != 0; VA = FindVA(VA->getElementType())) {
309           AddLiveStmt(val.liveStmts, LV.SSetFact, VA->getSizeExpr());
310         }
311       }
312       break;
313     }
314     case Stmt::PseudoObjectExprClass: {
315       // A pseudo-object operation only directly consumes its result
316       // expression.
317       Expr *child = cast<PseudoObjectExpr>(S)->getResultExpr();
318       if (!child) return;
319       if (OpaqueValueExpr *OV = dyn_cast<OpaqueValueExpr>(child))
320         child = OV->getSourceExpr();
321       child = child->IgnoreParens();
322       val.liveStmts = LV.SSetFact.add(val.liveStmts, child);
323       return;
324     }
325 
326     // FIXME: These cases eventually shouldn't be needed.
327     case Stmt::ExprWithCleanupsClass: {
328       S = cast<ExprWithCleanups>(S)->getSubExpr();
329       break;
330     }
331     case Stmt::CXXBindTemporaryExprClass: {
332       S = cast<CXXBindTemporaryExpr>(S)->getSubExpr();
333       break;
334     }
335     case Stmt::UnaryExprOrTypeTraitExprClass: {
336       // No need to unconditionally visit subexpressions.
337       return;
338     }
339   }
340 
341   for (Stmt::child_iterator it = S->child_begin(), ei = S->child_end();
342        it != ei; ++it) {
343     if (Stmt *child = *it)
344       AddLiveStmt(val.liveStmts, LV.SSetFact, child);
345   }
346 }
347 
348 void TransferFunctions::VisitBinaryOperator(BinaryOperator *B) {
349   if (B->isAssignmentOp()) {
350     if (!LV.killAtAssign)
351       return;
352 
353     // Assigning to a variable?
354     Expr *LHS = B->getLHS()->IgnoreParens();
355 
356     if (DeclRefExpr *DR = dyn_cast<DeclRefExpr>(LHS))
357       if (const VarDecl *VD = dyn_cast<VarDecl>(DR->getDecl())) {
358         // Assignments to references don't kill the ref's address
359         if (VD->getType()->isReferenceType())
360           return;
361 
362         if (!isAlwaysAlive(VD)) {
363           // The variable is now dead.
364           val.liveDecls = LV.DSetFact.remove(val.liveDecls, VD);
365         }
366 
367         if (observer)
368           observer->observerKill(DR);
369       }
370   }
371 }
372 
373 void TransferFunctions::VisitBlockExpr(BlockExpr *BE) {
374   AnalysisDeclContext::referenced_decls_iterator I, E;
375   std::tie(I, E) =
376     LV.analysisContext.getReferencedBlockVars(BE->getBlockDecl());
377   for ( ; I != E ; ++I) {
378     const VarDecl *VD = *I;
379     if (isAlwaysAlive(VD))
380       continue;
381     val.liveDecls = LV.DSetFact.add(val.liveDecls, VD);
382   }
383 }
384 
385 void TransferFunctions::VisitDeclRefExpr(DeclRefExpr *DR) {
386   if (const VarDecl *D = dyn_cast<VarDecl>(DR->getDecl()))
387     if (!isAlwaysAlive(D) && LV.inAssignment.find(DR) == LV.inAssignment.end())
388       val.liveDecls = LV.DSetFact.add(val.liveDecls, D);
389 }
390 
391 void TransferFunctions::VisitDeclStmt(DeclStmt *DS) {
392   for (const auto *DI : DS->decls())
393     if (const auto *VD = dyn_cast<VarDecl>(DI)) {
394       if (!isAlwaysAlive(VD))
395         val.liveDecls = LV.DSetFact.remove(val.liveDecls, VD);
396     }
397 }
398 
399 void TransferFunctions::VisitObjCForCollectionStmt(ObjCForCollectionStmt *OS) {
400   // Kill the iteration variable.
401   DeclRefExpr *DR = 0;
402   const VarDecl *VD = 0;
403 
404   Stmt *element = OS->getElement();
405   if (DeclStmt *DS = dyn_cast<DeclStmt>(element)) {
406     VD = cast<VarDecl>(DS->getSingleDecl());
407   }
408   else if ((DR = dyn_cast<DeclRefExpr>(cast<Expr>(element)->IgnoreParens()))) {
409     VD = cast<VarDecl>(DR->getDecl());
410   }
411 
412   if (VD) {
413     val.liveDecls = LV.DSetFact.remove(val.liveDecls, VD);
414     if (observer && DR)
415       observer->observerKill(DR);
416   }
417 }
418 
419 void TransferFunctions::
420 VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *UE)
421 {
422   // While sizeof(var) doesn't technically extend the liveness of 'var', it
423   // does extent the liveness of metadata if 'var' is a VariableArrayType.
424   // We handle that special case here.
425   if (UE->getKind() != UETT_SizeOf || UE->isArgumentType())
426     return;
427 
428   const Expr *subEx = UE->getArgumentExpr();
429   if (subEx->getType()->isVariableArrayType()) {
430     assert(subEx->isLValue());
431     val.liveStmts = LV.SSetFact.add(val.liveStmts, subEx->IgnoreParens());
432   }
433 }
434 
435 void TransferFunctions::VisitUnaryOperator(UnaryOperator *UO) {
436   // Treat ++/-- as a kill.
437   // Note we don't actually have to do anything if we don't have an observer,
438   // since a ++/-- acts as both a kill and a "use".
439   if (!observer)
440     return;
441 
442   switch (UO->getOpcode()) {
443   default:
444     return;
445   case UO_PostInc:
446   case UO_PostDec:
447   case UO_PreInc:
448   case UO_PreDec:
449     break;
450   }
451 
452   if (DeclRefExpr *DR = dyn_cast<DeclRefExpr>(UO->getSubExpr()->IgnoreParens()))
453     if (isa<VarDecl>(DR->getDecl())) {
454       // Treat ++/-- as a kill.
455       observer->observerKill(DR);
456     }
457 }
458 
459 LiveVariables::LivenessValues
460 LiveVariablesImpl::runOnBlock(const CFGBlock *block,
461                               LiveVariables::LivenessValues val,
462                               LiveVariables::Observer *obs) {
463 
464   TransferFunctions TF(*this, val, obs, block);
465 
466   // Visit the terminator (if any).
467   if (const Stmt *term = block->getTerminator())
468     TF.Visit(const_cast<Stmt*>(term));
469 
470   // Apply the transfer function for all Stmts in the block.
471   for (CFGBlock::const_reverse_iterator it = block->rbegin(),
472        ei = block->rend(); it != ei; ++it) {
473     const CFGElement &elem = *it;
474 
475     if (Optional<CFGAutomaticObjDtor> Dtor =
476             elem.getAs<CFGAutomaticObjDtor>()) {
477       val.liveDecls = DSetFact.add(val.liveDecls, Dtor->getVarDecl());
478       continue;
479     }
480 
481     if (!elem.getAs<CFGStmt>())
482       continue;
483 
484     const Stmt *S = elem.castAs<CFGStmt>().getStmt();
485     TF.Visit(const_cast<Stmt*>(S));
486     stmtsToLiveness[S] = val;
487   }
488   return val;
489 }
490 
491 void LiveVariables::runOnAllBlocks(LiveVariables::Observer &obs) {
492   const CFG *cfg = getImpl(impl).analysisContext.getCFG();
493   for (CFG::const_iterator it = cfg->begin(), ei = cfg->end(); it != ei; ++it)
494     getImpl(impl).runOnBlock(*it, getImpl(impl).blocksEndToLiveness[*it], &obs);
495 }
496 
497 LiveVariables::LiveVariables(void *im) : impl(im) {}
498 
499 LiveVariables::~LiveVariables() {
500   delete (LiveVariablesImpl*) impl;
501 }
502 
503 LiveVariables *
504 LiveVariables::computeLiveness(AnalysisDeclContext &AC,
505                                  bool killAtAssign) {
506 
507   // No CFG?  Bail out.
508   CFG *cfg = AC.getCFG();
509   if (!cfg)
510     return 0;
511 
512   // The analysis currently has scalability issues for very large CFGs.
513   // Bail out if it looks too large.
514   if (cfg->getNumBlockIDs() > 300000)
515     return 0;
516 
517   LiveVariablesImpl *LV = new LiveVariablesImpl(AC, killAtAssign);
518 
519   // Construct the dataflow worklist.  Enqueue the exit block as the
520   // start of the analysis.
521   DataflowWorklist worklist(*cfg, AC);
522   llvm::BitVector everAnalyzedBlock(cfg->getNumBlockIDs());
523 
524   // FIXME: we should enqueue using post order.
525   for (CFG::const_iterator it = cfg->begin(), ei = cfg->end(); it != ei; ++it) {
526     const CFGBlock *block = *it;
527     worklist.enqueueBlock(block);
528 
529     // FIXME: Scan for DeclRefExprs using in the LHS of an assignment.
530     // We need to do this because we lack context in the reverse analysis
531     // to determine if a DeclRefExpr appears in such a context, and thus
532     // doesn't constitute a "use".
533     if (killAtAssign)
534       for (CFGBlock::const_iterator bi = block->begin(), be = block->end();
535            bi != be; ++bi) {
536         if (Optional<CFGStmt> cs = bi->getAs<CFGStmt>()) {
537           if (const BinaryOperator *BO =
538                   dyn_cast<BinaryOperator>(cs->getStmt())) {
539             if (BO->getOpcode() == BO_Assign) {
540               if (const DeclRefExpr *DR =
541                     dyn_cast<DeclRefExpr>(BO->getLHS()->IgnoreParens())) {
542                 LV->inAssignment[DR] = 1;
543               }
544             }
545           }
546         }
547       }
548   }
549 
550   worklist.sortWorklist();
551 
552   while (const CFGBlock *block = worklist.dequeue()) {
553     // Determine if the block's end value has changed.  If not, we
554     // have nothing left to do for this block.
555     LivenessValues &prevVal = LV->blocksEndToLiveness[block];
556 
557     // Merge the values of all successor blocks.
558     LivenessValues val;
559     for (CFGBlock::const_succ_iterator it = block->succ_begin(),
560                                        ei = block->succ_end(); it != ei; ++it) {
561       if (const CFGBlock *succ = *it) {
562         val = LV->merge(val, LV->blocksBeginToLiveness[succ]);
563       }
564     }
565 
566     if (!everAnalyzedBlock[block->getBlockID()])
567       everAnalyzedBlock[block->getBlockID()] = true;
568     else if (prevVal.equals(val))
569       continue;
570 
571     prevVal = val;
572 
573     // Update the dataflow value for the start of this block.
574     LV->blocksBeginToLiveness[block] = LV->runOnBlock(block, val);
575 
576     // Enqueue the value to the predecessors.
577     worklist.enqueuePredecessors(block);
578   }
579 
580   return new LiveVariables(LV);
581 }
582 
583 void LiveVariables::dumpBlockLiveness(const SourceManager &M) {
584   getImpl(impl).dumpBlockLiveness(M);
585 }
586 
587 void LiveVariablesImpl::dumpBlockLiveness(const SourceManager &M) {
588   std::vector<const CFGBlock *> vec;
589   for (llvm::DenseMap<const CFGBlock *, LiveVariables::LivenessValues>::iterator
590        it = blocksEndToLiveness.begin(), ei = blocksEndToLiveness.end();
591        it != ei; ++it) {
592     vec.push_back(it->first);
593   }
594   std::sort(vec.begin(), vec.end(), [](const CFGBlock *A, const CFGBlock *B) {
595     return A->getBlockID() < B->getBlockID();
596   });
597 
598   std::vector<const VarDecl*> declVec;
599 
600   for (std::vector<const CFGBlock *>::iterator
601         it = vec.begin(), ei = vec.end(); it != ei; ++it) {
602     llvm::errs() << "\n[ B" << (*it)->getBlockID()
603                  << " (live variables at block exit) ]\n";
604 
605     LiveVariables::LivenessValues vals = blocksEndToLiveness[*it];
606     declVec.clear();
607 
608     for (llvm::ImmutableSet<const VarDecl *>::iterator si =
609           vals.liveDecls.begin(),
610           se = vals.liveDecls.end(); si != se; ++si) {
611       declVec.push_back(*si);
612     }
613 
614     std::sort(declVec.begin(), declVec.end(), [](const Decl *A, const Decl *B) {
615       return A->getLocStart() < B->getLocStart();
616     });
617 
618     for (std::vector<const VarDecl*>::iterator di = declVec.begin(),
619          de = declVec.end(); di != de; ++di) {
620       llvm::errs() << " " << (*di)->getDeclName().getAsString()
621                    << " <";
622       (*di)->getLocation().dump(M);
623       llvm::errs() << ">\n";
624     }
625   }
626   llvm::errs() << "\n";
627 }
628 
629 const void *LiveVariables::getTag() { static int x; return &x; }
630 const void *RelaxedLiveVariables::getTag() { static int x; return &x; }
631