forked from OSchip/llvm-project
[Clang] Fix the guaranteed alignment of memory returned by malloc/new on OpenBSD
The guaranteed alignment is 16 bytes on OpenBSD.
This commit is contained in:
parent
3b3dd76d8d
commit
c7ee0b8bda
|
@ -69,11 +69,11 @@ TargetInfo::TargetInfo(const llvm::Triple &T) : Triple(T) {
|
||||||
// From the glibc documentation, on GNU systems, malloc guarantees 16-byte
|
// 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
|
// 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.
|
// https://www.gnu.org/software/libc/manual/html_node/Malloc-Examples.html.
|
||||||
// This alignment guarantee also applies to Windows and Android. On Darwin,
|
// This alignment guarantee also applies to Windows and Android. On Darwin
|
||||||
// the alignment is 16 bytes on both 64-bit and 32-bit systems.
|
// and OpenBSD, the alignment is 16 bytes on both 64-bit and 32-bit systems.
|
||||||
if (T.isGNUEnvironment() || T.isWindowsMSVCEnvironment() || T.isAndroid())
|
if (T.isGNUEnvironment() || T.isWindowsMSVCEnvironment() || T.isAndroid())
|
||||||
NewAlign = Triple.isArch64Bit() ? 128 : Triple.isArch32Bit() ? 64 : 0;
|
NewAlign = Triple.isArch64Bit() ? 128 : Triple.isArch32Bit() ? 64 : 0;
|
||||||
else if (T.isOSDarwin())
|
else if (T.isOSDarwin() || T.isOSOpenBSD())
|
||||||
NewAlign = 128;
|
NewAlign = 128;
|
||||||
else
|
else
|
||||||
NewAlign = 0; // Infer from basic type alignment.
|
NewAlign = 0; // Infer from basic type alignment.
|
||||||
|
|
|
@ -198,6 +198,9 @@
|
||||||
// RUN: %clang_cc1 -E -dM -triple=armv7-apple-ios7.0 -x c++ < /dev/null | FileCheck -match-full-lines -check-prefix ARM-DARWIN-CXX %s
|
// RUN: %clang_cc1 -E -dM -triple=armv7-apple-ios7.0 -x c++ < /dev/null | FileCheck -match-full-lines -check-prefix ARM-DARWIN-CXX %s
|
||||||
// ARM-DARWIN-CXX: #define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 16UL
|
// ARM-DARWIN-CXX: #define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 16UL
|
||||||
|
|
||||||
|
// RUN: %clang_cc1 -E -dM -triple=arm-unknown-openbsd -x c++ < /dev/null | FileCheck -match-full-lines -check-prefix ARM-OPENBSD-CXX %s
|
||||||
|
// ARM-OPENBSD-CXX: #define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 16UL
|
||||||
|
|
||||||
// RUN: %clang_cc1 -dM -ffreestanding -triple arm-none-none -target-abi apcs-gnu -E /dev/null -o - | FileCheck -match-full-lines -check-prefix ARM-APCS-GNU %s
|
// RUN: %clang_cc1 -dM -ffreestanding -triple arm-none-none -target-abi apcs-gnu -E /dev/null -o - | FileCheck -match-full-lines -check-prefix ARM-APCS-GNU %s
|
||||||
// ARM-APCS-GNU: #define __INTPTR_TYPE__ int
|
// ARM-APCS-GNU: #define __INTPTR_TYPE__ int
|
||||||
// ARM-APCS-GNU: #define __PTRDIFF_TYPE__ int
|
// ARM-APCS-GNU: #define __PTRDIFF_TYPE__ int
|
||||||
|
|
|
@ -1171,3 +1171,6 @@
|
||||||
// PPC-DARWIN:#define __WINT_WIDTH__ 32
|
// PPC-DARWIN:#define __WINT_WIDTH__ 32
|
||||||
// PPC-DARWIN:#define __powerpc__ 1
|
// PPC-DARWIN:#define __powerpc__ 1
|
||||||
// PPC-DARWIN:#define __ppc__ 1
|
// PPC-DARWIN:#define __ppc__ 1
|
||||||
|
|
||||||
|
// RUN: %clang_cc1 -E -dM -triple=powerpc-unknown-openbsd -x c++ < /dev/null | FileCheck -match-full-lines -check-prefix PPC-OPENBSD-CXX %s
|
||||||
|
// PPC-OPENBSD-CXX: #define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 16UL
|
||||||
|
|
|
@ -1717,3 +1717,6 @@
|
||||||
// X86_64-NETBSD:#define __amd64__ 1
|
// X86_64-NETBSD:#define __amd64__ 1
|
||||||
// X86_64-NETBSD:#define __x86_64 1
|
// X86_64-NETBSD:#define __x86_64 1
|
||||||
// X86_64-NETBSD:#define __x86_64__ 1
|
// X86_64-NETBSD:#define __x86_64__ 1
|
||||||
|
|
||||||
|
// RUN: %clang_cc1 -E -dM -triple=i386-unknown-openbsd -x c++ < /dev/null | FileCheck -match-full-lines -check-prefix I386-OPENBSD-CXX %s
|
||||||
|
// I386-OPENBSD-CXX: #define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 16UL
|
||||||
|
|
Loading…
Reference in New Issue