summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Linker
diff options
context:
space:
mode:
authorHans Wennborg <hans@hanshq.net>2016-11-18 17:33:05 +0000
committerHans Wennborg <hans@hanshq.net>2016-11-18 17:33:05 +0000
commitaeacdc258b2ca3579037925c5a1630ed4df2de35 (patch)
treeccfb02423d3e9ca9b90c1f9033950c6d2fcab683 /llvm/lib/Linker
parentc3115285164b7c3762be12c2925d7ec76106e6f6 (diff)
downloadbcm5719-llvm-aeacdc258b2ca3579037925c5a1630ed4df2de35.tar.gz
bcm5719-llvm-aeacdc258b2ca3579037925c5a1630ed4df2de35.zip
IRMover: Avoid accidentally mapping types from the destination module (PR30799)
During Module linking, it's possible for SrcM->getIdentifiedStructTypes(); to return types that are actually defined in the destination module (DstM). Depending on how the bitcode file was read, getIdentifiedStructTypes() might do a walk over all values, including metadata nodes, looking for types. In my case, a debug info metadata node was shared between the two modules, and it referred to a type defined in the destination module (see test case). Differential Revision: https://reviews.llvm.org/D26212 llvm-svn: 287353
Diffstat (limited to 'llvm/lib/Linker')
-rw-r--r--llvm/lib/Linker/IRMover.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/llvm/lib/Linker/IRMover.cpp b/llvm/lib/Linker/IRMover.cpp
index 18389143124..4866ed2433d 100644
--- a/llvm/lib/Linker/IRMover.cpp
+++ b/llvm/lib/Linker/IRMover.cpp
@@ -701,6 +701,14 @@ void IRLinker::computeTypeMapping() {
if (!ST->hasName())
continue;
+ if (TypeMap.DstStructTypesSet.hasType(ST)) {
+ // This is actually a type from the destination module.
+ // getIdentifiedStructTypes() can have found it by walking debug info
+ // metadata nodes, some of which get linked by name when ODR Type Uniquing
+ // is enabled on the Context, from the source to the destination module.
+ continue;
+ }
+
// Check to see if there is a dot in the name followed by a digit.
size_t DotPos = ST->getName().rfind('.');
if (DotPos == 0 || DotPos == StringRef::npos ||
OpenPOWER on IntegriCloud