[llvm] Introduce CounterExpressionBuilder::subst(C, Map) (PR #112698)
NAKAMURA Takumi via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 8 22:17:57 PST 2025
================
@@ -135,6 +135,31 @@ Counter CounterExpressionBuilder::subtract(Counter LHS, Counter RHS,
return Simplify ? simplify(Cnt) : Cnt;
}
+Counter CounterExpressionBuilder::subst(Counter C, const SubstMap &Map) {
+ // Replace C with the value found in Map even if C is Expression.
+ if (auto I = Map.find(C); I != Map.end())
+ return I->second;
+
+ if (!C.isExpression())
+ return C;
+
+ auto CE = Expressions[C.getExpressionID()];
+ auto NewLHS = subst(CE.LHS, Map);
+ auto NewRHS = subst(CE.RHS, Map);
+
+ // Reconstruct Expression with induced subexpressions.
+ switch (CE.Kind) {
----------------
chapuni wrote:
This `switch` should catch them since this doesn't have `default:`.
https://github.com/llvm/llvm-project/pull/112698
More information about the llvm-commits
mailing list