MCPcopy Create free account
hub / github.com/Samsung/UTopia / CVPLatticeVal

Class CVPLatticeVal

lib/indcallsolver/CustomCVPPass.cpp:65–115  ·  view source on GitHub ↗

The lattice value type used by our custom lattice function. It holds the lattice state, and a set of functions.

Source from the content-addressed store, hash-verified

63/// The lattice value type used by our custom lattice function. It holds the
64/// lattice state, and a set of functions.
65class CVPLatticeVal {
66public:
67 /// The states of the lattice values. Only the FunctionSet state is
68 /// interesting. It indicates the set of functions to which an LLVM value may
69 /// refer.
70 enum CVPLatticeStateTy { Undefined, FunctionSet, Overdefined, Untracked };
71
72 /// Comparator for sorting the functions set. We want to keep the order
73 /// deterministic for testing, etc.
74 struct Compare {
75 bool operator()(const Function *LHS, const Function *RHS) const {
76 return LHS->getName() < RHS->getName();
77 }
78 };
79
80 CVPLatticeVal() : LatticeState(Undefined) {}
81 CVPLatticeVal(CVPLatticeStateTy LatticeState) : LatticeState(LatticeState) {}
82 CVPLatticeVal(std::vector<Function *> &&Functions)
83 : LatticeState(FunctionSet), Functions(std::move(Functions)) {
84 assert(std::is_sorted(this->Functions.begin(), this->Functions.end(),
85 Compare()));
86 }
87
88 /// Get a reference to the functions held by this lattice value. The number
89 /// of functions will be zero for states other than FunctionSet.
90 const std::vector<Function *> &getFunctions() const { return Functions; }
91
92 /// Returns true if the lattice value is in the FunctionSet state.
93 bool isFunctionSet() const { return LatticeState == FunctionSet; }
94
95 bool operator==(const CVPLatticeVal &RHS) const {
96 return LatticeState == RHS.LatticeState && Functions == RHS.Functions;
97 }
98
99 bool operator!=(const CVPLatticeVal &RHS) const {
100 return LatticeState != RHS.LatticeState || Functions != RHS.Functions;
101 }
102
103private:
104 /// Holds the state this lattice value is in.
105 CVPLatticeStateTy LatticeState;
106
107 /// Holds functions indicating the possible targets of call sites. This set
108 /// is empty for lattice values in the undefined, overdefined, and untracked
109 /// states. The maximum size of the set is controlled by
110 /// MaxFunctionsPerValue. Since most LLVM values are expected to be in
111 /// uninteresting states (i.e., overdefined), CVPLatticeVal objects should be
112 /// small and efficiently copyable.
113 // FIXME: This could be a TinyPtrVector and/or merge with LatticeState.
114 std::vector<Function *> Functions;
115};
116
117/// The custom lattice function used by the generic sparse propagation solver.
118/// It handles merging lattice values and computing new lattice values for

Callers 3

CVPLatticeFuncMethod · 0.85
MergeValuesMethod · 0.85
computeConstantMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected