[PATCH] D152448: [Metadata] Fix `addAnnotationMetadata` when appending a string tuple to an existing MDTuple.

Zain Jaffal via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 8 07:57:04 PDT 2023


zjaffal created this revision.
zjaffal added reviewers: fhahn, paquette, delcypher.
Herald added subscribers: StephenFan, hiraditya.
Herald added a project: All.
zjaffal requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Currently if the MD_Annotation node containd a string node when we add a
string tuple node the string will not be preserved. This change fixes
that issue.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152448

Files:
  llvm/lib/IR/Metadata.cpp


Index: llvm/lib/IR/Metadata.cpp
===================================================================
--- llvm/lib/IR/Metadata.cpp
+++ llvm/lib/IR/Metadata.cpp
@@ -1551,8 +1551,10 @@
   if (Existing) {
     auto *Tuple = cast<MDTuple>(Existing);
     for (auto &N : Tuple->operands()) {
-      if (isa<MDString>(N.get()))
+      if (isa<MDString>(N.get())) {
+        Names.push_back(N);
         continue;
+      }
       auto *MDAnnotationTuple = cast<MDTuple>(N);
       if (any_of(MDAnnotationTuple->operands(), [&AnnotationsSet](auto &Op) {
             return AnnotationsSet.contains(cast<MDString>(Op)->getString());


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D152448.529598.patch
Type: text/x-patch
Size: 622 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230608/87fde61c/attachment.bin>


More information about the llvm-commits mailing list