[NFC] rename MD_unique_id to MD_guid for consistency#209880
Merged
mtrofin merged 1 commit intoJul 15, 2026
Merged
Conversation
mtrofin
marked this pull request as ready for review
July 15, 2026 20:24
|
@llvm/pr-subscribers-llvm-ir @llvm/pr-subscribers-lto Author: Mircea Trofin (mtrofin) ChangesFull diff: https://github.com/llvm/llvm-project/pull/209880.diff 7 Files Affected:
diff --git a/llvm/include/llvm/IR/FixedMetadataKinds.def b/llvm/include/llvm/IR/FixedMetadataKinds.def
index cb6ebfb5c0fb5..d10d16075fecb 100644
--- a/llvm/include/llvm/IR/FixedMetadataKinds.def
+++ b/llvm/include/llvm/IR/FixedMetadataKinds.def
@@ -62,7 +62,7 @@ LLVM_FIXED_MD_KIND(MD_nofpclass, "nofpclass", 47)
LLVM_FIXED_MD_KIND(MD_call_target, "call_target", 48)
LLVM_FIXED_MD_KIND(MD_inline_history, "inline_history", 49)
LLVM_FIXED_MD_KIND(MD_elf_section_properties, "elf_section_properties", 50)
-LLVM_FIXED_MD_KIND(MD_unique_id, "guid", 51)
+LLVM_FIXED_MD_KIND(MD_guid, "guid", 51)
LLVM_FIXED_MD_KIND(MD_mem_cache_hint, "mem.cache_hint", 52)
LLVM_FIXED_MD_KIND(MD_block_uniformity_profile, "block.uniformity.profile", 53)
LLVM_FIXED_MD_KIND(MD_callgraph, "callgraph", 54)
diff --git a/llvm/lib/IR/Globals.cpp b/llvm/lib/IR/Globals.cpp
index 31d6d9434dd60..3428f662e9120 100644
--- a/llvm/lib/IR/Globals.cpp
+++ b/llvm/lib/IR/Globals.cpp
@@ -88,7 +88,7 @@ void GlobalValue::assignGUID() {
const GUID G =
GlobalValue::getGUIDAssumingExternalLinkage(getGlobalIdentifier());
setMetadata(
- LLVMContext::MD_unique_id,
+ LLVMContext::MD_guid,
MDNode::get(getContext(), {ConstantAsMetadata::get(ConstantInt::get(
Type::getInt64Ty(getContext()), G))}));
}
@@ -96,7 +96,7 @@ void GlobalValue::assignGUID() {
void GlobalValue::reassignGUID() {
if (!getGUIDMetadata())
return;
- eraseMetadata(LLVMContext::MD_unique_id);
+ eraseMetadata(LLVMContext::MD_guid);
assignGUID();
}
@@ -139,7 +139,7 @@ std::optional<GlobalValue::GUID> GlobalValue::getGUIDIfAssigned() const {
MDNode *GlobalValue::getGUIDMetadata() const {
if (auto *GO = dyn_cast<GlobalObject>(this))
- return GO->getMetadata(LLVMContext::MD_unique_id);
+ return GO->getMetadata(LLVMContext::MD_guid);
return nullptr;
}
@@ -472,7 +472,7 @@ bool GlobalObject::hasMetadataOtherThanDebugLocAndGuid() const {
SmallVector<std::pair<unsigned, MDNode *>, 4> MDs;
getAllMetadata(MDs);
for (const auto &V : MDs)
- if (V.first != LLVMContext::MD_dbg && V.first != LLVMContext::MD_unique_id)
+ if (V.first != LLVMContext::MD_dbg && V.first != LLVMContext::MD_guid)
return true;
return false;
}
diff --git a/llvm/lib/Transforms/IPO/FunctionImport.cpp b/llvm/lib/Transforms/IPO/FunctionImport.cpp
index 032bdfb763e0a..88f322fae04b9 100644
--- a/llvm/lib/Transforms/IPO/FunctionImport.cpp
+++ b/llvm/lib/Transforms/IPO/FunctionImport.cpp
@@ -1671,20 +1671,20 @@ bool llvm::convertToDeclaration(GlobalValue &GV) {
<< "\n");
MDNode *UniqueID = nullptr;
if (auto *GO = dyn_cast<GlobalObject>(&GV))
- UniqueID = GO->getMetadata(LLVMContext::MD_unique_id);
+ UniqueID = GO->getMetadata(LLVMContext::MD_guid);
if (Function *F = dyn_cast<Function>(&GV)) {
F->deleteBody();
F->clearMetadata();
if (UniqueID)
- F->setMetadata(LLVMContext::MD_unique_id, UniqueID);
+ F->setMetadata(LLVMContext::MD_guid, UniqueID);
F->setComdat(nullptr);
} else if (GlobalVariable *V = dyn_cast<GlobalVariable>(&GV)) {
V->setInitializer(nullptr);
V->setLinkage(GlobalValue::ExternalLinkage);
V->clearMetadata();
if (UniqueID)
- V->setMetadata(LLVMContext::MD_unique_id, UniqueID);
+ V->setMetadata(LLVMContext::MD_guid, UniqueID);
V->setComdat(nullptr);
} else {
GlobalValue *NewGV;
diff --git a/llvm/lib/Transforms/IPO/LowerTypeTests.cpp b/llvm/lib/Transforms/IPO/LowerTypeTests.cpp
index e25451cd1f53d..c293c4284c2e9 100644
--- a/llvm/lib/Transforms/IPO/LowerTypeTests.cpp
+++ b/llvm/lib/Transforms/IPO/LowerTypeTests.cpp
@@ -2274,7 +2274,7 @@ bool LowerTypeTestsModule::lower() {
GlobalVariable::ExternalLinkage,
M.getDataLayout().getProgramAddressSpace(), FunctionName, &M);
F->setMetadata(
- LLVMContext::MD_unique_id,
+ LLVMContext::MD_guid,
MDTuple::get(M.getContext(), {FuncMD->getOperand(2).get()}));
}
// If the function is available_externally, remove its definition so
@@ -2284,12 +2284,12 @@ bool LowerTypeTestsModule::lower() {
// following the code path below to replace the type metadata.
if (F->hasAvailableExternallyLinkage()) {
// Maintain !guid metadata.
- auto *OrigGUIDMD = F->getMetadata(LLVMContext::MD_unique_id);
+ auto *OrigGUIDMD = F->getMetadata(LLVMContext::MD_guid);
F->setLinkage(GlobalValue::ExternalLinkage);
F->deleteBody();
F->setComdat(nullptr);
F->clearMetadata();
- F->setMetadata(LLVMContext::MD_unique_id, OrigGUIDMD);
+ F->setMetadata(LLVMContext::MD_guid, OrigGUIDMD);
}
// Update the linkage for extern_weak declarations when a definition
diff --git a/llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp b/llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp
index 3c5781fa16651..d9574c08aced8 100644
--- a/llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp
+++ b/llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp
@@ -216,8 +216,8 @@ void simplifyExternals(Module &M) {
AttributeList::FunctionIndex,
F.getAttributes().getFnAttrs()));
NewF->takeName(&F);
- NewF->setMetadata(LLVMContext::MD_unique_id,
- F.getMetadata(LLVMContext::MD_unique_id));
+ NewF->setMetadata(LLVMContext::MD_guid,
+ F.getMetadata(LLVMContext::MD_guid));
F.replaceAllUsesWith(NewF);
F.eraseFromParent();
}
diff --git a/llvm/lib/Transforms/Utils/AssignGUID.cpp b/llvm/lib/Transforms/Utils/AssignGUID.cpp
index b05504ad7181a..ef43392d63d0b 100644
--- a/llvm/lib/Transforms/Utils/AssignGUID.cpp
+++ b/llvm/lib/Transforms/Utils/AssignGUID.cpp
@@ -36,6 +36,6 @@ void AssignGUIDPass::assignGUIDForMergedGV(GlobalVariable &GV) {
// that metadata from GV first, but we may want to remember those later, if
// we had a motivation for that. In that case, we need some other metadata
// to maintain that association.
- GV.eraseMetadata(LLVMContext::MD_unique_id);
+ GV.eraseMetadata(LLVMContext::MD_guid);
GV.assignGUID();
}
diff --git a/llvm/lib/Transforms/Utils/CloneModule.cpp b/llvm/lib/Transforms/Utils/CloneModule.cpp
index 618d66a8d2685..66f42eb15534e 100644
--- a/llvm/lib/Transforms/Utils/CloneModule.cpp
+++ b/llvm/lib/Transforms/Utils/CloneModule.cpp
@@ -155,8 +155,8 @@ std::unique_ptr<Module> llvm::CloneModule(
}
if (!ShouldCloneDefinition(&I)) {
- if (auto *MD = I.getMetadata(LLVMContext::MD_unique_id))
- F->setMetadata(LLVMContext::MD_unique_id, MapMetadata(MD, VMap));
+ if (auto *MD = I.getMetadata(LLVMContext::MD_guid))
+ F->setMetadata(LLVMContext::MD_guid, MapMetadata(MD, VMap));
// Skip after setting the correct linkage for an external reference.
F->setLinkage(GlobalValue::ExternalLinkage);
// Personality function is not valid on a declaration.
|
|
@llvm/pr-subscribers-llvm-transforms Author: Mircea Trofin (mtrofin) ChangesFull diff: https://github.com/llvm/llvm-project/pull/209880.diff 7 Files Affected:
diff --git a/llvm/include/llvm/IR/FixedMetadataKinds.def b/llvm/include/llvm/IR/FixedMetadataKinds.def
index cb6ebfb5c0fb5..d10d16075fecb 100644
--- a/llvm/include/llvm/IR/FixedMetadataKinds.def
+++ b/llvm/include/llvm/IR/FixedMetadataKinds.def
@@ -62,7 +62,7 @@ LLVM_FIXED_MD_KIND(MD_nofpclass, "nofpclass", 47)
LLVM_FIXED_MD_KIND(MD_call_target, "call_target", 48)
LLVM_FIXED_MD_KIND(MD_inline_history, "inline_history", 49)
LLVM_FIXED_MD_KIND(MD_elf_section_properties, "elf_section_properties", 50)
-LLVM_FIXED_MD_KIND(MD_unique_id, "guid", 51)
+LLVM_FIXED_MD_KIND(MD_guid, "guid", 51)
LLVM_FIXED_MD_KIND(MD_mem_cache_hint, "mem.cache_hint", 52)
LLVM_FIXED_MD_KIND(MD_block_uniformity_profile, "block.uniformity.profile", 53)
LLVM_FIXED_MD_KIND(MD_callgraph, "callgraph", 54)
diff --git a/llvm/lib/IR/Globals.cpp b/llvm/lib/IR/Globals.cpp
index 31d6d9434dd60..3428f662e9120 100644
--- a/llvm/lib/IR/Globals.cpp
+++ b/llvm/lib/IR/Globals.cpp
@@ -88,7 +88,7 @@ void GlobalValue::assignGUID() {
const GUID G =
GlobalValue::getGUIDAssumingExternalLinkage(getGlobalIdentifier());
setMetadata(
- LLVMContext::MD_unique_id,
+ LLVMContext::MD_guid,
MDNode::get(getContext(), {ConstantAsMetadata::get(ConstantInt::get(
Type::getInt64Ty(getContext()), G))}));
}
@@ -96,7 +96,7 @@ void GlobalValue::assignGUID() {
void GlobalValue::reassignGUID() {
if (!getGUIDMetadata())
return;
- eraseMetadata(LLVMContext::MD_unique_id);
+ eraseMetadata(LLVMContext::MD_guid);
assignGUID();
}
@@ -139,7 +139,7 @@ std::optional<GlobalValue::GUID> GlobalValue::getGUIDIfAssigned() const {
MDNode *GlobalValue::getGUIDMetadata() const {
if (auto *GO = dyn_cast<GlobalObject>(this))
- return GO->getMetadata(LLVMContext::MD_unique_id);
+ return GO->getMetadata(LLVMContext::MD_guid);
return nullptr;
}
@@ -472,7 +472,7 @@ bool GlobalObject::hasMetadataOtherThanDebugLocAndGuid() const {
SmallVector<std::pair<unsigned, MDNode *>, 4> MDs;
getAllMetadata(MDs);
for (const auto &V : MDs)
- if (V.first != LLVMContext::MD_dbg && V.first != LLVMContext::MD_unique_id)
+ if (V.first != LLVMContext::MD_dbg && V.first != LLVMContext::MD_guid)
return true;
return false;
}
diff --git a/llvm/lib/Transforms/IPO/FunctionImport.cpp b/llvm/lib/Transforms/IPO/FunctionImport.cpp
index 032bdfb763e0a..88f322fae04b9 100644
--- a/llvm/lib/Transforms/IPO/FunctionImport.cpp
+++ b/llvm/lib/Transforms/IPO/FunctionImport.cpp
@@ -1671,20 +1671,20 @@ bool llvm::convertToDeclaration(GlobalValue &GV) {
<< "\n");
MDNode *UniqueID = nullptr;
if (auto *GO = dyn_cast<GlobalObject>(&GV))
- UniqueID = GO->getMetadata(LLVMContext::MD_unique_id);
+ UniqueID = GO->getMetadata(LLVMContext::MD_guid);
if (Function *F = dyn_cast<Function>(&GV)) {
F->deleteBody();
F->clearMetadata();
if (UniqueID)
- F->setMetadata(LLVMContext::MD_unique_id, UniqueID);
+ F->setMetadata(LLVMContext::MD_guid, UniqueID);
F->setComdat(nullptr);
} else if (GlobalVariable *V = dyn_cast<GlobalVariable>(&GV)) {
V->setInitializer(nullptr);
V->setLinkage(GlobalValue::ExternalLinkage);
V->clearMetadata();
if (UniqueID)
- V->setMetadata(LLVMContext::MD_unique_id, UniqueID);
+ V->setMetadata(LLVMContext::MD_guid, UniqueID);
V->setComdat(nullptr);
} else {
GlobalValue *NewGV;
diff --git a/llvm/lib/Transforms/IPO/LowerTypeTests.cpp b/llvm/lib/Transforms/IPO/LowerTypeTests.cpp
index e25451cd1f53d..c293c4284c2e9 100644
--- a/llvm/lib/Transforms/IPO/LowerTypeTests.cpp
+++ b/llvm/lib/Transforms/IPO/LowerTypeTests.cpp
@@ -2274,7 +2274,7 @@ bool LowerTypeTestsModule::lower() {
GlobalVariable::ExternalLinkage,
M.getDataLayout().getProgramAddressSpace(), FunctionName, &M);
F->setMetadata(
- LLVMContext::MD_unique_id,
+ LLVMContext::MD_guid,
MDTuple::get(M.getContext(), {FuncMD->getOperand(2).get()}));
}
// If the function is available_externally, remove its definition so
@@ -2284,12 +2284,12 @@ bool LowerTypeTestsModule::lower() {
// following the code path below to replace the type metadata.
if (F->hasAvailableExternallyLinkage()) {
// Maintain !guid metadata.
- auto *OrigGUIDMD = F->getMetadata(LLVMContext::MD_unique_id);
+ auto *OrigGUIDMD = F->getMetadata(LLVMContext::MD_guid);
F->setLinkage(GlobalValue::ExternalLinkage);
F->deleteBody();
F->setComdat(nullptr);
F->clearMetadata();
- F->setMetadata(LLVMContext::MD_unique_id, OrigGUIDMD);
+ F->setMetadata(LLVMContext::MD_guid, OrigGUIDMD);
}
// Update the linkage for extern_weak declarations when a definition
diff --git a/llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp b/llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp
index 3c5781fa16651..d9574c08aced8 100644
--- a/llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp
+++ b/llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp
@@ -216,8 +216,8 @@ void simplifyExternals(Module &M) {
AttributeList::FunctionIndex,
F.getAttributes().getFnAttrs()));
NewF->takeName(&F);
- NewF->setMetadata(LLVMContext::MD_unique_id,
- F.getMetadata(LLVMContext::MD_unique_id));
+ NewF->setMetadata(LLVMContext::MD_guid,
+ F.getMetadata(LLVMContext::MD_guid));
F.replaceAllUsesWith(NewF);
F.eraseFromParent();
}
diff --git a/llvm/lib/Transforms/Utils/AssignGUID.cpp b/llvm/lib/Transforms/Utils/AssignGUID.cpp
index b05504ad7181a..ef43392d63d0b 100644
--- a/llvm/lib/Transforms/Utils/AssignGUID.cpp
+++ b/llvm/lib/Transforms/Utils/AssignGUID.cpp
@@ -36,6 +36,6 @@ void AssignGUIDPass::assignGUIDForMergedGV(GlobalVariable &GV) {
// that metadata from GV first, but we may want to remember those later, if
// we had a motivation for that. In that case, we need some other metadata
// to maintain that association.
- GV.eraseMetadata(LLVMContext::MD_unique_id);
+ GV.eraseMetadata(LLVMContext::MD_guid);
GV.assignGUID();
}
diff --git a/llvm/lib/Transforms/Utils/CloneModule.cpp b/llvm/lib/Transforms/Utils/CloneModule.cpp
index 618d66a8d2685..66f42eb15534e 100644
--- a/llvm/lib/Transforms/Utils/CloneModule.cpp
+++ b/llvm/lib/Transforms/Utils/CloneModule.cpp
@@ -155,8 +155,8 @@ std::unique_ptr<Module> llvm::CloneModule(
}
if (!ShouldCloneDefinition(&I)) {
- if (auto *MD = I.getMetadata(LLVMContext::MD_unique_id))
- F->setMetadata(LLVMContext::MD_unique_id, MapMetadata(MD, VMap));
+ if (auto *MD = I.getMetadata(LLVMContext::MD_guid))
+ F->setMetadata(LLVMContext::MD_guid, MapMetadata(MD, VMap));
// Skip after setting the correct linkage for an external reference.
F->setLinkage(GlobalValue::ExternalLinkage);
// Personality function is not valid on a declaration.
|
teresajohnson
approved these changes
Jul 15, 2026
mtrofin
enabled auto-merge (squash)
July 15, 2026 20:43
mtrofin
deleted the
users/mtrofin/07-15-_nfc_rename_md_unique_id_to_md_guid_for_consistency
branch
July 15, 2026 21:10
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/226/builds/13160 Here is the relevant piece of the build log for the reference |
pedroMVicente
pushed a commit
to pedroMVicente/llvm-project
that referenced
this pull request
Jul 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

No description provided.