diff options
author | Vlad Tsyrklevich <vlad@tsyrklevich.net> | 2018-06-20 16:50:56 +0000 |
---|---|---|
committer | Vlad Tsyrklevich <vlad@tsyrklevich.net> | 2018-06-20 16:50:56 +0000 |
commit | 34b91122166186669bd52abaf04c1b294055b8a7 (patch) | |
tree | a08b16d0607fb1879dd3df49c192346ab07a7cd6 /llvm/lib/Linker | |
parent | 6fa24b0b7fb755114ca3ac50c6617e917222a893 (diff) | |
download | bcm5719-llvm-34b91122166186669bd52abaf04c1b294055b8a7.tar.gz bcm5719-llvm-34b91122166186669bd52abaf04c1b294055b8a7.zip |
IRMover: Account for matching types present across modules
Summary:
Due to uniqueing of DICompositeTypes, it's possible for a type from one
module to be loaded into another earlier module without being renamed.
Then when the defining module is being IRMoved, the type can be used as
a Mapping destination before being loaded, such that when it's requested
using TypeMapTy::get() it will fail with an assertion that the type is a
source type when it's actually a type in both the source and
destination modules. Correctly handle that case by allowing a non-opaque
non-literal struct type be present in both modules.
Fix for PR37684.
Reviewers: pcc, tejohnson
Reviewed By: pcc, tejohnson
Subscribers: tobiasvk, mehdi_amini, steven_wu, llvm-commits, kcc
Differential Revision: https://reviews.llvm.org/D47898
llvm-svn: 335145
Diffstat (limited to 'llvm/lib/Linker')
-rw-r--r-- | llvm/lib/Linker/IRMover.cpp | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/llvm/lib/Linker/IRMover.cpp b/llvm/lib/Linker/IRMover.cpp index 42081442db7..0416ddd5601 100644 --- a/llvm/lib/Linker/IRMover.cpp +++ b/llvm/lib/Linker/IRMover.cpp @@ -241,18 +241,27 @@ Type *TypeMapTy::get(Type *Ty, SmallPtrSet<StructType *, 8> &Visited) { // These are types that LLVM itself will unique. bool IsUniqued = !isa<StructType>(Ty) || cast<StructType>(Ty)->isLiteral(); -#ifndef NDEBUG if (!IsUniqued) { + StructType *STy = cast<StructType>(Ty); + // This is actually a type from the destination module, this can be reached + // when this type is loaded in another module, added to DstStructTypesSet, + // and then we reach the same type in another module where it has not been + // added to MappedTypes. (PR37684) + if (STy->getContext().isODRUniquingDebugTypes() && !STy->isOpaque() && + DstStructTypesSet.hasType(STy)) + return *Entry = STy; + +#ifndef NDEBUG for (auto &Pair : MappedTypes) { assert(!(Pair.first != Ty && Pair.second == Ty) && "mapping to a source type"); } - } #endif - if (!IsUniqued && !Visited.insert(cast<StructType>(Ty)).second) { - StructType *DTy = StructType::create(Ty->getContext()); - return *Entry = DTy; + if (!Visited.insert(STy).second) { + StructType *DTy = StructType::create(Ty->getContext()); + return *Entry = DTy; + } } // If this is not a recursive type, then just map all of the elements and |