Update stack alignment in ix86_update_stack_boundary
Stack alignment adjustment for __tls_get_addr should be done in ix86_update_stack_boundary, not ix86_compute_frame_layout. Also there is no need to over-align stack for __tls_get_addr and function with __tls_get_addr call isn't a leaf function. gcc/ PR target/68986 * config/i386/i386.c (ix86_compute_frame_layout): Move stack alignment adjustment to ... (ix86_update_stack_boundary): Here. Don't over-align stack for __tls_get_addr. (ix86_finalize_stack_realign_flags): Use stack_alignment_needed if __tls_get_addr is called. gcc/testsuite/ PR target/68986 * gcc.target/i386/pr68986-1.c: New test. * gcc.target/i386/pr68986-2.c: Likewise. * gcc.target/i386/pr68986-3.c: Likewise. From-SVN: r232825
This commit is contained in:
parent
213a1c03ba
commit
81cd202e24
|
@ -1,3 +1,13 @@
|
|||
2016-01-26 H.J. Lu <hongjiu.lu@intel.com>
|
||||
|
||||
PR target/68986
|
||||
* config/i386/i386.c (ix86_compute_frame_layout): Move stack
|
||||
alignment adjustment to ...
|
||||
(ix86_update_stack_boundary): Here. Don't over-align stack for
|
||||
__tls_get_addr.
|
||||
(ix86_finalize_stack_realign_flags): Use stack_alignment_needed
|
||||
if __tls_get_addr is called.
|
||||
|
||||
2016-01-26 Christian Bruel <christian.bruel@st.com>
|
||||
|
||||
* doc/sourcebuild.texi (arm_crypto_pragma_ok): Remove.
|
||||
|
|
|
@ -11360,18 +11360,6 @@ ix86_compute_frame_layout (struct ix86_frame *frame)
|
|||
crtl->preferred_stack_boundary = 128;
|
||||
crtl->stack_alignment_needed = 128;
|
||||
}
|
||||
/* preferred_stack_boundary is never updated for call
|
||||
expanded from tls descriptor. Update it here. We don't update it in
|
||||
expand stage because according to the comments before
|
||||
ix86_current_function_calls_tls_descriptor, tls calls may be optimized
|
||||
away. */
|
||||
else if (ix86_current_function_calls_tls_descriptor
|
||||
&& crtl->preferred_stack_boundary < PREFERRED_STACK_BOUNDARY)
|
||||
{
|
||||
crtl->preferred_stack_boundary = PREFERRED_STACK_BOUNDARY;
|
||||
if (crtl->stack_alignment_needed < PREFERRED_STACK_BOUNDARY)
|
||||
crtl->stack_alignment_needed = PREFERRED_STACK_BOUNDARY;
|
||||
}
|
||||
|
||||
stack_alignment_needed = crtl->stack_alignment_needed / BITS_PER_UNIT;
|
||||
preferred_alignment = crtl->preferred_stack_boundary / BITS_PER_UNIT;
|
||||
|
@ -12043,6 +12031,15 @@ ix86_update_stack_boundary (void)
|
|||
&& cfun->stdarg
|
||||
&& crtl->stack_alignment_estimated < 128)
|
||||
crtl->stack_alignment_estimated = 128;
|
||||
|
||||
/* __tls_get_addr needs to be called with 16-byte aligned stack. */
|
||||
if (ix86_tls_descriptor_calls_expanded_in_cfun
|
||||
&& crtl->preferred_stack_boundary < 128)
|
||||
{
|
||||
crtl->preferred_stack_boundary = 128;
|
||||
if (crtl->stack_alignment_needed < 128)
|
||||
crtl->stack_alignment_needed = 128;
|
||||
}
|
||||
}
|
||||
|
||||
/* Handle the TARGET_GET_DRAP_RTX hook. Return NULL if no DRAP is
|
||||
|
@ -12505,10 +12502,11 @@ ix86_finalize_stack_realign_flags (void)
|
|||
unsigned int incoming_stack_boundary
|
||||
= (crtl->parm_stack_boundary > ix86_incoming_stack_boundary
|
||||
? crtl->parm_stack_boundary : ix86_incoming_stack_boundary);
|
||||
unsigned int stack_realign = (incoming_stack_boundary
|
||||
< (crtl->is_leaf
|
||||
? crtl->max_used_stack_slot_alignment
|
||||
: crtl->stack_alignment_needed));
|
||||
unsigned int stack_realign
|
||||
= (incoming_stack_boundary
|
||||
< (crtl->is_leaf && !ix86_current_function_calls_tls_descriptor
|
||||
? crtl->max_used_stack_slot_alignment
|
||||
: crtl->stack_alignment_needed));
|
||||
|
||||
if (crtl->stack_realign_finalized)
|
||||
{
|
||||
|
|
|
@ -1,3 +1,10 @@
|
|||
2016-01-26 H.J. Lu <hongjiu.lu@intel.com>
|
||||
|
||||
PR target/68986
|
||||
* gcc.target/i386/pr68986-1.c: New test.
|
||||
* gcc.target/i386/pr68986-2.c: Likewise.
|
||||
* gcc.target/i386/pr68986-3.c: Likewise.
|
||||
|
||||
2016-01-26 Christian Bruel <christian.bruel@st.com>
|
||||
|
||||
* lib/target-supports.exp
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
/* { dg-do compile } */
|
||||
/* { dg-require-effective-target tls_native } */
|
||||
/* { dg-require-effective-target fpic } */
|
||||
/* { dg-options "-fPIC -mno-accumulate-outgoing-args -mpreferred-stack-boundary=5 -mincoming-stack-boundary=4" } */
|
||||
|
||||
extern __thread int msgdata;
|
||||
int
|
||||
foo ()
|
||||
{
|
||||
return msgdata;
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
/* { dg-do compile { target ia32 } } */
|
||||
/* { dg-require-effective-target tls_native } */
|
||||
/* { dg-require-effective-target fpic } */
|
||||
/* { dg-options "-fPIC -mno-accumulate-outgoing-args -mpreferred-stack-boundary=2 -m32" } */
|
||||
|
||||
extern __thread int msgdata;
|
||||
int
|
||||
foo ()
|
||||
{
|
||||
return msgdata;
|
||||
}
|
||||
|
||||
/* { dg-final { scan-assembler "andl\[\\t \]*\\$-16,\[\\t \]*%esp" } } */
|
|
@ -0,0 +1,13 @@
|
|||
/* { dg-do compile } */
|
||||
/* { dg-require-effective-target tls_native } */
|
||||
/* { dg-require-effective-target fpic } */
|
||||
/* { dg-options "-fPIC -mno-sse -mpreferred-stack-boundary=3 -mincoming-stack-boundary=3" } */
|
||||
|
||||
extern __thread int msgdata;
|
||||
int
|
||||
foo ()
|
||||
{
|
||||
return msgdata;
|
||||
}
|
||||
|
||||
/* { dg-final { scan-assembler "and\[lq\]\[\\t \]*\\$-16,\[\\t \]*%\[re\]?sp" } } */
|
Loading…
Reference in New Issue