diff --git a/llvm/lib/IR/Metadata.cpp b/llvm/lib/IR/Metadata.cpp index e2a89e2b6300b..c153ffb71a73b 100644 --- a/llvm/lib/IR/Metadata.cpp +++ b/llvm/lib/IR/Metadata.cpp @@ -1551,8 +1551,10 @@ void Instruction::addAnnotationMetadata(SmallVector Annotations) { if (Existing) { auto *Tuple = cast(Existing); for (auto &N : Tuple->operands()) { - if (isa(N.get())) + if (isa(N.get())) { + Names.push_back(N); continue; + } auto *MDAnnotationTuple = cast(N); if (any_of(MDAnnotationTuple->operands(), [&AnnotationsSet](auto &Op) { return AnnotationsSet.contains(cast(Op)->getString());