From: Renlin Li Date: Tue, 9 Aug 2016 17:20:14 +0000 (+0000) Subject: [PATCH][PR64971]Convert function pointer to Pmode when emit call. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=408702b44570a4c92e4f9d05cd97f98cf12a4eb4;p=gcc.git [PATCH][PR64971]Convert function pointer to Pmode when emit call. gcc/ 2016-08-04 Renlin Li PR middle-end/64971 * calls.c (prepare_call_address): Convert funexp to Pmode when necessary. * config/aarch64/aarch64.md (sibcall): Remove fix for PR 64971. (sibcall_value): Likewise. From-SVN: r239300 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index cee39a1c0c4..40537cba7e7 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2016-08-09 Renlin Li + + PR middle-end/64971 + * calls.c (prepare_call_address): Convert funexp to Pmode when + necessary. + * config/aarch64/aarch64.md (sibcall): Remove fix for PR 64971. + (sibcall_value): Likewise. + 2016-08-09 Marek Polacek PR c/7652 diff --git a/gcc/calls.c b/gcc/calls.c index 949a92e3fe3..4ad3e34d677 100644 --- a/gcc/calls.c +++ b/gcc/calls.c @@ -194,10 +194,19 @@ prepare_call_address (tree fndecl_or_type, rtx funexp, rtx static_chain_value, && targetm.small_register_classes_for_mode_p (FUNCTION_MODE)) ? force_not_mem (memory_address (FUNCTION_MODE, funexp)) : memory_address (FUNCTION_MODE, funexp)); - else if (! sibcallp) + else { - if (!NO_FUNCTION_CSE && optimize && ! flag_no_function_cse) - funexp = force_reg (Pmode, funexp); + /* funexp could be a SYMBOL_REF represents a function pointer which is + of ptr_mode. In this case, it should be converted into address mode + to be a valid address for memory rtx pattern. See PR 64971. */ + if (GET_MODE (funexp) != Pmode) + funexp = convert_memory_address (Pmode, funexp); + + if (! sibcallp) + { + if (!NO_FUNCTION_CSE && optimize && ! flag_no_function_cse) + funexp = force_reg (Pmode, funexp); + } } if (static_chain_value != 0 diff --git a/gcc/config/aarch64/aarch64.md b/gcc/config/aarch64/aarch64.md index f15dd8d8672..c95258b7103 100644 --- a/gcc/config/aarch64/aarch64.md +++ b/gcc/config/aarch64/aarch64.md @@ -859,13 +859,6 @@ || aarch64_is_noplt_call_p (callee))) XEXP (operands[0], 0) = force_reg (Pmode, callee); - /* FIXME: This is a band-aid. Need to analyze why expand_expr_addr_expr - is generating an SImode symbol reference. See PR 64971. */ - if (TARGET_ILP32 - && GET_CODE (XEXP (operands[0], 0)) == SYMBOL_REF - && GET_MODE (XEXP (operands[0], 0)) == SImode) - XEXP (operands[0], 0) = convert_memory_address (Pmode, - XEXP (operands[0], 0)); if (operands[2] == NULL_RTX) operands[2] = const0_rtx; @@ -897,14 +890,6 @@ || aarch64_is_noplt_call_p (callee))) XEXP (operands[1], 0) = force_reg (Pmode, callee); - /* FIXME: This is a band-aid. Need to analyze why expand_expr_addr_expr - is generating an SImode symbol reference. See PR 64971. */ - if (TARGET_ILP32 - && GET_CODE (XEXP (operands[1], 0)) == SYMBOL_REF - && GET_MODE (XEXP (operands[1], 0)) == SImode) - XEXP (operands[1], 0) = convert_memory_address (Pmode, - XEXP (operands[1], 0)); - if (operands[3] == NULL_RTX) operands[3] = const0_rtx;