1 //===-- BBLiveVar.h - Live Variable Analysis for a BasicBlock ----*- C++ -*--=//
3 // This is a BasicBlock annotation class that is used by live var analysis to
4 // hold data flow information for a basic block.
6 //===----------------------------------------------------------------------===//
11 #include "llvm/Analysis/LiveVar/ValueSet.h"
12 #include "llvm/Annotation.h"
18 class BBLiveVar : public Annotation {
19 const BasicBlock *BB; // pointer to BasicBlock
20 unsigned POID; // Post-Order ID
22 ValueSet DefSet; // Def set (with no preceding uses) for LV analysis
23 ValueSet InSet, OutSet; // In & Out for LV analysis
24 bool InSetChanged, OutSetChanged; // set if the InSet/OutSet is modified
26 // map that contains PredBB -> Phi arguments
27 // coming in on that edge. such uses have to be
28 // treated differently from ordinary uses.
29 std::map<const BasicBlock *, ValueSet> PredToEdgeInSetMap;
31 // method to propogate an InSet to OutSet of a predecessor
32 bool setPropagate(ValueSet *OutSetOfPred,
33 const ValueSet *InSetOfThisBB,
34 const BasicBlock *PredBB);
36 // To add an operand which is a def
37 void addDef(const Value *Op);
39 // To add an operand which is a use
40 void addUse(const Value *Op);
42 void calcDefUseSets(); // calculates the Def & Use sets for this BB
44 BBLiveVar(const BasicBlock *BB, unsigned POID);
45 ~BBLiveVar() {} // make dtor private
47 static BBLiveVar *CreateOnBB(const BasicBlock *BB, unsigned POID);
48 static BBLiveVar *GetFromBB(const BasicBlock *BB);
49 static void RemoveFromBB(const BasicBlock *BB);
51 inline bool isInSetChanged() const { return InSetChanged; }
52 inline bool isOutSetChanged() const { return OutSetChanged; }
54 inline unsigned getPOId() const { return POID; }
56 bool applyTransferFunc(); // calcultes the In in terms of Out
58 // calculates Out set using In sets of the predecessors
61 inline const ValueSet &getOutSet() const { return OutSet; }
62 inline const ValueSet &getInSet() const { return InSet; }
64 void printAllSets() const; // for printing Def/In/Out sets
65 void printInOutSets() const; // for printing In/Out sets