File tree 4 files changed +52
-2
lines changed
4 files changed +52
-2
lines changed Original file line number Diff line number Diff line change @@ -940,6 +940,9 @@ class TargetInfo : public RefCountedBase<TargetInfo> {
940
940
return false ;
941
941
}
942
942
943
+ // / \brief Whether target allows to overalign ABI-specified prefered alignment
944
+ virtual bool allowsLargerPreferedTypeAlignment () const { return true ; }
945
+
943
946
protected:
944
947
virtual uint64_t getPointerWidthV (unsigned AddrSpace) const {
945
948
return PointerWidth;
Original file line number Diff line number Diff line change @@ -1904,8 +1904,8 @@ unsigned ASTContext::getPreferredTypeAlign(const Type *T) const {
1904
1904
if (T->isMemberPointerType ())
1905
1905
return getPreferredTypeAlign (getPointerDiffType ().getTypePtr ());
1906
1906
1907
- if (Target->getTriple (). getArch () == llvm::Triple::xcore )
1908
- return ABIAlign; // Never overalign on XCore.
1907
+ if (! Target->allowsLargerPreferedTypeAlignment () )
1908
+ return ABIAlign;
1909
1909
1910
1910
// Double and long long should be naturally aligned if possible.
1911
1911
if (const ComplexType *CT = T->getAs <ComplexType>())
Original file line number Diff line number Diff line change @@ -3807,6 +3807,8 @@ class MicrosoftX86_32TargetInfo : public WindowsX86_32TargetInfo {
3807
3807
: WindowsX86_32TargetInfo(Triple) {
3808
3808
LongDoubleWidth = LongDoubleAlign = 64 ;
3809
3809
LongDoubleFormat = &llvm::APFloat::IEEEdouble;
3810
+ DataLayoutString =
3811
+ " e-m:e-p:32:32-i64:32-f64:32-f128:32-n8:16:32-a:0:32-S32" ;
3810
3812
}
3811
3813
void getTargetDefines (const LangOptions &Opts,
3812
3814
MacroBuilder &Builder) const override {
@@ -3926,6 +3928,10 @@ class MCUX86_32TargetInfo : public X86_32TargetInfo {
3926
3928
Builder.defineMacro (" __iamcu" );
3927
3929
Builder.defineMacro (" __iamcu__" );
3928
3930
}
3931
+
3932
+ bool allowsLargerPreferedTypeAlignment () const override {
3933
+ return false ;
3934
+ }
3929
3935
};
3930
3936
3931
3937
// RTEMS Target
@@ -7491,6 +7497,9 @@ class XCoreTargetInfo : public TargetInfo {
7491
7497
// R0=ExceptionPointerRegister R1=ExceptionSelectorRegister
7492
7498
return (RegNo < 2 )? RegNo : -1 ;
7493
7499
}
7500
+ bool allowsLargerPreferedTypeAlignment () const override {
7501
+ return false ;
7502
+ }
7494
7503
};
7495
7504
7496
7505
const Builtin::Info XCoreTargetInfo::BuiltinInfo[] = {
Original file line number Diff line number Diff line change
1
+ // RUN: %clang_cc1 -triple i386-pc-elfiamcu -emit-llvm -o - %s | FileCheck %s
2
+
3
+ // CHECK: target datalayout = "e-m:e-p:32:32-i64:32-f64:32-f128:32-n8:16:32-a:0:32-S32"
4
+ // CHECK: target triple = "i386-pc-elfiamcu"
5
+
6
+
7
+ void food (double * d );
8
+ void fooll (long long * ll );
9
+ void fooull (unsigned long long * ull );
10
+ void foold (long double * ld );
11
+
12
+ // CHECK-LABEL: define void @testdouble()
13
+ // CHECK: alloca double, align 4
14
+ void testdouble () {
15
+ double d = 2.0 ;
16
+ food (& d );
17
+ }
18
+
19
+ // CHECK-LABEL: define void @testlonglong()
20
+ // CHECK: alloca i64, align 4
21
+ void testlonglong () {
22
+ long long ll = 2 ;
23
+ fooll (& ll );
24
+ }
25
+
26
+ // CHECK-LABEL: define void @testunsignedlonglong()
27
+ // CHECK: alloca i64, align 4
28
+ void testunsignedlonglong () {
29
+ unsigned long long ull = 2 ;
30
+ fooull (& ull );
31
+ }
32
+
33
+ // CHECK-LABEL: define void @testlongdouble()
34
+ // CHECK: alloca double, align 4
35
+ void testlongdouble () {
36
+ long double ld = 2.0 ;
37
+ foold (& ld );
38
+ }
You can’t perform that action at this time.
0 commit comments