[llvm] [VPlan] Track VPValue names in VPlan. (PR #81411)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 14 04:59:53 PDT 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)) {
----------------
fhahn wrote:

Yes, the number of clashes should be low.

> The former will avoid reusing names that were removed.
The code at the moment intentionally allows re-using names for values that have been removed.

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


More information about the llvm-commits mailing list