From: Alan Modra Date: Fri, 4 Jul 2008 02:33:29 +0000 (+0000) Subject: re PR target/36634 (-msecure-plt combine gives invalid call insn) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c985ffcbed3d63cba3d884362b513e062ed16522;p=thirdparty%2Fgcc.git re PR target/36634 (-msecure-plt combine gives invalid call insn) PR target/36634 * config/rs6000/rs6000.md (call, call_value): Don't arrange for pic_offset_table_rtx to be marked as used here. (call_nonlocal_sysv, call_value_nonlocal_sysv): Add split for TARGET_SECURE_PLT to "use" pic_offset_table_rtx. (call_nonlocal_sysv_secure, call_value_nonlocal_sysv_secure): New insn. (sibcall_nonlocal_sysv, sibcall_value_nonlocal_sysv): Assert !TARGET_SECURE_PLT. From-SVN: r137449 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index fd5a9ff3f933..0ec48495f51f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,14 @@ +2008-07-04 Alan Modra + + PR target/36634 + * config/rs6000/rs6000.md (call, call_value): Don't arrange for + pic_offset_table_rtx to be marked as used here. + (call_nonlocal_sysv, call_value_nonlocal_sysv): Add split for + TARGET_SECURE_PLT to "use" pic_offset_table_rtx. + (call_nonlocal_sysv_secure, call_value_nonlocal_sysv_secure): New insn. + (sibcall_nonlocal_sysv, sibcall_value_nonlocal_sysv): Assert + !TARGET_SECURE_PLT. + 2008-06-05 Richard Sandiford * config/mips/mips.c (mips_emit_loadgp): Return early if diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md index 865690d10ab9..eab399b228f6 100644 --- a/gcc/config/rs6000/rs6000.md +++ b/gcc/config/rs6000/rs6000.md @@ -10379,25 +10379,6 @@ operands[0] = XEXP (operands[0], 0); - if (DEFAULT_ABI == ABI_V4 && TARGET_SECURE_PLT - && flag_pic - && GET_CODE (operands[0]) == SYMBOL_REF - && !SYMBOL_REF_LOCAL_P (operands[0])) - { - rtx call; - rtvec tmp; - - tmp = gen_rtvec (3, - gen_rtx_CALL (VOIDmode, - gen_rtx_MEM (SImode, operands[0]), - operands[1]), - gen_rtx_USE (VOIDmode, operands[2]), - gen_rtx_CLOBBER (VOIDmode, gen_rtx_SCRATCH (SImode))); - call = emit_call_insn (gen_rtx_PARALLEL (VOIDmode, tmp)); - use_reg (&CALL_INSN_FUNCTION_USAGE (call), pic_offset_table_rtx); - DONE; - } - if (GET_CODE (operands[0]) != SYMBOL_REF || (DEFAULT_ABI == ABI_AIX && !SYMBOL_REF_FUNCTION_P (operands[0])) || (DEFAULT_ABI != ABI_DARWIN && (INTVAL (operands[2]) & CALL_LONG) != 0)) @@ -10449,28 +10430,6 @@ operands[1] = XEXP (operands[1], 0); - if (DEFAULT_ABI == ABI_V4 && TARGET_SECURE_PLT - && flag_pic - && GET_CODE (operands[1]) == SYMBOL_REF - && !SYMBOL_REF_LOCAL_P (operands[1])) - { - rtx call; - rtvec tmp; - - tmp = gen_rtvec (3, - gen_rtx_SET (VOIDmode, - operands[0], - gen_rtx_CALL (VOIDmode, - gen_rtx_MEM (SImode, - operands[1]), - operands[2])), - gen_rtx_USE (VOIDmode, operands[3]), - gen_rtx_CLOBBER (VOIDmode, gen_rtx_SCRATCH (SImode))); - call = emit_call_insn (gen_rtx_PARALLEL (VOIDmode, tmp)); - use_reg (&CALL_INSN_FUNCTION_USAGE (call), pic_offset_table_rtx); - DONE; - } - if (GET_CODE (operands[1]) != SYMBOL_REF || (DEFAULT_ABI == ABI_AIX && !SYMBOL_REF_FUNCTION_P (operands[1])) || (DEFAULT_ABI != ABI_DARWIN && (INTVAL (operands[3]) & CALL_LONG) != 0)) @@ -10726,7 +10685,7 @@ [(set_attr "type" "jmpreg,jmpreg,jmpreg,jmpreg") (set_attr "length" "4,4,8,8")]) -(define_insn "*call_nonlocal_sysv" +(define_insn_and_split "*call_nonlocal_sysv" [(call (mem:SI (match_operand:P 0 "symbol_ref_operand" "s,s")) (match_operand 1 "" "g,g")) (use (match_operand:SI 2 "immediate_operand" "O,n")) @@ -10746,17 +10705,51 @@ #else if (DEFAULT_ABI == ABI_V4 && flag_pic) { - if (TARGET_SECURE_PLT && flag_pic == 2) - /* The magic 32768 offset here and in the other sysv call insns - corresponds to the offset of r30 in .got2, as given by LCTOC1. - See sysv4.h:toc_section. */ - return "bl %z0+32768@plt"; - else - return "bl %z0@plt"; + gcc_assert (!TARGET_SECURE_PLT); + return "bl %z0@plt"; } else return "bl %z0"; #endif +} + "DEFAULT_ABI == ABI_V4 + && TARGET_SECURE_PLT && flag_pic && !SYMBOL_REF_LOCAL_P (operands[0]) + && (INTVAL (operands[2]) & CALL_LONG) == 0" + [(parallel [(call (mem:SI (match_dup 0)) + (match_dup 1)) + (use (match_dup 2)) + (use (match_dup 3)) + (clobber (match_dup 4))])] +{ + operands[4] = operands[3]; + operands[3] = pic_offset_table_rtx; +} + [(set_attr "type" "branch,branch") + (set_attr "length" "4,8")]) + +(define_insn "*call_nonlocal_sysv_secure" + [(call (mem:SI (match_operand:P 0 "symbol_ref_operand" "s,s")) + (match_operand 1 "" "g,g")) + (use (match_operand:SI 2 "immediate_operand" "O,n")) + (use (match_operand:SI 3 "register_operand" "r,r")) + (clobber (match_scratch:SI 4 "=l,l"))] + "(DEFAULT_ABI == ABI_V4 + && TARGET_SECURE_PLT && flag_pic && !SYMBOL_REF_LOCAL_P (operands[0]) + && (INTVAL (operands[2]) & CALL_LONG) == 0)" +{ + if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS) + output_asm_insn ("crxor 6,6,6", operands); + + else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS) + output_asm_insn ("creqv 6,6,6", operands); + + if (flag_pic == 2) + /* The magic 32768 offset here and in the other sysv call insns + corresponds to the offset of r30 in .got2, as given by LCTOC1. + See sysv4.h:toc_section. */ + return "bl %z0+32768@plt"; + else + return "bl %z0@plt"; } [(set_attr "type" "branch,branch") (set_attr "length" "4,8")]) @@ -10781,7 +10774,7 @@ [(set_attr "type" "jmpreg,jmpreg,jmpreg,jmpreg") (set_attr "length" "4,4,8,8")]) -(define_insn "*call_value_nonlocal_sysv" +(define_insn_and_split "*call_value_nonlocal_sysv" [(set (match_operand 0 "" "") (call (mem:SI (match_operand:P 1 "symbol_ref_operand" "s,s")) (match_operand 2 "" "g,g"))) @@ -10802,14 +10795,50 @@ #else if (DEFAULT_ABI == ABI_V4 && flag_pic) { - if (TARGET_SECURE_PLT && flag_pic == 2) - return "bl %z1+32768@plt"; - else - return "bl %z1@plt"; + gcc_assert (!TARGET_SECURE_PLT); + return "bl %z1@plt"; } else return "bl %z1"; #endif +} + "DEFAULT_ABI == ABI_V4 + && TARGET_SECURE_PLT && flag_pic && !SYMBOL_REF_LOCAL_P (operands[1]) + && (INTVAL (operands[3]) & CALL_LONG) == 0" + [(parallel [(set (match_dup 0) + (call (mem:SI (match_dup 1)) + (match_dup 2))) + (use (match_dup 3)) + (use (match_dup 4)) + (clobber (match_dup 5))])] +{ + operands[5] = operands[4]; + operands[4] = pic_offset_table_rtx; +} + [(set_attr "type" "branch,branch") + (set_attr "length" "4,8")]) + +(define_insn "*call_value_nonlocal_sysv_secure" + [(set (match_operand 0 "" "") + (call (mem:SI (match_operand:P 1 "symbol_ref_operand" "s,s")) + (match_operand 2 "" "g,g"))) + (use (match_operand:SI 3 "immediate_operand" "O,n")) + (use (match_operand:SI 4 "register_operand" "r,r")) + (clobber (match_scratch:SI 5 "=l,l"))] + "(DEFAULT_ABI == ABI_V4 + && TARGET_SECURE_PLT && flag_pic && !SYMBOL_REF_LOCAL_P (operands[1]) + && (INTVAL (operands[3]) & CALL_LONG) == 0)" +{ + if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS) + output_asm_insn ("crxor 6,6,6", operands); + + else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS) + output_asm_insn ("creqv 6,6,6", operands); + + if (flag_pic == 2) + return "bl %z1+32768@plt"; + else + return "bl %z1@plt"; } [(set_attr "type" "branch,branch") (set_attr "length" "4,8")]) @@ -11025,10 +11054,8 @@ if (DEFAULT_ABI == ABI_V4 && flag_pic) { - if (TARGET_SECURE_PLT && flag_pic == 2) - return \"b %z0+32768@plt\"; - else - return \"b %z0@plt\"; + gcc_assert (!TARGET_SECURE_PLT); + return \"b %z0@plt\"; } else return \"b %z0\"; @@ -11079,10 +11106,8 @@ if (DEFAULT_ABI == ABI_V4 && flag_pic) { - if (TARGET_SECURE_PLT && flag_pic == 2) - return \"b %z1+32768@plt\"; - else - return \"b %z1@plt\"; + gcc_assert (!TARGET_SECURE_PLT); + return \"b %z1@plt\"; } else return \"b %z1\";