summaryrefslogtreecommitdiffstats
path: root/gnu/llvm/lib/Linker/IRMover.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'gnu/llvm/lib/Linker/IRMover.cpp')
-rw-r--r--gnu/llvm/lib/Linker/IRMover.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/gnu/llvm/lib/Linker/IRMover.cpp b/gnu/llvm/lib/Linker/IRMover.cpp
index ee067a912e3..f7170e714b9 100644
--- a/gnu/llvm/lib/Linker/IRMover.cpp
+++ b/gnu/llvm/lib/Linker/IRMover.cpp
@@ -954,7 +954,12 @@ Expected<Constant *> IRLinker::linkGlobalValueProto(GlobalValue *SGV,
NewGV->setLinkage(GlobalValue::InternalLinkage);
Constant *C = NewGV;
- if (DGV)
+ // Only create a bitcast if necessary. In particular, with
+ // DebugTypeODRUniquing we may reach metadata in the destination module
+ // containing a GV from the source module, in which case SGV will be
+ // the same as DGV and NewGV, and TypeMap.get() will assert since it
+ // assumes it is being invoked on a type in the source module.
+ if (DGV && NewGV != SGV)
C = ConstantExpr::getBitCast(NewGV, TypeMap.get(SGV->getType()));
if (DGV && NewGV != DGV) {