#include "clang/Basic/TargetInfo.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/Triple.h"
#include "llvm/Support/Capacity.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/raw_ostream.h"
unsigned ASTContext::getPreferredTypeAlign(const Type *T) const {
unsigned ABIAlign = getTypeAlign(T);
+ if (Target->getTriple().getArch() == llvm::Triple::xcore)
+ return ABIAlign; // Never overalign on XCore.
+
// Double and long long should be naturally aligned if possible.
if (const ComplexType* CT = T->getAs<ComplexType>())
T = CT->getElementType().getTypePtr();
+// RUN: %clang_cc1 -triple xcore -verify %s
+_Static_assert(sizeof(long long) == 8, "sizeof long long is wrong");
+_Static_assert(_Alignof(long long) == 4, "alignof long long is wrong");
+
+_Static_assert(sizeof(double) == 8, "sizeof double is wrong");
+_Static_assert(_Alignof(double) == 4, "alignof double is wrong");
+
// RUN: %clang_cc1 -triple xcore-unknown-unknown -fno-signed-char -fno-common -emit-llvm -o - %s | FileCheck %s
// CHECK: target datalayout = "e-p:32:32:32-a0:0:32-n32-i1:8:32-i8:8:32-i16:16:32-i32:32:32-i64:32:32-f16:16:32-f32:32:32-f64:32:32"
// CHECK: [[V2:%[a-z0-9]+]] = load i8** [[V]], align 4
// CHECK: call void @f(i8* [[V2]])
- char v2 = va_arg (ap, char);
+ char v2 = va_arg (ap, char); // expected-warning{{second argument to 'va_arg' is of promotable type 'char'}}
f(&v2);
// CHECK: [[I:%[a-z0-9]+]] = load i8** [[AP]]
// CHECK: [[IN:%[a-z0-9]+]] = getelementptr i8* [[I]], i32 4
// CHECK: [[IN:%[a-z0-9]+]] = getelementptr i8* [[I]], i32 8
// CHECK: store i8* [[IN]], i8** [[AP]]
// CHECK: [[V1:%[a-z0-9]+]] = load i64* [[P]]
- // CHECK: store i64 [[V1]], i64* [[V:%[a-z0-9]+]], align 8
+ // CHECK: store i64 [[V1]], i64* [[V:%[a-z0-9]+]], align 4
// CHECK:[[V2:%[a-z0-9]+]] = bitcast i64* [[V]] to i8*
// CHECK: call void @f(i8* [[V2]])
// CHECK: [[IN:%[a-z0-9]+]] = getelementptr i8* [[I]], i32 8
// CHECK: store i8* [[IN]], i8** [[AP]]
// CHECK: [[V1:%[a-z0-9]+]] = load double* [[P]]
- // CHECK: store double [[V1]], double* [[V:%[a-z0-9]+]], align 8
+ // CHECK: store double [[V1]], double* [[V:%[a-z0-9]+]], align 4
// CHECK: [[V2:%[a-z0-9]+]] = bitcast double* [[V]] to i8*
// CHECK: call void @f(i8* [[V2]])
}