зеркало из https://github.com/dotnet/llilc.git
Fix llvm assert when calling StructType::setBody from getClassType.
It's possible that while adding the fields to a struct we may complete the struct due to circular type definitions. Detect that case and return the result right away.
This commit is contained in:
Родитель
d1d9ece652
Коммит
9b0f4ec7ec
|
@ -1305,7 +1305,7 @@ Type *GenIR::getClassType(CORINFO_CLASS_HANDLE ClassHandle, bool IsRefClass,
|
|||
// causes trouble with certain recursive type graphs, for example:
|
||||
//
|
||||
// class A { B b; }
|
||||
// class B : extends A { int c };
|
||||
// class B : extends A { int c; }
|
||||
//
|
||||
// We need to know the size of A before we can finish B. So we can't
|
||||
// ask for B's details while filling out A.
|
||||
|
@ -1405,6 +1405,15 @@ Type *GenIR::getClassType(CORINFO_CLASS_HANDLE ClassHandle, bool IsRefClass,
|
|||
}
|
||||
}
|
||||
|
||||
// It's possible that while adding the fields to this struct we already
|
||||
// completed the struct. For example:
|
||||
// class A { B b; }
|
||||
// struct B { A a; }
|
||||
// In that case we are already done.
|
||||
if (!StructTy->isOpaque()) {
|
||||
return ResultTy;
|
||||
}
|
||||
|
||||
// Install the field list (even if empty) to complete the struct.
|
||||
// Since padding is explicit, this is an LLVM packed struct.
|
||||
StructTy->setBody(Fields, true /* isPacked */);
|
||||
|
|
Загрузка…
Ссылка в новой задаче