@@ -47,11 +47,16 @@ struct Win64TargetABI : TargetABI
47
47
void rewriteArgument (IrFuncTy& fty, IrFuncTyArg& arg);
48
48
49
49
private:
50
- // Returns true if the D type is a composite (struct/static array/complex number).
51
- bool isComposite (Type* t)
50
+ // Returns true if the D type is an aggregate:
51
+ // * struct
52
+ // * static/dynamic array
53
+ // * delegate
54
+ // * complex number
55
+ bool isAggregate (Type* t)
52
56
{
53
- return t->ty == Tstruct || t->ty == Tsarray
54
- || t->iscomplex (); // treat complex numbers as structs too
57
+ TY ty = t->ty ;
58
+ return ty == Tstruct || ty == Tsarray || ty == Tarray || ty == Tdelegate
59
+ || t->iscomplex ();
55
60
}
56
61
57
62
// Returns true if the D type can be bit-cast to an integer of the same size.
@@ -75,8 +80,9 @@ struct Win64TargetABI : TargetABI
75
80
bool isPassedWithByvalSemantics (Type* t)
76
81
{
77
82
return
78
- // * structs/static arrays/complex numbers which can NOT be rewritten as integers
79
- (isComposite (t) && !canRewriteAsInt (t)) ||
83
+ // * aggregates which can NOT be rewritten as integers
84
+ // (size > 64 bits or not a power of 2)
85
+ (isAggregate (t) && !canRewriteAsInt (t)) ||
80
86
// * 80-bit real and ireal
81
87
(realIs80bits () && (t->ty == Tfloat80 || t->ty == Timaginary80));
82
88
}
@@ -116,8 +122,7 @@ bool Win64TargetABI::returnInArg(TypeFunction* tf)
116
122
// * all POD types <= 64 bits and of a size that is a power of 2
117
123
// (incl. 2x32-bit cfloat) are returned in a register (RAX, or
118
124
// XMM0 for single float/ifloat/double/idouble)
119
- // * all other structs/static arrays/complex numbers and 80-bit
120
- // real/ireal are returned via struct-return (sret)
125
+ // * all other types are returned via struct-return (sret)
121
126
return (rt->ty == Tstruct && !((TypeStruct*)rt)->sym ->isPOD ())
122
127
|| isPassedWithByvalSemantics (rt);
123
128
}
@@ -165,7 +170,7 @@ void Win64TargetABI::rewriteArgument(IrFuncTy& fty, IrFuncTyArg& arg)
165
170
.add (LDC_ATTRIBUTE (NoAlias))
166
171
.add (LDC_ATTRIBUTE (NoCapture));
167
172
}
168
- else if (isComposite (t) && canRewriteAsInt (t) && !IntegerRewrite::isObsoleteFor (originalLType))
173
+ else if (isAggregate (t) && canRewriteAsInt (t) && !IntegerRewrite::isObsoleteFor (originalLType))
169
174
{
170
175
arg.rewrite = &integerRewrite;
171
176
arg.ltype = integerRewrite.type (arg.type , arg.ltype );
0 commit comments