[llvm] [VPlan] Track VPValue names in VPlan. (PR #81411)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Feb 25 09:30:46 PST 2024
================
@@ -1112,6 +1123,26 @@ VPlan *VPlan::duplicate() {
return NewPlan;
}
+void VPlan::setName(const VPValue *V, const Twine &Name) {
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
+ std::string N = Name.str();
+ if (N.empty())
+ return;
+ assert(!VPValue2Name.contains(V));
+ std::string CurrName = N;
+
+ if (UsedNames.contains(N))
+ CurrName = N + ".1";
+ unsigned Cnt = 2;
+ while (UsedNames.contains(CurrName)) {
----------------
ayalz wrote:
This O(n^2) search is tolerable because n is expected to be very small? Can alternatively hold a map between used names and the number of times each name is used, instead of a set. The former will avoid reusing names that were removed.
https://github.com/llvm/llvm-project/pull/81411
More information about the llvm-commits
mailing list