LLVM 23.0.0git
AssignGUID.cpp
Go to the documentation of this file.
1//===-- AssignGUID.cpp - Unique identifier assignment pass ------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file provides a pass which assigns GUID (globally unique identifier)
10// metadata to every GlobalValue in the module, according to its current name,
11// linkage, and originating file. It is idempotent -- if GUID metadata is
12// already present, it does nothing.
13//
14//===----------------------------------------------------------------------===//
15
17#include "llvm/Support/Debug.h"
18
19using namespace llvm;
20
22 for (auto &GV : M.globals()) {
23 if (GV.isDeclaration())
24 continue;
25 GV.assignGUID();
26 }
27 for (auto &F : M.functions()) {
28 if (F.isDeclaration())
29 continue;
30 F.assignGUID();
31 }
32}
33
35 // FIXME: merging adds all the guids of the original GVs. We currently drop
36 // that metadata from GV first, but we may want to remember those later, if
37 // we had a motivation for that. In that case, we need some other metadata
38 // to maintain that association.
39 GV.eraseMetadata(LLVMContext::MD_unique_id);
40 GV.assignGUID();
41}
#define F(x, y, z)
Definition MD5.cpp:54
static void assignGUIDForMergedGV(GlobalVariable &GV)
static void runOnModule(Module &M)
LLVM_ABI bool eraseMetadata(unsigned KindID)
Erase all metadata attachments with the given kind.
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:68
This is an optimization pass for GlobalISel generic memory operations.