Bug 95885 - LOCAL_DECL_ALIGNMENT and TARGET_LOWER_LOCAL_DECL_ALIGNMENT macro documentation should be improved
Summary: LOCAL_DECL_ALIGNMENT and TARGET_LOWER_LOCAL_DECL_ALIGNMENT macro documentatio...
Status: ASSIGNED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 11.0
: P3 normal
Target Milestone: ---
Assignee: Andrew Pinski
URL:
Keywords: documentation
Depends on:
Blocks:
 
Reported: 2020-06-24 20:01 UTC by Sunil Pandey
Modified: 2022-11-11 18:32 UTC (History)
1 user (show)

See Also:
Host:
Target: x86_64-*-* i?86-*-*
Build:
Known to work:
Known to fail:
Last reconfirmed: 2020-06-25 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sunil Pandey 2020-06-24 20:01:05 UTC
LOCAL_DECL_ALIGNMENT Macro documentation

 1172 @defmac LOCAL_DECL_ALIGNMENT (@var{decl})
 1173 If defined, a C expression to compute the alignment for a local
 1174 variable @var{decl}.
 1175 
 1176 If this macro is not defined, then
 1177 @code{LOCAL_ALIGNMENT (TREE_TYPE (@var{decl}), DECL_ALIGN (@var{decl}))}
 1178 is used.
 1179 
 1180 One use of this macro is to increase alignment of medium-size data to
 1181 make it all fit in fewer cache lines.
 1182 
 1183 If the value of this macro has a type, it should be an unsigned type.
 1184 @end defmac

This macro not only increases alignment but also decreases(-m32 -mpreferred-stack-boundary=2) depending on condition.
Comment 1 Richard Biener 2020-06-25 07:38:21 UTC
The documentation is correct, the x86 implementation is not.  Note the
documentation says "One use of this macro...", so clearly it's documentation
can be improved by explicitely constraining the macro to increase alignment.
Comment 2 Andrew Pinski 2022-11-11 18:32:48 UTC
There is now TARGET_LOWER_LOCAL_DECL_ALIGNMENT which was added by r11-2259-g 0a9d711df36b42 .

We should provide examples of when one should be used vs the other.
And maybe even better describe why there are two target hooks that seems like does the same thing now.

I am going to try to this for GCC 14 with the other target macro/hooks cleanups I am doing.