-
Notifications
You must be signed in to change notification settings - Fork 191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clarify definition of HFA in AAPCS64 #206
Comments
Another litmus test: typedef union {
struct { double a, b; } x;
struct { double a; double __attribute__((aligned(16))) c; double d; } y;
} __attribute__((aligned(16))) T; Gcc and clang don't consider this to be an HFA. |
I agree this is an area that could do with further clarification, having been confused by it myself before.
It is not intended to be a requirement. We consider V to be an alignment modified HFA. To give you some idea of why clang/gcc are not classifying certain structures as aggregates.
T is not a HFA as there is padding within the structure. While padding is not important for it to be considered a composite type, it is important for it being considered a HFA. The best part of the text that describes this is Neither of which are considered homogenous. Again I agree that this could be improved. Possibly in an external rationale with examples rather than in the document directly. |
What about
But HFA is defined in terms of uniquely addressable members, and:
It seems to me that this is very specifically an issue of padding, and needs to be spelt out as such. Hence
I still think the document itself is ambiguous. |
Since I was the original author of the HFA rules in the AAPCS, I'll chime in here. I've reviewed the text in the AAPCS and I agree that some additional clarity is warranted: the handling of alignment modifiers was added to the specification as a result of the updates to support C11 and in retrospect it's clear that we missed some changes here. We will need to ensure that any wording changes do not affect existing implementations (excepting, of course, any cases where they do not agree with each other). This may take us some time as we will need to do some careful validation. |
Another litmus test: |
That's not valid C (zero sized arrays are a GNU extension). Perhaps you mean the C11 flexible array |
Right.
No; the type |
Both |
Consider the following definitions:
Gcc and clang consider V to be an HFA, and not T and U. There is the following statement (§5.9.5):
If this is intended to be a requirement for homogeneous aggregates, then it disqualifies V from being one, since V's alignment is not that of double. If that is the case, then it should be stated more prominently. However, this seems unlikely (§C.4):
explicitly making allowances for HFAs with alignment >16, even though there is no floating-point type with such alignment. If the intent of the specification was that V should be an HFA, then it is not clear why T and U should not be. It is made clear that padding is not a member, for (§5.9):
There are ambiguities in the spec. The best move is probably to change it to be clearly aligned with the behaviour of gcc and clang, but more minimal changes which clearly break gcc and clang are also plausible.
The text was updated successfully, but these errors were encountered: