From 651282142f9f33ecb045d3f9784d3c2cd5558d37 Mon Sep 17 00:00:00 2001 From: Pirama Arumuga Nainar Date: Wed, 1 Aug 2018 17:55:34 +0000 Subject: [PATCH] [Android] Increase default new alignment for Android Summary: Android's memory allocators also guarantee 8-byte alignment for 32-bit architectures and 16-byte alignment for 64-bit. Reviewers: rsmith Subscribers: cfe-commits, srhines, enh Differential Revision: https://reviews.llvm.org/D50112 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338603 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Basic/TargetInfo.cpp | 5 +++-- test/Preprocessor/init.c | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/Basic/TargetInfo.cpp b/lib/Basic/TargetInfo.cpp index 3400c8721f..7b69cb097c 100644 --- a/lib/Basic/TargetInfo.cpp +++ b/lib/Basic/TargetInfo.cpp @@ -63,8 +63,9 @@ TargetInfo::TargetInfo(const llvm::Triple &T) : TargetOpts(), Triple(T) { MinGlobalAlign = 0; // From the glibc documentation, on GNU systems, malloc guarantees 16-byte // alignment on 64-bit systems and 8-byte alignment on 32-bit systems. See - // https://www.gnu.org/software/libc/manual/html_node/Malloc-Examples.html - if (T.isGNUEnvironment() || T.isWindowsMSVCEnvironment()) + // https://www.gnu.org/software/libc/manual/html_node/Malloc-Examples.html. + // This alignment guarantee also applies to Windows and Android. + if (T.isGNUEnvironment() || T.isWindowsMSVCEnvironment() || T.isAndroid()) NewAlign = Triple.isArch64Bit() ? 128 : Triple.isArch32Bit() ? 64 : 0; else NewAlign = 0; // Infer from basic type alignment. diff --git a/test/Preprocessor/init.c b/test/Preprocessor/init.c index 68d057d87b..e61caecbb2 100644 --- a/test/Preprocessor/init.c +++ b/test/Preprocessor/init.c @@ -9019,7 +9019,7 @@ // ANDROID:#define __ANDROID__ 1 // // RUN: %clang_cc1 -x c++ -triple i686-linux-android -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix I386-ANDROID-CXX %s -// I386-ANDROID-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 4U +// I386-ANDROID-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 8U // // RUN: %clang_cc1 -x c++ -triple x86_64-linux-android -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix X86_64-ANDROID-CXX %s // X86_64-ANDROID-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 16UL -- 2.40.0