[llvm] Introduce CounterExpressionBuilder::replace(C, Map) (PR #112698)

NAKAMURA Takumi via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 18 02:11:00 PDT 2024


================
@@ -135,6 +135,38 @@ Counter CounterExpressionBuilder::subtract(Counter LHS, Counter RHS,
   return Simplify ? simplify(Cnt) : Cnt;
 }
 
+Counter CounterExpressionBuilder::replace(Counter C, const ReplaceMap &Map) {
+  auto I = Map.find(C);
+
+  // Replace C with the Map even if C is Expression.
+  if (I != Map.end())
+    return I->second;
+
+  // Traverse only Expression.
----------------
chapuni wrote:

Because others (Zero or CounterRef) are not traversable :)

Is this line too naive to you? I could eliminate.

https://github.com/llvm/llvm-project/pull/112698


More information about the llvm-commits mailing list