diff options
author | Jakub Jelinek <jakub@redhat.com> | 2014-02-08 10:09:01 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2014-02-08 10:09:01 +0100 |
commit | 8fcbce729d0ccd6881e479af9eec694abec61ee5 (patch) | |
tree | f4136c704d65e778659cad96324aa2c41d89c897 /gcc/doc | |
parent | 451bdd23084ab3282aa438f8d2808ea091cc0758 (diff) | |
download | gcc-8fcbce729d0ccd6881e479af9eec694abec61ee5.tar.gz |
re PR middle-end/60092 (posix_memalign not recognized to derive alias and alignment info)
PR middle-end/60092
* tree-ssa-ccp.c (surely_varying_stmt_p): Don't return true
if TYPE_ATTRIBUTES (gimple_call_fntype ()) contain
assume_aligned or alloc_align attributes.
(bit_value_assume_aligned): Add ATTR, PTRVAL and ALLOC_ALIGN
arguments. Handle also assume_aligned and alloc_align attributes.
(evaluate_stmt): Adjust bit_value_assume_aligned caller.
Handle calls to functions with assume_aligned or alloc_align
attributes.
* doc/extend.texi: Document assume_aligned and alloc_align
attributes.
c-family/
* c-common.c (handle_alloc_size_attribute): Use tree_fits_uhwi_p
and tree_to_uhwi.
(handle_alloc_align_attribute, handle_assume_aligned_attribute): New
functions.
(c_common_attribute_table): Add alloc_align and assume_aligned
attributes.
testsuite/
* gcc.dg/attr-alloc_align-1.c: New test.
* gcc.dg/attr-alloc_align-2.c: New test.
* gcc.dg/attr-alloc_align-3.c: New test.
* gcc.dg/attr-assume_aligned-1.c: New test.
* gcc.dg/attr-assume_aligned-2.c: New test.
* gcc.dg/attr-assume_aligned-3.c: New test.
From-SVN: r207628
Diffstat (limited to 'gcc/doc')
-rw-r--r-- | gcc/doc/extend.texi | 44 |
1 files changed, 42 insertions, 2 deletions
diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi index a42e90490c0..a969fb4939c 100644 --- a/gcc/doc/extend.texi +++ b/gcc/doc/extend.texi @@ -2154,8 +2154,8 @@ The keyword @code{__attribute__} allows you to specify special attributes when making a declaration. This keyword is followed by an attribute specification inside double parentheses. The following attributes are currently defined for functions on all targets: -@code{aligned}, @code{alloc_size}, @code{noreturn}, -@code{returns_twice}, @code{noinline}, @code{noclone}, +@code{aligned}, @code{alloc_size}, @code{alloc_align}, @code{assume_aligned}, +@code{noreturn}, @code{returns_twice}, @code{noinline}, @code{noclone}, @code{always_inline}, @code{flatten}, @code{pure}, @code{const}, @code{nothrow}, @code{sentinel}, @code{format}, @code{format_arg}, @code{no_instrument_function}, @code{no_split_stack}, @@ -2249,6 +2249,46 @@ declares that @code{my_calloc} returns memory of the size given by the product of parameter 1 and 2 and that @code{my_realloc} returns memory of the size given by parameter 2. +@item alloc_align +@cindex @code{alloc_align} attribute +The @code{alloc_align} attribute is used to tell the compiler that the +function return value points to memory, where the returned pointer minimum +alignment is given by one of the functions parameters. GCC uses this +information to improve pointer alignment analysis. + +The function parameter denoting the allocated alignment is specified by +one integer argument, whose number is the argument of the attribute. +Argument numbering starts at one. + +For instance, + +@smallexample +void* my_memalign(size_t, size_t) __attribute__((alloc_align(1))) +@end smallexample + +@noindent +declares that @code{my_memalign} returns memory with minimum alignment +given by parameter 1. + +@item assume_aligned +@cindex @code{assume_aligned} attribute +The @code{assume_aligned} attribute is used to tell the compiler that the +function return value points to memory, where the returned pointer minimum +alignment is given by the first argument. +If the attribute has two arguments, the second argument is misalignment offset. + +For instance + +@smallexample +void* my_alloc1(size_t) __attribute__((assume_aligned(16))) +void* my_alloc2(size_t) __attribute__((assume_aligned(32, 8))) +@end smallexample + +@noindent +declares that @code{my_alloc1} returns 16-byte aligned pointer and +that @code{my_alloc2} returns a pointer whose value modulo 32 is equal +to 8. + @item always_inline @cindex @code{always_inline} function attribute Generally, functions are not inlined unless optimization is specified. |