diff options
author | Hans Wennborg <hans@hanshq.net> | 2018-01-16 12:06:38 +0000 |
---|---|---|
committer | Hans Wennborg <hans@hanshq.net> | 2018-01-16 12:06:38 +0000 |
commit | 7f2e3d00cf4a72c69111765f87a467cd28026fb9 (patch) | |
tree | 98111b89b9190bff8f787cfd2a9f1b7ad0d74681 /lib | |
parent | ef854ab36638ba5b565f7734d22cbe3a510ae8b6 (diff) |
Merging r322103:
------------------------------------------------------------------------
r322103 | tejohnson | 2018-01-09 10:32:53 -0800 (Tue, 09 Jan 2018) | 25 lines
Fix crash when linking metadata with ODR type uniquing
Summary:
With DebugTypeODRUniquing enabled, during IR linking debug metadata
in the destination module may be reached from the source module.
This means that ConstantAsMetadata nodes (e.g. on DITemplateValueParameter)
may contain a value the destination module. When trying to map such
metadata nodes, we will attempt to map a GV already in the dest module.
linkGlobalValueProto will end up with a source GV that is the same as
the dest GV as well as the new GV. Trying to access the TypeMap for the
source GV type, which is actually a dest GV type, hits an assertion
since it appears that we have mapped into the source module (because the
type is the value not a key into the map).
Detect that we don't need to access the TypeMap in this case, since
there is no need to create a bitcast from the new GV to the source GV
type as they GV are the same.
Fixes PR35722.
Reviewers: mehdi_amini, pcc
Subscribers: probinson, llvm-commits, eraman
Differential Revision: https://reviews.llvm.org/D41624
------------------------------------------------------------------------
git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_60@322545 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Linker/IRMover.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/Linker/IRMover.cpp b/lib/Linker/IRMover.cpp index ee067a912e3..f7170e714b9 100644 --- a/lib/Linker/IRMover.cpp +++ b/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) { |