-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmapping-to-a-source-type.patch
37 lines (34 loc) · 1.46 KB
/
mapping-to-a-source-type.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
--- lib/Linker/IRMover.cpp 2021-02-21 12:57:44.000000000 -0500
+++ lib/Linker/IRMover.cpp 2021-02-21 13:07:05.000000000 -0500
@@ -235,18 +235,27 @@
// 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");
+ if (Pair.first != Ty && Pair.second == Ty)
+ STy->getContext().diagnose(LinkDiagnosticInfo(DS_Warning, "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