[PATCH] D50683: [Android] Set NewAlign for 64-bit Android to 8 bytes
Pirama Arumuga Nainar via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 13 17:53:24 PDT 2018
pirama created this revision.
pirama added reviewers: rsmith, srhines.
Android uses jemalloc allocator, which returns 8-byte-aligned pointers for
allocations smaller than 8 bytes for 64-bit architectures. Set NewAlign
conservatively to 8 bytes.
Repository:
rC Clang
https://reviews.llvm.org/D50683
Files:
lib/Basic/TargetInfo.cpp
test/Preprocessor/init.c
Index: test/Preprocessor/init.c
===================================================================
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -9022,7 +9022,10 @@
// 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
+// X86_64-ANDROID-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 8UL
+//
+// RUN: %clang_cc1 -x c++ -triple aarch64-linux-android -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix AARCH64-ANDROID-CXX %s
+// AARCH64-ANDROID-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 8UL
//
// RUN: %clang_cc1 -triple arm-linux-androideabi20 -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix ANDROID20 %s
// ANDROID20:#define __ANDROID_API__ 20
Index: lib/Basic/TargetInfo.cpp
===================================================================
--- lib/Basic/TargetInfo.cpp
+++ lib/Basic/TargetInfo.cpp
@@ -64,10 +64,13 @@
// 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.
- // This alignment guarantee also applies to Windows and Android.
- if (T.isGNUEnvironment() || T.isWindowsMSVCEnvironment() || T.isAndroid())
+ // This alignment guarantee also applies to Windows.
+ if (T.isGNUEnvironment() || T.isWindowsMSVCEnvironment())
NewAlign = Triple.isArch64Bit() ? 128 : Triple.isArch32Bit() ? 64 : 0;
- else
+ else if (T.isAndroid()) {
+ // For 64-bit Android, alignment is 8 bytes for allocations <= 8 bytes.
+ NewAlign = (Triple.isArch64Bit() || Triple.isArch32Bit()) ? 64 : 0;
+ } else
NewAlign = 0; // Infer from basic type alignment.
HalfWidth = 16;
HalfAlign = 16;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50683.160497.patch
Type: text/x-patch
Size: 1959 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180814/78ac3443/attachment.bin>
More information about the cfe-commits
mailing list