Skip to content

Commit

Permalink
[Metadata] Fix addAnnotationMetadata when appending a string tuple …
Browse files Browse the repository at this point in the history
…to an existing MDTuple.

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.

Reviewed By: fhahn

Differential Revision: https://reviews.llvm.org/D152448
  • Loading branch information
Zain Jaffal committed Jun 9, 2023
1 parent 859b05b commit c45695e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion llvm/lib/IR/Metadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1551,8 +1551,10 @@ void Instruction::addAnnotationMetadata(SmallVector<StringRef> Annotations) {
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());
Expand Down

0 comments on commit c45695e

Please sign in to comment.