We would set the body of a struct type (therefore making it non-opaque)
but were forgetting to move it to the non-opaque set.
Fixes pr22807.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@231442
91177308-0d34-0410-b5e6-
96231b3b80d8
NonOpaqueStructTypeSet NonOpaqueStructTypes;
void addNonOpaque(StructType *Ty);
+ void switchToNonOpaque(StructType *Ty);
void addOpaque(StructType *Ty);
StructType *findNonOpaque(ArrayRef<Type *> ETypes, bool IsPacked);
bool hasType(StructType *Ty);
Elements[I] = get(SrcSTy->getElementType(I));
DstSTy->setBody(Elements, SrcSTy->isPacked());
+ DstStructTypesSet.switchToNonOpaque(DstSTy);
}
SrcDefinitionsToResolve.clear();
DstResolvedOpaqueTypes.clear();
NonOpaqueStructTypes.insert(Ty);
}
+void Linker::IdentifiedStructTypeSet::switchToNonOpaque(StructType *Ty) {
+ assert(!Ty->isOpaque());
+ NonOpaqueStructTypes.insert(Ty);
+ bool Removed = OpaqueStructTypes.erase(Ty);
+ (void)Removed;
+ assert(Removed);
+}
+
void Linker::IdentifiedStructTypeSet::addOpaque(StructType *Ty) {
assert(Ty->isOpaque());
OpaqueStructTypes.insert(Ty);
--- /dev/null
+%struct.A = type { %struct.B* }
+%struct.B = type opaque
+
+define i32 @foo(%struct.A** %A) {
+ ret i32 0
+}
--- /dev/null
+%struct.A = type { %struct.B* }
+%struct.B = type opaque
+
+define i32 @bar(%struct.A* %A) {
+ ret i32 0
+}
--- /dev/null
+; RUN: llvm-link -S -o - %p/pr22807.ll %p/Inputs/pr22807-1.ll %p/Inputs/pr22807-2.ll | FileCheck %s
+
+; CHECK-NOT: type
+; CHECK: %struct.B = type { %struct.A* }
+; CHECK-NEXT: %struct.A = type { %struct.B* }
+; CHECK-NOT: type
+
+%struct.B = type { %struct.A* }
+%struct.A = type opaque
+
+define i32 @baz(%struct.B* %BB) {
+ ret i32 0
+}