-
Notifications
You must be signed in to change notification settings - Fork 85
7904115: Fix for AIX test case failures due to incorrect alignment for double and pointer #296
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
base: master
Are you sure you want to change the base?
Changes from 4 commits
97b3e87
fdaf568
996537e
d4a0f64
12b42e8
7f1983b
f43b66f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,7 @@ | |
| import java.util.ArrayList; | ||
| import java.util.Collections; | ||
| import java.util.List; | ||
| import org.openjdk.jextract.Type; | ||
|
|
||
| public final class Options { | ||
|
|
||
|
|
@@ -86,6 +87,9 @@ public Options build() { | |
|
|
||
| public void addClangArg(String arg) { | ||
| clangArgs.add(arg); | ||
| if (TypeImpl.IS_AIX) { | ||
| clangArgs.add("-m64"); | ||
| } | ||
|
||
| } | ||
|
|
||
| public void addLibrary(Library library) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are there 2 cases here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn't this be:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes right.
These are my findings!
case Double -> alignIfNeeded(runtimeHelperName() + ".C_DOUBLE", (TypeImpl.IS_AIX ? 4 : 8), align);The above fix solves most of the failures except two of them. This solves the failure like "Unsupported layout: 4%D8"
The remaining two test failures are due to 'IllegalArgumentException: Invalid alignment constraint for member layout: D8(d)'
I observed that the expected alignment is 8 for them and the ABI expects the alignment constraint for d to be 4, not 8
For one of the test failure : jtreg/generator/testStruct/LibStructTest.java
For the struct AllTypes, the double d field is not the first field, so according to AIX power mode rules, subsequent doubles are aligned on 4-byte boundaries, not 8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's expected, but I think the test should be modified to handle that instead. The issue with the code in this patch is that it adjusts the alignment down to
4in some cases when the requested alignment is8. The requested alignment (i.e. thealignargument) is always correct here, since that is what we get straight from clang based on alignment specifiers or pack pragmas.For instance, for a struct like this:
alignwould be8here for the fieldd, but you overwrite it to4, which doesn't seem right.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I had another look at the test, and it looks like it can not really be adjusted, so there might be an issue elsewhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did a little debugging, and it looks like clang doesn't attach the alignment specified by
alignasto the field declaration any ways. So, we can not handle hyper-aligned fields even if we wanted to. In other words, you can disregard the example above.On the other hand, I'm not sure if clang attaches the right alignment to double fields that are not the first field on AIX. Look at the code in
StructBuilderthat generates the layouts for fields:You should be able to get the alignment of the field deceleration using
long fieldAlign = ClangAlignOf.getOrThrow(var) / 8;. If this is4as expected for a non-first double field, then we could just pass that information down to the code that generates the layout string, I think.