LLVM 24.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
18using namespace llvm;
19
21 for (auto &GV : M.globals()) {
22 if (GV.isDeclaration())
23 continue;
24 GV.assignGUID();
25 }
26 for (auto &F : M.functions()) {
27 if (F.isDeclaration())
28 continue;
29 F.assignGUID();
30 }
31}
32
34 // FIXME: merging adds all the guids of the original GVs. We currently drop
35 // that metadata from GV first, but we may want to remember those later, if
36 // we had a motivation for that. In that case, we need some other metadata
37 // to maintain that association.
38 GV.eraseMetadata(LLVMContext::MD_guid);
39 GV.assignGUID();
40}
#define F(x, y, z)
Definition MD5.cpp:54
static LLVM_ABI void assignGUIDForMergedGV(GlobalVariable &GV)
static LLVM_ABI 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:67
This is an optimization pass for GlobalISel generic memory operations.