@@ -96,6 +96,19 @@ operator<<(llvm::raw_ostream &OS, ByConstRef<ConstantEdgeFunction<L>> Id) {
9696 return OS;
9797}
9898
99+ template <typename L>
100+ requires (is_std_hashable_v<typename NonTopBotValue<L>::type> ||
101+ is_llvm_hashable_v<typename NonTopBotValue<L>::type>)
102+ [[nodiscard]] auto hash_value (const ConstantEdgeFunction<L> &CEF) noexcept {
103+ using value_type = typename ConstantEdgeFunction<L>::value_type;
104+ if constexpr (is_std_hashable_v<value_type>) {
105+ return std::hash<value_type>{}(CEF.Value );
106+ } else {
107+ using llvm::hash_value;
108+ return hash_value (CEF.Value );
109+ }
110+ }
111+
99112template <typename L> struct AllBottom final {
100113 using l_t = L;
101114 using JLattice = JoinLatticeTraits<L>;
@@ -173,7 +186,7 @@ template <typename L> struct AllTop final {
173186 [[nodiscard]] static EdgeFunction<l_t >
174187 compose (EdgeFunctionRef<AllTop> This,
175188 const EdgeFunction<l_t > &SecondFunction) {
176- return llvm::isa<EdgeIdentity< l_t >>( SecondFunction) ? This : SecondFunction ;
189+ return SecondFunction. isConstant ( ) ? SecondFunction : This ;
177190 }
178191
179192 [[nodiscard]] static EdgeFunction<l_t >
@@ -211,13 +224,16 @@ defaultComposeOrNull(const EdgeFunction<L> &This,
211224 if (llvm::isa<EdgeIdentity<L>>(SecondFunction)) {
212225 return This;
213226 }
214- if (SecondFunction.isConstant () || llvm::isa<AllTop<L>>(This) ||
215- llvm::isa<EdgeIdentity<L>>(This)) {
227+ if (SecondFunction.isConstant () || llvm::isa<EdgeIdentity<L>>(This)) {
216228 return SecondFunction;
217229 }
218- if (llvm::isa<AllBottom <L>>(This)) {
230+ if (llvm::isa<AllTop <L>>(This)) {
219231 return This;
220232 }
233+ if (auto BotEF = This.template asRef <AllBottom<L>>()) {
234+ return AllBottom<L>::compose (*BotEF, SecondFunction);
235+ }
236+
221237 return nullptr ;
222238}
223239
@@ -275,6 +291,11 @@ template <typename L> struct EdgeFunctionComposer {
275291
276292static_assert (HasDepth<EdgeFunctionComposer<int >>);
277293
294+ template <typename L>
295+ auto hash_value (const EdgeFunctionComposer<L> &EFC) noexcept {
296+ return llvm::hash_combine (EFC.First , EFC.Second );
297+ }
298+
278299template <typename L, uint8_t N> struct JoinEdgeFunction {
279300 using l_t = L;
280301 using JLattice = JoinLatticeTraits<L>;
@@ -471,12 +492,10 @@ ConstantEdgeFunction<L>::compose(EdgeFunctionRef<ConcreteEF> This,
471492
472493 if constexpr (AreEqualityComparable<decltype (JLattice::top ()), L>) {
473494 if (JLattice::top () == ConstVal) {
474- // / TODO: Can this ever happen?
475495 return AllTop<L>{};
476496 }
477497 } else {
478498 if (L (JLattice::top ()) == ConstVal) {
479- // / TODO: Can this ever happen?
480499 return AllTop<L>{};
481500 }
482501 }
@@ -505,7 +524,7 @@ ConstantEdgeFunction<L>::join(EdgeFunctionRef<ConcreteEF> This,
505524 return OtherFunction.joinWith (This);
506525 }
507526
508- auto OtherVal = OtherFunction.computeTarget (JLattice::top ());
527+ auto OtherVal = OtherFunction.computeTarget (JLattice::bottom ());
509528 auto JoinedVal = JLattice::join (This->Value , OtherVal);
510529
511530 if constexpr (AreEqualityComparable<decltype (JLattice::bottom ()), l_t >) {
0 commit comments