Add TARGET_LOWER_LOCAL_DECL_ALIGNMENT [PR95237]
authorSunil K Pandey <skpgkp2@gmail.com>
Sat, 18 Jul 2020 02:42:09 +0000 (19:42 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Tue, 21 Jul 2020 23:25:43 +0000 (16:25 -0700)
commit0a9d711df36b42b6494b73a90c7ebf050e904493
treee6b4dc17bd474f0c42f2d8b9d85a8f6dbdb00dce
parent699f9c0cc1bcc8acfd78c02315c963bf790c874d
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.
16 files changed:
gcc/c/c-decl.c
gcc/config/i386/i386-protos.h
gcc/config/i386/i386.c
gcc/cp/decl.c
gcc/doc/tm.texi
gcc/doc/tm.texi.in
gcc/target.def
gcc/testsuite/c-c++-common/pr95237-1.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/pr95237-2.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/pr95237-3.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/pr95237-4.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/pr95237-5.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/pr95237-6.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/pr95237-7.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/pr95237-8.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/pr95237-9.c [new file with mode: 0644]