diff options
| author | Pirama Arumuga Nainar <pirama@google.com> | 2019-09-11 18:35:49 +0000 |
|---|---|---|
| committer | Pirama Arumuga Nainar <pirama@google.com> | 2019-09-11 18:35:49 +0000 |
| commit | 8b46544641ef49e20621a3ac8e14fd4c95338522 (patch) | |
| tree | e490e4958daade820c9e0f4781a3c453f7d81736 /llvm/lib | |
| parent | abcc2a879c95d2ed262f1b344a069747c2138778 (diff) | |
| download | bcm5719-llvm-8b46544641ef49e20621a3ac8e14fd4c95338522.tar.gz bcm5719-llvm-8b46544641ef49e20621a3ac8e14fd4c95338522.zip | |
[IRMover] Don't map globals if their types are the same
Summary:
During IR Linking, if the types of two globals in destination and source
modules are the same, it can only be because the global in the
destination module is originally from the source module and got added to
the destination module 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 the destination (for instance, during the
loop over SrcM->getIdentifiedStructTypes() further below in
IRLinker::computeTypeMapping()).
Fixes PR40312.
Reviewers: tejohnson, pcc, srhines
Subscribers: mehdi_amini, hiraditya, steven_wu, dexonsmith, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D66814
llvm-svn: 371643
Diffstat (limited to 'llvm/lib')
| -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)) |

