[llvm] Store GUIDs in metadata (PR #133682)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Tue May 27 02:38:22 PDT 2025
================
@@ -0,0 +1,34 @@
+//===-- AssignGUID.cpp - Unique identifier assignment pass ------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file provides a pass which assigns a a GUID (globally unique identifier)
+// to every GlobalValue in the module, according to its current name, linkage,
+// and originating file.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/Transforms/Utils/AssignGUID.h"
+#include "llvm/Support/Debug.h"
+
+using namespace llvm;
+
+PreservedAnalyses AssignGUIDPass::run(Module &M, ModuleAnalysisManager &AM) {
+ for (auto &GV : M.globals()) {
+ if (GV.isDeclaration())
+ continue;
+ GV.assignGUID();
+ dbgs() << "[Added GUID to GV:] " << GV.getName() << "\n";
----------------
nikic wrote:
This should be inside LLVM_DEBUG.
https://github.com/llvm/llvm-project/pull/133682
More information about the llvm-commits
mailing list