[llvm] [IR] Name unnamed values after each pass (PR #221519)

Arthur Eubanks via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 6 20:04:01 PDT 2026


================
@@ -14,25 +14,43 @@
 //===----------------------------------------------------------------------===//
 
 #include "llvm/Transforms/Utils/InstructionNamer.h"
+#include "llvm/ADT/Twine.h"
+#include "llvm/Analysis/LazyCallGraph.h"
+#include "llvm/Analysis/LoopInfo.h"
 #include "llvm/IR/Function.h"
+#include "llvm/IR/Module.h"
+#include "llvm/IR/PassInstrumentation.h"
 #include "llvm/IR/PassManager.h"
 #include "llvm/IR/Type.h"
+#include <atomic>
+#include <cstdint>
+#include <memory>
+#include <string>
 
 using namespace llvm;
 
-static void nameInstructions(Function &F) {
+static void nameInstructions(Function &F,
+                             std::atomic<uint64_t> *NextID = nullptr) {
+  auto getName = [NextID](StringRef Prefix) -> std::string {
+    if (!NextID)
+      return Prefix.str();
+    return (Twine(Prefix) + "." +
+            Twine(NextID->fetch_add(1, std::memory_order_relaxed)))
----------------
aeubanks wrote:

I guess theoretically in the future maybe we could have parallel threaded runs using the same StandardInstrumentations... but that's a very distant future

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


More information about the llvm-commits mailing list