diff options
Diffstat (limited to 'llvm/lib/Linker/IRMover.cpp')
| -rw-r--r-- | llvm/lib/Linker/IRMover.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/llvm/lib/Linker/IRMover.cpp b/llvm/lib/Linker/IRMover.cpp index 8e89724d443..aee89af88a6 100644 --- a/llvm/lib/Linker/IRMover.cpp +++ b/llvm/lib/Linker/IRMover.cpp @@ -758,8 +758,18 @@ void IRLinker::computeTypeMapping() { } for (GlobalValue &SGV : *SrcM) - if (GlobalValue *DGV = getLinkedToGlobal(&SGV)) + if (GlobalValue *DGV = getLinkedToGlobal(&SGV)) { + if (DGV->getType() == SGV.getType()) { + // If the types of DGV and SGV are the same, it means that DGV is from + // the source module and got added to DstM from a shared metadata. We + // shouldn't map this type to itself in case the type's components get + // remapped to a new type from DstM (for instance, during the loop over + // SrcM->getIdentifiedStructTypes() below). + continue; + } + TypeMap.addTypeMapping(DGV->getType(), SGV.getType()); + } for (GlobalValue &SGV : SrcM->aliases()) if (GlobalValue *DGV = getLinkedToGlobal(&SGV)) |

