diff options
author | Sunil K Pandey <skpgkp2@gmail.com> | 2020-07-17 19:42:09 -0700 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2020-07-21 16:25:43 -0700 |
commit | 0a9d711df36b42b6494b73a90c7ebf050e904493 (patch) | |
tree | e6b4dc17bd474f0c42f2d8b9d85a8f6dbdb00dce /gcc/cp | |
parent | 699f9c0cc1bcc8acfd78c02315c963bf790c874d (diff) | |
download | gcc-0a9d711df36b42b6494b73a90c7ebf050e904493.zip gcc-0a9d711df36b42b6494b73a90c7ebf050e904493.tar.gz gcc-0a9d711df36b42b6494b73a90c7ebf050e904493.tar.bz2 |
Add TARGET_LOWER_LOCAL_DECL_ALIGNMENT [PR95237]
Default for this hook is NOP. For x86, in 32 bit mode, this hook
sets alignment of long long on stack to 32 bits if preferred stack
boundary is 32 bits.
- This patch prevents lowering of alignment from following macros.
LOCAL_ALIGNMENT
STACK_SLOT_ALIGNMENT
LOCAL_DECL_ALIGNMENT
- This patch fixes
gcc.target/i386/pr69454-2.c
gcc.target/i386/stackalign/longlong-1.c
- Regression test on x86-64, no new fail introduced.
Tested on x86-64.
gcc/c/ChangeLog:
PR target/95237
* c-decl.c (finish_decl): Call target hook
lower_local_decl_alignment to lower local decl alignment.
gcc/ChangeLog:
PR target/95237
* config/i386/i386-protos.h (ix86_local_alignment): Add
another function parameter may_lower alignment. Default is
false.
* config/i386/i386.c (ix86_lower_local_decl_alignment): New
function.
(ix86_local_alignment): Amend ix86_local_alignment to accept
another parameter may_lower. If may_lower is true, new align
may be lower than incoming alignment. If may_lower is false,
new align will be greater or equal to incoming alignment.
(TARGET_LOWER_LOCAL_DECL_ALIGNMENT): Define.
* doc/tm.texi: Regenerate.
* doc/tm.texi.in (TARGET_LOWER_LOCAL_DECL_ALIGNMENT): New
hook.
* target.def (lower_local_decl_alignment): New hook.
gcc/cp/ChangeLog:
PR target/95237
* decl.c (cp_finish_decl): Call target hook
lower_local_decl_alignment to lower local decl alignment.
gcc/testsuite/ChangeLog:
PR target/95237
* c-c++-common/pr95237-1.c: New test.
* c-c++-common/pr95237-2.c: New test.
* c-c++-common/pr95237-3.c: New test.
* c-c++-common/pr95237-4.c: New test.
* c-c++-common/pr95237-5.c: New test.
* c-c++-common/pr95237-6.c: New test.
* c-c++-common/pr95237-7.c: New test.
* c-c++-common/pr95237-8.c: New test.
* c-c++-common/pr95237-9.c: New test.
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/decl.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index db91b50..7d71745 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -8012,6 +8012,13 @@ cp_finish_decl (tree decl, tree init, bool init_const_expr_p, NULL_TREE, DECL_ATTRIBUTES (decl)); } + /* This is the last point we can lower alignment so give the target the + chance to do so. */ + if (VAR_P (decl) + && !is_global_var (decl) + && !DECL_HARD_REGISTER (decl)) + targetm.lower_local_decl_alignment (decl); + invoke_plugin_callbacks (PLUGIN_FINISH_DECL, decl); } |