Fix v1.31 regression wrt. unresolved IrAggr (#4312)

And use `IrTypeClass::getVtblType()` to get the vtable LLVM array
type, instead of deriving it from the `IrClass::getVtblSymbol()`
global (invoking that function may define the vtable!).

I've hit some compiler crashes for the Symmetry code base, on
Windows only. I guess the problem surfaced due to
`-link-defaultlib-shared`, which on Windows causes some vtables of
instantiated classes to be defined whenever accessing the vtable
symbol. I don't have a reduced test case unfortunately.
This commit is contained in:
Martin Kinkelin 2023-02-06 17:02:07 +01:00 committed by GitHub
parent 58c4b8bdae
commit 5f46c65ab5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 37 additions and 39 deletions

View file

@ -46,7 +46,8 @@ LLValue *loadThisPtr(AggregateDeclaration *ad, IrFunction &irfunc) {
}
LLValue *indexVThis(AggregateDeclaration *ad, LLValue* val) {
llvm::StructType *st = getIrAggr(ad, true)->getLLStructType();
DtoResolveDsymbol(ad);
llvm::StructType *st = getIrAggr(ad)->getLLStructType();
unsigned idx = getVthisIdx(ad);
return DtoLoad(st->getElementType(idx),
DtoGEP(st, val, 0, idx, ".vthis"));
@ -226,7 +227,7 @@ void DtoResolveNestedContext(const Loc &loc, AggregateDeclaration *decl,
DtoResolveDsymbol(decl);
unsigned idx = getVthisIdx(decl);
llvm::StructType *st = getIrAggr(decl, true)->getLLStructType();
llvm::StructType *st = getIrAggr(decl)->getLLStructType();
LLValue *gep = DtoGEP(st, value, 0, idx, ".vthis");
DtoStore(DtoBitCast(nest, st->getElementType(idx)), gep);
}