Skip to content

Commit 7278cb5

Browse files
authored
[X86] [iamcu] Fix wrong alignment value for attr (aligned) with -miamcu (#80401)
attribute ((aligned)) should be 4 for -miamcu. relate: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66818
1 parent 141de74 commit 7278cb5

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

clang/lib/Basic/Targets/X86.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,7 @@ class LLVM_LIBRARY_VISIBILITY MCUX86_32TargetInfo : public X86_32TargetInfo {
672672
MCUX86_32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
673673
: X86_32TargetInfo(Triple, Opts) {
674674
LongDoubleWidth = 64;
675+
DefaultAlignForAttributeAligned = 32;
675676
LongDoubleFormat = &llvm::APFloat::IEEEdouble();
676677
resetDataLayout("e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-i64:32-"
677678
"f64:32-f128:32-n8:16:32-a:0:32-S32");

clang/test/Sema/attr-aligned.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,25 @@
11
// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fsyntax-only -verify %s
2+
// RUN: %clang_cc1 -triple i586-intel-elfiamcu -fsyntax-only -verify %s
23

34
int x __attribute__((aligned(3))); // expected-error {{requested alignment is not a power of 2}}
45
int y __attribute__((aligned(1ull << 33))); // expected-error {{requested alignment must be 4294967296 bytes or smaller}}
56
int y __attribute__((aligned(1ull << 32)));
6-
// GH50534
7-
int z __attribute__((aligned((__int128_t)0x1234567890abcde0ULL << 64))); // expected-error {{requested alignment must be 4294967296 bytes or smaller}}
87

98
// PR26444
109
int y __attribute__((aligned(1 << 29)));
1110
int y __attribute__((aligned(1 << 28)));
1211

1312
// PR3254
1413
short g0[3] __attribute__((aligned));
14+
#ifdef __iamcu
15+
short g0_chk[__alignof__(g0) == 4 ? 1 : -1];
16+
#else
1517
short g0_chk[__alignof__(g0) == 16 ? 1 : -1];
1618

19+
// GH50534
20+
int z __attribute__((aligned((__int128_t)0x1234567890abcde0ULL << 64))); // expected-error {{requested alignment must be 4294967296 bytes or smaller}}
21+
#endif
22+
1723
typedef char ueber_aligned_char __attribute__((aligned(8)));
1824

1925
struct struct_with_ueber_char {

0 commit comments

Comments
 (0)