[llvm] XCOFF associated metadata (PR #159096)
Wael Yehia via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 30 15:47:57 PDT 2025
================
@@ -766,6 +766,30 @@ void Verifier::visitGlobalValue(const GlobalValue &GV) {
DL.getIntPtrType(GO->getType()),
RangeLikeMetadataKind::AbsoluteSymbol);
}
+
+ if (GO->hasMetadata(LLVMContext::MD_ref)) {
+ SmallVector<MDNode *> MDs;
+ GO->getMetadata(LLVMContext::MD_ref, MDs);
+ for (const MDNode *MD : MDs) {
+ Check(MD->getNumOperands() == 1, "ref metadata must have one operand",
----------------
w2yehia wrote:
> For this metadata it is possible you could have 2 different features that require implicit references to be added. In that case would you have to get the existing array of refs, duplicate and append to it, then create a new metadata node with that array?
yes you cannot mutate an existing node, so you'll have to create a new one, but that's not too much work as we constantly create new IR and throw old one in LLVM, and it will not happen often.
> Or are you suggesting we support both arrays of refs, and multiple individual refs as well?
No, not both because that would complicate the handling on the consumer side.
I'm in favor of supporting only the array of refs (and enforcing one `!ref` MD) just because it's more compact in textual IR (and I cannot think of other benefits).
https://github.com/llvm/llvm-project/pull/159096
More information about the llvm-commits
mailing list