This is an automated email from the git hooks/post-receive script.
unknown user pushed a commit to branch hjl/pr58066/gcc-5-branch in repository gcc.
commit 94c030b0534570cd3a9f946877d00bd0862f3636 Author: H.J. Lu hjl.tools@gmail.com Date: Sat Jul 11 16:35:07 2015 -0700
Align stack before calling __tls_get_addr
In 64-bit, we need to align the stack to 16 bytes before generating __tls_get_addr call
PR targer/58066 * config/i386/i386.c (legitimize_tls_address): Adjust stack to align to 16 bytes before generating __tls_get_addr call. * config/i386/i386.md (*tls_global_dynamic_64_<mode>): Updated to depend on SP register. (*tls_global_dynamic_64_largepic): Likewise. (tls_global_dynamic_64_<mode>): Likewise. (*tls_local_dynamic_base_64_<mode>): Likewise. (*tls_local_dynamic_base_64_largepic): Likewise. (tls_local_dynamic_base_64_<mode>): Likewise. --- gcc/config/i386/i386.c | 15 +++++++++++++++ gcc/config/i386/i386.md | 21 +++++++++++++++------ 2 files changed, 30 insertions(+), 6 deletions(-)
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 7c28a55..e01c075 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -14046,6 +14046,13 @@ legitimize_tls_address (rtx x, enum tls_model model, bool [...] && model == TLS_MODEL_LOCAL_DYNAMIC) model = TLS_MODEL_GLOBAL_DYNAMIC;
+ int preferred_stack_alignment + = ix86_preferred_stack_boundary / BITS_PER_UNIT; + int stack_adjustment = (((stack_pointer_delta + % preferred_stack_alignment) + - preferred_stack_alignment) + % preferred_stack_alignment); + switch (model) { case TLS_MODEL_GLOBAL_DYNAMIC: @@ -14087,8 +14094,12 @@ legitimize_tls_address (rtx x, enum tls_model model, bool [...] rtx_insn *insns;
start_sequence (); + if (stack_adjustment) + adjust_stack (GEN_INT (stack_adjustment)); emit_call_insn (ix86_gen_tls_global_dynamic_64 (rax, x, caddr)); + if (stack_adjustment) + anti_adjust_stack (GEN_INT (stack_adjustment)); insns = get_insns (); end_sequence ();
@@ -14141,8 +14152,12 @@ legitimize_tls_address (rtx x, enum tls_model model, bool [...] rtx eqv;
start_sequence (); + if (stack_adjustment) + adjust_stack (GEN_INT (stack_adjustment)); emit_call_insn (ix86_gen_tls_local_dynamic_base_64 (rax, caddr)); + if (stack_adjustment) + anti_adjust_stack (GEN_INT (stack_adjustment)); insns = get_insns (); end_sequence ();
diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md index 6b6f44c..810ea44 100644 --- a/gcc/config/i386/i386.md +++ b/gcc/config/i386/i386.md @@ -13237,7 +13237,8 @@ (call:P (mem:QI (match_operand 2 "constant_call_address_operand" "Bz")) (match_operand 3))) - (unspec:P [(match_operand 1 "tls_symbolic_operand")] + (unspec:P [(match_operand 1 "tls_symbolic_operand") + (reg:P SP_REG)] UNSPEC_TLS_GD)] "TARGET_64BIT" { @@ -13261,7 +13262,8 @@ (mem:QI (plus:DI (match_operand:DI 2 "register_operand" "b") (match_operand:DI 3 "immediate_operand" "i"))) (match_operand 4))) - (unspec:DI [(match_operand 1 "tls_symbolic_operand")] + (unspec:DI [(match_operand 1 "tls_symbolic_operand") + (reg:P SP_REG)] UNSPEC_TLS_GD)] "TARGET_64BIT && ix86_cmodel == CM_LARGE_PIC && !TARGET_PECOFF && GET_CODE (operands[3]) == CONST @@ -13283,7 +13285,8 @@ (call:P (mem:QI (match_operand 2)) (const_int 0))) - (unspec:P [(match_operand 1 "tls_symbolic_operand")] + (unspec:P [(match_operand 1 "tls_symbolic_operand") + (reg:P SP_REG)] UNSPEC_TLS_GD)])] "TARGET_64BIT" "ix86_tls_descriptor_calls_expanded_in_cfun = true;") @@ -13333,7 +13336,9 @@ (call:P (mem:QI (match_operand 1 "constant_call_address_operand" "Bz")) (match_operand 2))) - (unspec:P [(const_int 0)] UNSPEC_TLS_LD_BASE)] + (unspec:P [(const_int 0) + (reg:P SP_REG)] + UNSPEC_TLS_LD_BASE)] "TARGET_64BIT" { output_asm_insn @@ -13351,7 +13356,9 @@ (mem:QI (plus:DI (match_operand:DI 1 "register_operand" "b") (match_operand:DI 2 "immediate_operand" "i"))) (match_operand 3))) - (unspec:DI [(const_int 0)] UNSPEC_TLS_LD_BASE)] + (unspec:DI [(const_int 0) + (reg:DI SP_REG)] + UNSPEC_TLS_LD_BASE)] "TARGET_64BIT && ix86_cmodel == CM_LARGE_PIC && !TARGET_PECOFF && GET_CODE (operands[2]) == CONST && GET_CODE (XEXP (operands[2], 0)) == UNSPEC @@ -13372,7 +13379,9 @@ (call:P (mem:QI (match_operand 1)) (const_int 0))) - (unspec:P [(const_int 0)] UNSPEC_TLS_LD_BASE)])] + (unspec:P [(const_int 0) + (reg:P SP_REG)] + UNSPEC_TLS_LD_BASE)])] "TARGET_64BIT" "ix86_tls_descriptor_calls_expanded_in_cfun = true;")