[clang] [llvm] [IR] Introduce an appendTags() idiom to set MMRA metadata [NFC] (PR #199621)
Sameer Sahasrabuddhe via cfe-commits
cfe-commits at lists.llvm.org
Tue May 26 19:57:23 PDT 2026
================
@@ -98,6 +98,21 @@ MDNode *MMRAMetadata::combine(LLVMContext &Ctx, const MMRAMetadata &A,
return MDTuple::get(Ctx, Result);
}
+void MMRAMetadata::appendTags(Instruction &I, ArrayRef<TagT> Tags) {
+ if (Tags.empty())
+ return;
+ SmallVector<MMRAMetadata::TagT> MMRAs(Tags);
+ LLVMContext &Ctx = I.getContext();
+ if (MDNode *Existing = I.getMetadata(LLVMContext::MD_mmra)) {
+ // Merge with existing MMRA tags.
+ MMRAMetadata Parsed(Existing);
+ MMRAs.append(Parsed.begin(), Parsed.end());
+ }
+ llvm::sort(MMRAs);
+ MMRAs.erase(llvm::unique(MMRAs), MMRAs.end());
----------------
ssahasra wrote:
I grepped for such uses ... there was exactly one instance were "llvm::" prefix was not used. That aligns with my own built-in habit of being explicit about the llvm:: namespace for things that "feel like they should be in std::"
https://github.com/llvm/llvm-project/pull/199621
More information about the cfe-commits
mailing list