summaryrefslogtreecommitdiffstats
path: root/clang/lib/Analysis/LiveVariables.cpp
diff options
context:
space:
mode:
authorTom Care <tom.care@uqconnect.edu.au>2010-08-27 22:30:10 +0000
committerTom Care <tom.care@uqconnect.edu.au>2010-08-27 22:30:10 +0000
commite5aa30c722a7e5ffec1372c2a863a54bfd558850 (patch)
tree4c56e05e1237f2eeec27c9d499c4bfe646a84cbd /clang/lib/Analysis/LiveVariables.cpp
parentf2855b147fc5015c11d950f7be9b777727be0468 (diff)
downloadbcm5719-llvm-e5aa30c722a7e5ffec1372c2a863a54bfd558850.tar.gz
bcm5719-llvm-e5aa30c722a7e5ffec1372c2a863a54bfd558850.zip
Add alternate version of LiveVariables analysis that does not kill liveness at assignments. This 'relaxed' liveness is useful in path sensitive analysis for situations where the resulting extended liveness allows us to find some bugs.
- Added killAtAssign flag to LiveVariables - Added relaxed LiveVariables to AnalysisContext with an accessor llvm-svn: 112306
Diffstat (limited to 'clang/lib/Analysis/LiveVariables.cpp')
-rw-r--r--clang/lib/Analysis/LiveVariables.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/clang/lib/Analysis/LiveVariables.cpp b/clang/lib/Analysis/LiveVariables.cpp
index 3011fd0dee4..47b2e3d6040 100644
--- a/clang/lib/Analysis/LiveVariables.cpp
+++ b/clang/lib/Analysis/LiveVariables.cpp
@@ -77,12 +77,13 @@ public:
};
} // end anonymous namespace
-LiveVariables::LiveVariables(AnalysisContext &AC) {
+LiveVariables::LiveVariables(AnalysisContext &AC, bool killAtAssign) {
// Register all referenced VarDecls.
CFG &cfg = *AC.getCFG();
getAnalysisData().setCFG(cfg);
getAnalysisData().setContext(AC.getASTContext());
getAnalysisData().AC = &AC;
+ getAnalysisData().killAtAssign = killAtAssign;
RegisterDecls R(getAnalysisData());
cfg.VisitBlockStmts(R);
@@ -260,12 +261,13 @@ void TransferFuncs::VisitAssign(BinaryOperator* B) {
if (DR->getDecl()->getType()->isReferenceType()) {
VisitDeclRefExpr(DR);
} else {
- // Update liveness inforamtion.
- unsigned bit = AD.getIdx(DR->getDecl());
- LiveState.getDeclBit(bit) = Dead | AD.AlwaysLive.getDeclBit(bit);
-
- if (AD.Observer) { AD.Observer->ObserverKill(DR); }
+ if (AD.killAtAssign) {
+ // Update liveness inforamtion.
+ unsigned bit = AD.getIdx(DR->getDecl());
+ LiveState.getDeclBit(bit) = Dead | AD.AlwaysLive.getDeclBit(bit);
+ if (AD.Observer) { AD.Observer->ObserverKill(DR); }
+ }
// Handle things like +=, etc., which also generate "uses"
// of a variable. Do this just by visiting the subexpression.
if (B->getOpcode() != BO_Assign)
OpenPOWER on IntegriCloud