-
Notifications
You must be signed in to change notification settings - Fork 14.9k
[clang] Ensure minimal alignment of global vars of incomplete type. #72886
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// RUN: %clang --target=s390x-linux -S -emit-llvm -o - %s | FileCheck %s | ||
// | ||
// Test that a global variable with an incomplete type gets the minimum | ||
// alignment of 2 per the ABI if no alignment was specified by user. | ||
// | ||
// CHECK: @VarNoAl {{.*}} align 2 | ||
// CHECK-NEXT: @VarExplAl1 {{.*}} align 1 | ||
// CHECK-NEXT: @VarExplAl4 {{.*}} align 4 | ||
|
||
// No alignemnt specified by user. | ||
struct incomplete_ty_noal; | ||
extern struct incomplete_ty_noal VarNoAl; | ||
struct incomplete_ty_noal *fun0 (void) | ||
{ | ||
return &VarNoAl; | ||
} | ||
|
||
// User-specified alignment of 1. | ||
struct incomplete_ty_al1; | ||
extern struct incomplete_ty_al1 __attribute__((aligned(1))) VarExplAl1; | ||
struct incomplete_ty_al1 *fun1 (void) | ||
{ | ||
return &VarExplAl1; | ||
} | ||
|
||
// User-specified alignment of 4. | ||
struct incomplete_ty_al4; | ||
extern struct incomplete_ty_al4 __attribute__((aligned(4))) VarExplAl4; | ||
struct incomplete_ty_al4 *fun2 (void) | ||
{ | ||
return &VarExplAl4; | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 is this a Driver test rather than a CodeGen test using clang_cc1?
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 found some other align tests there, like arm-alignment.c, so I thought this should work..?
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.
Sorry, I missed this when reviewing.
We generally only use Driver tests when we're trying to test some aspect of the driver. For arm-alignment.c, it isn't really trying to test the code generation itself; it's trying to test the effect of alignment-related flags.
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.
Sorry, my bad. There is a SystemZ test for this already, so I moved these tests into it instead. I created a new PR: #73230.