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"
17 enum LiveVarDebugLevel_t {
24 extern LiveVarDebugLevel_t DEBUG_LV;
26 class BBLiveVar : public Annotation {
27 const BasicBlock *BB; // pointer to BasicBlock
28 unsigned POID; // Post-Order ID
30 ValueSet DefSet; // Def set (with no preceding uses) for LV analysis
31 ValueSet InSet, OutSet; // In & Out for LV analysis
32 bool InSetChanged, OutSetChanged; // set if the InSet/OutSet is modified
34 // map that contains PredBB -> Phi arguments
35 // coming in on that edge. such uses have to be
36 // treated differently from ordinary uses.
37 std::map<const BasicBlock *, ValueSet> PredToEdgeInSetMap;
39 // method to propogate an InSet to OutSet of a predecessor
40 bool setPropagate(ValueSet *OutSetOfPred,
41 const ValueSet *InSetOfThisBB,
42 const BasicBlock *PredBB);
44 // To add an operand which is a def
45 void addDef(const Value *Op);
47 // To add an operand which is a use
48 void addUse(const Value *Op);
50 void calcDefUseSets(); // calculates the Def & Use sets for this BB
52 BBLiveVar(const BasicBlock *BB, unsigned POID);
53 ~BBLiveVar() {} // make dtor private
55 static BBLiveVar *CreateOnBB(const BasicBlock *BB, unsigned POID);
56 static BBLiveVar *GetFromBB(const BasicBlock *BB);
57 static void RemoveFromBB(const BasicBlock *BB);
59 inline bool isInSetChanged() const { return InSetChanged; }
60 inline bool isOutSetChanged() const { return OutSetChanged; }
62 inline unsigned getPOId() const { return POID; }
64 bool applyTransferFunc(); // calcultes the In in terms of Out
66 // calculates Out set using In sets of the predecessors
69 inline const ValueSet &getOutSet() const { return OutSet; }
70 inline const ValueSet &getInSet() const { return InSet; }
72 void printAllSets() const; // for printing Def/In/Out sets
73 void printInOutSets() const; // for printing In/Out sets