Fix ICE for ref/out params of opaque structs

Fixes dmd-testsuite's new compilable/test21668.d.
This commit is contained in:
Martin Kinkelin 2021-03-01 11:12:28 +01:00
parent 3abffca14c
commit 52bcbcc566
3 changed files with 25 additions and 13 deletions

View file

@ -183,7 +183,16 @@ llvm::FunctionType *DtoFunctionType(Type *type, IrFuncTy &irFty, Type *thistype,
loweredDType = merge(ltd);
} else if (passPointer) {
// ref/out
attrs.addDereferenceableAttr(loweredDType->size());
auto ts = loweredDType->toBasetype()->isTypeStruct();
if (ts && !ts->sym->members) {
// opaque struct
attrs.addAttribute(LLAttribute::NonNull);
#if LDC_LLVM_VER >= 1100
attrs.addAttribute(LLAttribute::NoUndef);
#endif
} else {
attrs.addDereferenceableAttr(loweredDType->size());
}
} else {
if (abi->passByVal(f, loweredDType)) {
// LLVM ByVal parameters are pointers to a copy in the function