Author: hans Date: Tue Jan 16 04:06:38 2018 New Revision: 322545 URL: http://llvm.org/viewvc/llvm-project?rev=322545&view=rev Log: 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 ------------------------------------------------------------------------ Added: llvm/branches/release_60/test/ThinLTO/X86/Inputs/dicompositetype-unique2.ll - copied unchanged from r322103, llvm/trunk/test/ThinLTO/X86/Inputs/dicompositetype-unique2.ll llvm/branches/release_60/test/ThinLTO/X86/dicompositetype-unique2.ll - copied unchanged from r322103, llvm/trunk/test/ThinLTO/X86/dicompositetype-unique2.ll Modified: llvm/branches/release_60/ (props changed) llvm/branches/release_60/lib/Linker/IRMover.cpp Propchange: llvm/branches/release_60/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Tue Jan 16 04:06:38 2018 @@ -1,3 +1,3 @@ /llvm/branches/Apple/Pertwee:110850,110961 /llvm/branches/type-system-rewrite:133420-134817 -/llvm/trunk:155241 +/llvm/trunk:155241,322103 Modified: llvm/branches/release_60/lib/Linker/IRMover.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_60/lib/Linker/IRMover.cpp?rev=322545&r1=322544&r2=322545&view=diff ============================================================================== --- llvm/branches/release_60/lib/Linker/IRMover.cpp (original) +++ llvm/branches/release_60/lib/Linker/IRMover.cpp Tue Jan 16 04:06:38 2018 @@ -954,7 +954,12 @@ Expected<Constant *> IRLinker::linkGloba 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) { _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits