зеркало из https://github.com/dotnet/llilc.git
Merge pull request #485 from erozenfeld/getClassTypeFix
Fix llvm assert when calling StructType::setBody from getClassType.
This commit is contained in:
Коммит
5955b02d45
|
@ -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 */);
|
||||
|
|
Загрузка…
Ссылка в новой задаче