[llvm-branch-commits] [cfe-branch] r208600 - Merging r201729:

Tom Stellard thomas.stellard at amd.com
Mon May 12 10:32:29 PDT 2014


Author: tstellar
Date: Mon May 12 12:32:29 2014
New Revision: 208600

URL: http://llvm.org/viewvc/llvm-project?rev=208600&view=rev
Log:
Merging r201729:

------------------------------------------------------------------------
r201729 | chandlerc | 2014-02-19 17:35:01 -0500 (Wed, 19 Feb 2014) | 21 lines

Teach Clang to provide ::max_align_t in C11 and C++11 modes.

This definition is not chosen idly. There is an unfortunate reality with
max_align_t -- the specific nature of its definition leaks into the ABI
almost immediately. Because it is part of C11 and C++11 it becomes
essential for it to match with other systems on that ABI. There is an
effort to discourage any further use of this construct as a consequence
-- using max_align_t introduces an immediate ABI problem. We can never
update it to have larger alignment even as the microarchitecture changes
to necessitate higher alignment. =/

The particular definition here exactly matches the ABI of GCC's chosen
::max_align_t definition, for better or worse. This was written with the
help of Richard Smith who was decoding the exact ABI implications of the
selected definition in GCC. Notably, in-register arguments are impacted
by the particular definition chosen. =/

No one is under the illusion that this is a "good" or "useful"
definition of max_align_t, and we are working with the standards
committee to specify a more useful interface to address this need.

------------------------------------------------------------------------

Modified:
    cfe/branches/release_34/lib/Headers/stddef.h
    cfe/branches/release_34/test/Headers/c11.c

Modified: cfe/branches/release_34/lib/Headers/stddef.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_34/lib/Headers/stddef.h?rev=208600&r1=208599&r2=208600&view=diff
==============================================================================
--- cfe/branches/release_34/lib/Headers/stddef.h (original)
+++ cfe/branches/release_34/lib/Headers/stddef.h Mon May 12 12:32:29 2014
@@ -84,6 +84,16 @@ using ::std::nullptr_t;
 #endif
 #endif
 
+#if __STDC_VERSION__ >= 201112L || __cplusplus >= 201103L
+typedef struct {
+  long long __clang_max_align_nonce1
+      __attribute__((__aligned__(__alignof__(long long))));
+  long double __clang_max_align_nonce2
+      __attribute__((__aligned__(__alignof__(long double))));
+} max_align_t;
+#define __CLANG_MAX_ALIGN_T_DEFINED
+#endif
+
 #define offsetof(t, d) __builtin_offsetof(t, d)
 
 #endif /* __STDDEF_H */

Modified: cfe/branches/release_34/test/Headers/c11.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_34/test/Headers/c11.c?rev=208600&r1=208599&r2=208600&view=diff
==============================================================================
--- cfe/branches/release_34/test/Headers/c11.c (original)
+++ cfe/branches/release_34/test/Headers/c11.c Mon May 12 12:32:29 2014
@@ -22,6 +22,10 @@ _Static_assert(__alignof(c) == 4, "");
 #define __STDC_WANT_LIB_EXT1__ 1
 #include <stddef.h>
 rsize_t x = 0;
+_Static_assert(sizeof(max_align_t) >= sizeof(long long), "");
+_Static_assert(alignof(max_align_t) >= alignof(long long), "");
+_Static_assert(sizeof(max_align_t) >= sizeof(long double), "");
+_Static_assert(alignof(max_align_t) >= alignof(long double), "");
 
 // If we are freestanding, then also check RSIZE_MAX (in a hosted implementation
 // we will use the host stdint.h, which may not yet have C11 support).





More information about the llvm-branch-commits mailing list