LiveVariables analysis now uses intersect for the merge of block-level expression liveness information.

The rationale is that a block-level expression cannot be live in a parent block unless it is live in all of the successor blocks.

llvm-svn: 48618
This commit is contained in:
Ted Kremenek 2008-03-20 21:46:49 +00:00
parent 5ca2ea6479
commit b7151c7ca8
2 changed files with 30 additions and 3 deletions

View File

@ -119,7 +119,7 @@ struct DeclBitVector_Types {
const llvm::BitVector::reference getDeclBit(unsigned i) const {
return const_cast<llvm::BitVector&>(DeclBV)[i];
}
ValTy& operator|=(const ValTy& RHS) {
assert (sizesEqual(RHS));
DeclBV |= RHS.DeclBV;
@ -132,6 +132,14 @@ struct DeclBitVector_Types {
return *this;
}
ValTy& OrDeclBits(const ValTy& RHS) {
return operator|=(RHS);
}
ValTy& AndDeclBits(const ValTy& RHS) {
return operator&=(RHS);
}
bool sizesEqual(const ValTy& RHS) const {
return DeclBV.size() == RHS.DeclBV.size();
}
@ -225,6 +233,16 @@ struct ExprDeclBitVector_Types {
return const_cast<llvm::BitVector&>(ExprBV)[i];
}
ValTy& OrExprBits(const ValTy& RHS) {
ExprBV |= RHS.ExprBV;
return *this;
}
ValTy& AndExprBits(const ValTy& RHS) {
ExprBV &= RHS.ExprBV;
return *this;
}
ValTy& operator|=(const ValTy& RHS) {
assert (sizesEqual(RHS));
ParentRef(*this) |= ParentRef(RHS);

View File

@ -168,8 +168,17 @@ void TransferFuncs::VisitDeclStmt(DeclStmt* DS) {
//===----------------------------------------------------------------------===//
namespace {
typedef ExprDeclBitVector_Types::Union Merge;
typedef DataflowSolver<LiveVariables,TransferFuncs,Merge> Solver;
struct Merge {
typedef ExprDeclBitVector_Types::ValTy ValTy;
void operator()(ValTy& Dst, const ValTy& Src) {
Dst.OrDeclBits(Src);
Dst.AndExprBits(Src);
}
};
typedef DataflowSolver<LiveVariables, TransferFuncs, Merge> Solver;
} // end anonymous namespace
//===----------------------------------------------------------------------===//