diff --git a/llvm/lib/Linker/IRMover.cpp b/llvm/lib/Linker/IRMover.cpp --- a/llvm/lib/Linker/IRMover.cpp +++ b/llvm/lib/Linker/IRMover.cpp @@ -324,7 +324,10 @@ if (StructType *OldT = DstStructTypesSet.findNonOpaque(ElementTypes, IsPacked)) { - STy->setName(""); + // We can endup with STy being in the destination module and in this case + // we should not remove the name. Just keep using the OldT == STy. + if (OldT != STy) + STy->setName(""); return *Entry = OldT; }