Added support to dataflow solver to (when requested) also record dataflow
values for the block-level expressions.
Modified 'LiveVariables' to provide the option to clients to record
liveness information for block-level expressions (using the above feature).
Modified 'DeadStores' to conform to the new interface of 'LiveVariables'.
Modified 'GRConstants' to compute liveness information for block-level
expressions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46137 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Analysis/DeadStores.cpp b/Analysis/DeadStores.cpp
index 564478d..926109e 100644
--- a/Analysis/DeadStores.cpp
+++ b/Analysis/DeadStores.cpp
@@ -80,7 +80,7 @@
LiveVariables L(cfg);
L.runOnCFG(cfg);
DeadStoreObs A(Ctx, Diags);
- L.runOnAllBlocks(cfg,A);
+ L.runOnAllBlocks(cfg,&A);
}
} // end namespace clang
diff --git a/Analysis/GRConstants.cpp b/Analysis/GRConstants.cpp
index 64cc199..75f7fa0 100644
--- a/Analysis/GRConstants.cpp
+++ b/Analysis/GRConstants.cpp
@@ -189,6 +189,7 @@
cfg = &c;
Liveness = new LiveVariables(c);
Liveness->runOnCFG(c);
+ Liveness->runOnAllBlocks(c, NULL, true);
}
StateTy getInitialState() {
@@ -274,9 +275,6 @@
GRConstants::StateTy
GRConstants::RemoveSubExprMappings(StateTy M) {
-#if 0
- return M;
-#else
for (StateTy::iterator I = M.begin(), E = M.end();
I!=E && I.getKey().getKind() == DSPtr::IsSubExp; ++I) {
// Note: we can assign a new map to M since the iterators are
@@ -286,16 +284,12 @@
}
return M;
-#endif
}
GRConstants::StateTy
GRConstants::RemoveDescendantMappings(Stmt* S, GRConstants::StateTy State,
unsigned Levels) {
-#if 1
- return State;
-#else
typedef Stmt::child_iterator iterator;
for (iterator I=S->child_begin(), E=S->child_end(); I!=E; ++I)
@@ -317,7 +311,6 @@
}
return State;
-#endif
}
void GRConstants::DoStmt(Stmt* S) {
@@ -357,8 +350,11 @@
void GRConstants::VisitBinAssign(BinaryOperator* B) {
- if (DeclRefExpr* D = dyn_cast<DeclRefExpr>(B->getLHS()->IgnoreParens()))
- AddBinding(D->getDecl(), GetBinding(B->getRHS()));
+ if (DeclRefExpr* D = dyn_cast<DeclRefExpr>(B->getLHS()->IgnoreParens())) {
+ ExprVariantTy V = GetBinding(B->getRHS());
+ AddBinding(D->getDecl(), V);
+ AddBinding(B, V);
+ }
}
//===----------------------------------------------------------------------===//
diff --git a/Analysis/LiveVariables.cpp b/Analysis/LiveVariables.cpp
index 256b00d..ff4224a 100644
--- a/Analysis/LiveVariables.cpp
+++ b/Analysis/LiveVariables.cpp
@@ -165,11 +165,12 @@
}
void LiveVariables::runOnAllBlocks(const CFG& cfg,
- LiveVariables::ObserverTy& Obs) {
+ LiveVariables::ObserverTy* Obs,
+ bool recordStmtValues) {
Solver S(*this);
ObserverTy* OldObserver = getAnalysisData().Observer;
- getAnalysisData().Observer = &Obs;
- S.runOnAllBlocks(cfg);
+ getAnalysisData().Observer = Obs;
+ S.runOnAllBlocks(cfg, recordStmtValues);
getAnalysisData().Observer = OldObserver;
}