-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[clang] Ensure minimal alignment of global vars of incomplete type. (#…
…72886) The SystemZ ABI requires any global variable to be aligned to at least 2 bytes, and therefore an external global Value with an opaque type should get this alignment as well.
- Loading branch information
Showing
2 changed files
with
40 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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 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; | ||
} |