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