Re: [COMMITTED 1/3] Make TARGET_STATIC_CHAIN allow a function type
On 11/19/2014 08:56 PM, H.J. Lu wrote: On Wed, Nov 19, 2014 at 10:04 AM, Jakub Jelinek ja...@redhat.com wrote: On Wed, Nov 19, 2014 at 03:58:50PM +0100, Richard Henderson wrote: As opposed to always being a decl. This is a prerequisite to allowing the static chain to be loaded for indirect calls. * targhooks.c (default_static_chain): Remove check for DECL_STATIC_CHAIN. * config/moxie/moxie.c (moxie_static_chain): Likewise. * config/i386/i386.c (ix86_static_chain): Allow decl or type as the first argument. * config/xtensa/xtensa.c (xtensa_static_chain): Change the name of the unused first parameter. * doc/tm.texi (TARGET_STATIC_CHAIN): Document the first parameter may be a type. * target.def (static_chain): Likewise. r217769 broke lots of tests on i686-linux... Guh. I thought I tested both multilibs from x86_64, but I guess not. Anyway, fixed as the comment describes. r~ PR target/63977 * config/i386/i386.c (ix86_static_chain): Reinstate the check for DECL_STATIC_CHAIN. diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index fffddfc..6c8dbd6 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -27360,6 +27360,12 @@ ix86_static_chain (const_tree fndecl_or_type, bool incoming_p) { unsigned regno; + /* While this function won't be called by the middle-end when a static + chain isn't needed, it's also used throughout the backend so it's + easiest to keep this check centralized. */ + if (DECL_P (fndecl_or_type) !DECL_STATIC_CHAIN (fndecl_or_type)) +return NULL; + if (TARGET_64BIT) { /* We always use R10 in 64-bit mode. */
[COMMITTED 1/3] Make TARGET_STATIC_CHAIN allow a function type
As opposed to always being a decl. This is a prerequisite to allowing the static chain to be loaded for indirect calls. * targhooks.c (default_static_chain): Remove check for DECL_STATIC_CHAIN. * config/moxie/moxie.c (moxie_static_chain): Likewise. * config/i386/i386.c (ix86_static_chain): Allow decl or type as the first argument. * config/xtensa/xtensa.c (xtensa_static_chain): Change the name of the unused first parameter. * doc/tm.texi (TARGET_STATIC_CHAIN): Document the first parameter may be a type. * target.def (static_chain): Likewise. --- gcc/ChangeLog | 13 + gcc/config/i386/i386.c | 19 +-- gcc/config/moxie/moxie.c | 5 + gcc/config/xtensa/xtensa.c | 2 +- gcc/doc/tm.texi| 2 +- gcc/target.def | 6 +++--- gcc/targhooks.c| 5 + 7 files changed, 33 insertions(+), 19 deletions(-) diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 3166e03..3b41de2 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -27356,13 +27356,10 @@ ix86_minimum_alignment (tree exp, machine_mode mode, This is a register, unless all free registers are used by arguments. */ static rtx -ix86_static_chain (const_tree fndecl, bool incoming_p) +ix86_static_chain (const_tree fndecl_or_type, bool incoming_p) { unsigned regno; - if (!DECL_STATIC_CHAIN (fndecl)) -return NULL; - if (TARGET_64BIT) { /* We always use R10 in 64-bit mode. */ @@ -27370,13 +27367,23 @@ ix86_static_chain (const_tree fndecl, bool incoming_p) } else { - tree fntype; + const_tree fntype, fndecl; unsigned int ccvt; /* By default in 32-bit mode we use ECX to pass the static chain. */ regno = CX_REG; - fntype = TREE_TYPE (fndecl); + if (TREE_CODE (fndecl_or_type) == FUNCTION_DECL) + { + fntype = TREE_TYPE (fndecl_or_type); + fndecl = fndecl_or_type; + } + else + { + fntype = fndecl_or_type; + fndecl = NULL; + } + ccvt = ix86_get_callcvt (fntype); if ((ccvt IX86_CALLCVT_FASTCALL) != 0) { diff --git a/gcc/config/moxie/moxie.c b/gcc/config/moxie/moxie.c index d4688d9..148d26b 100644 --- a/gcc/config/moxie/moxie.c +++ b/gcc/config/moxie/moxie.c @@ -528,13 +528,10 @@ moxie_arg_partial_bytes (cumulative_args_t cum_v, /* Worker function for TARGET_STATIC_CHAIN. */ static rtx -moxie_static_chain (const_tree fndecl, bool incoming_p) +moxie_static_chain (const_tree ARG_UNUSED (fndecl_or_type), bool incoming_p) { rtx addr, mem; - if (!DECL_STATIC_CHAIN (fndecl)) -return NULL; - if (incoming_p) addr = plus_constant (Pmode, arg_pointer_rtx, 2 * UNITS_PER_WORD); else diff --git a/gcc/config/xtensa/xtensa.c b/gcc/config/xtensa/xtensa.c index 159a1a7..a0025a5 100644 --- a/gcc/config/xtensa/xtensa.c +++ b/gcc/config/xtensa/xtensa.c @@ -3626,7 +3626,7 @@ xtensa_function_value_regno_p (const unsigned int regno) expressions that denote where they are stored. */ static rtx -xtensa_static_chain (const_tree ARG_UNUSED (fndecl), bool incoming_p) +xtensa_static_chain (const_tree ARG_UNUSED (fndecl_or_type), bool incoming_p) { rtx base = incoming_p ? arg_pointer_rtx : stack_pointer_rtx; return gen_frame_mem (Pmode, plus_constant (Pmode, base, diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index 0d3a9fd..5b9da47 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi @@ -3462,7 +3462,7 @@ If the static chain is passed in memory, these macros should not be defined; instead, the @code{TARGET_STATIC_CHAIN} hook should be used. @end defmac -@deftypefn {Target Hook} rtx TARGET_STATIC_CHAIN (const_tree @var{fndecl}, bool @var{incoming_p}) +@deftypefn {Target Hook} rtx TARGET_STATIC_CHAIN (const_tree @var{fndecl_or_type}, bool @var{incoming_p}) This hook replaces the use of @code{STATIC_CHAIN_REGNUM} et al for targets that may use different static chain locations for different nested functions. This may be required if the target has function diff --git a/gcc/target.def b/gcc/target.def index bc5160d..dc48ae6 100644 --- a/gcc/target.def +++ b/gcc/target.def @@ -4516,8 +4516,8 @@ false for naked functions. The default implementation always returns true., bool, (void), hook_bool_void_true) -/* Return an rtx for the static chain for FNDECL. If INCOMING_P is true, - then it should be for the callee; otherwise for the caller. */ +/* Return an rtx for the static chain for FNDECL_OR_TYPE. If INCOMING_P + is true, then it should be for the callee; otherwise for the caller. */ DEFHOOK (static_chain, This hook replaces the use of @code{STATIC_CHAIN_REGNUM} et al for\n\ @@ -4539,7 +4539,7 @@ will be at an offset from the frame pointer.\n\ The variables @code{stack_pointer_rtx}, @code{frame_pointer_rtx}, and\n\ @code{arg_pointer_rtx} will have been
Re: [COMMITTED 1/3] Make TARGET_STATIC_CHAIN allow a function type
On 11/19/14 07:58, Richard Henderson wrote: As opposed to always being a decl. This is a prerequisite to allowing the static chain to be loaded for indirect calls. * targhooks.c (default_static_chain): Remove check for DECL_STATIC_CHAIN. * config/moxie/moxie.c (moxie_static_chain): Likewise. * config/i386/i386.c (ix86_static_chain): Allow decl or type as the first argument. * config/xtensa/xtensa.c (xtensa_static_chain): Change the name of the unused first parameter. * doc/tm.texi (TARGET_STATIC_CHAIN): Document the first parameter may be a type. * target.def (static_chain): Likewise. [ ... ] - fntype = TREE_TYPE (fndecl); + if (TREE_CODE (fndecl_or_type) == FUNCTION_DECL) + { + fntype = TREE_TYPE (fndecl_or_type); + fndecl = fndecl_or_type; + } + else + { + fntype = fndecl_or_type; + fndecl = NULL; + } + Looks like there's some spaces vs tabs goof in the true arm of that conditional. With that nit fixed, this is OK. jeff
Re: [COMMITTED 1/3] Make TARGET_STATIC_CHAIN allow a function type
On Wed, Nov 19, 2014 at 03:58:50PM +0100, Richard Henderson wrote: As opposed to always being a decl. This is a prerequisite to allowing the static chain to be loaded for indirect calls. * targhooks.c (default_static_chain): Remove check for DECL_STATIC_CHAIN. * config/moxie/moxie.c (moxie_static_chain): Likewise. * config/i386/i386.c (ix86_static_chain): Allow decl or type as the first argument. * config/xtensa/xtensa.c (xtensa_static_chain): Change the name of the unused first parameter. * doc/tm.texi (TARGET_STATIC_CHAIN): Document the first parameter may be a type. * target.def (static_chain): Likewise. r217769 broke lots of tests on i686-linux, haven't verified if everything below is caused by this, but regparm-1.c at -m32 certainly is. The ICE is: regparm-1.c: In function ‘test_realigned’: regparm-1.c:49:1: internal compiler error: in ix86_expand_prologue, at config/i386/i386.c:11347 } ^ 0x106140a ix86_expand_prologue() ../../gcc/config/i386/i386.c:11347 0x11aaf2a gen_prologue() ../../gcc/config/i386/i386.md:12095 0x99baf9 thread_prologue_and_epilogue_insns() ../../gcc/function.c:5911 0x99cba4 rest_of_handle_thread_prologue_and_epilogue ../../gcc/function.c:6481 0x99cc0c execute ../../gcc/function.c:6519 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See http://gcc.gnu.org/bugs.html for instructions. +FAIL: gcc.dg/pr36015.c (internal compiler error) +FAIL: gcc.dg/pr36015.c (test for excess errors) +UNRESOLVED: gcc.dg/pr36015.c compilation failed to produce executable +FAIL: gcc.dg/torture/stackalign/regparm-1.c -O0 (internal compiler error) +FAIL: gcc.dg/torture/stackalign/regparm-1.c -O0 (test for excess errors) +UNRESOLVED: gcc.dg/torture/stackalign/regparm-1.c -O0 compilation failed to produce executable +FAIL: gcc.dg/torture/stackalign/regparm-1.c -O0 -fpic (internal compiler error) +FAIL: gcc.dg/torture/stackalign/regparm-1.c -O0 -fpic (test for excess errors) +UNRESOLVED: gcc.dg/torture/stackalign/regparm-1.c -O0 -fpic compilation failed to produce executable +FAIL: gcc.dg/torture/stackalign/regparm-1.c -O0 -mforce-drap (internal compiler error) +FAIL: gcc.dg/torture/stackalign/regparm-1.c -O0 -mforce-drap (test for excess errors) +FAIL: gcc.dg/torture/stackalign/regparm-1.c -O0 -mforce-drap -fpic (internal compiler error) +FAIL: gcc.dg/torture/stackalign/regparm-1.c -O0 -mforce-drap -fpic (test for excess errors) +UNRESOLVED: gcc.dg/torture/stackalign/regparm-1.c -O0 -mforce-drap -fpic compilation failed to produce executable +UNRESOLVED: gcc.dg/torture/stackalign/regparm-1.c -O0 -mforce-drap compilation failed to produce executable +FAIL: gcc.dg/torture/stackalign/regparm-1.c -O1 -fpic (internal compiler error) +FAIL: gcc.dg/torture/stackalign/regparm-1.c -O1 -fpic (test for excess errors) +UNRESOLVED: gcc.dg/torture/stackalign/regparm-1.c -O1 -fpic compilation failed to produce executable +FAIL: gcc.dg/torture/stackalign/regparm-1.c -O1 -mforce-drap -fpic (internal compiler error) +FAIL: gcc.dg/torture/stackalign/regparm-1.c -O1 -mforce-drap -fpic (test for excess errors) +UNRESOLVED: gcc.dg/torture/stackalign/regparm-1.c -O1 -mforce-drap -fpic compilation failed to produce executable +FAIL: gcc.dg/torture/stackalign/regparm-1.c -O2 -flto -flto-partition=none -fpic (internal compiler error) +FAIL: gcc.dg/torture/stackalign/regparm-1.c -O2 -flto -flto-partition=none -fpic (test for excess errors) +UNRESOLVED: gcc.dg/torture/stackalign/regparm-1.c -O2 -flto -flto-partition=none -fpic compilation failed to produce executable +FAIL: gcc.dg/torture/stackalign/regparm-1.c -O2 -flto -flto-partition=none -mforce-drap -fpic (internal compiler error) +FAIL: gcc.dg/torture/stackalign/regparm-1.c -O2 -flto -flto-partition=none -mforce-drap -fpic (test for excess errors) +UNRESOLVED: gcc.dg/torture/stackalign/regparm-1.c -O2 -flto -flto-partition=none -mforce-drap -fpic compilation failed to produce executable +FAIL: gcc.dg/torture/stackalign/regparm-1.c -O2 -flto -fpic (internal compiler error) +FAIL: gcc.dg/torture/stackalign/regparm-1.c -O2 -flto -fpic (test for excess errors) +UNRESOLVED: gcc.dg/torture/stackalign/regparm-1.c -O2 -flto -fpic compilation failed to produce executable +FAIL: gcc.dg/torture/stackalign/regparm-1.c -O2 -flto -mforce-drap -fpic (internal compiler error) +FAIL: gcc.dg/torture/stackalign/regparm-1.c -O2 -flto -mforce-drap -fpic (test for excess errors) +UNRESOLVED: gcc.dg/torture/stackalign/regparm-1.c -O2 -flto -mforce-drap -fpic compilation failed to produce executable +FAIL: gcc.dg/torture/stackalign/regparm-1.c -O2 -fpic (internal compiler error) +FAIL: gcc.dg/torture/stackalign/regparm-1.c -O2 -fpic (test for excess errors) +UNRESOLVED:
Re: [COMMITTED 1/3] Make TARGET_STATIC_CHAIN allow a function type
On Wed, Nov 19, 2014 at 10:04 AM, Jakub Jelinek ja...@redhat.com wrote: On Wed, Nov 19, 2014 at 03:58:50PM +0100, Richard Henderson wrote: As opposed to always being a decl. This is a prerequisite to allowing the static chain to be loaded for indirect calls. * targhooks.c (default_static_chain): Remove check for DECL_STATIC_CHAIN. * config/moxie/moxie.c (moxie_static_chain): Likewise. * config/i386/i386.c (ix86_static_chain): Allow decl or type as the first argument. * config/xtensa/xtensa.c (xtensa_static_chain): Change the name of the unused first parameter. * doc/tm.texi (TARGET_STATIC_CHAIN): Document the first parameter may be a type. * target.def (static_chain): Likewise. r217769 broke lots of tests on i686-linux, haven't verified if everything below is caused by this, but regparm-1.c at -m32 certainly is. The ICE is: regparm-1.c: In function ‘test_realigned’: regparm-1.c:49:1: internal compiler error: in ix86_expand_prologue, at config/i386/i386.c:11347 } ^ 0x106140a ix86_expand_prologue() ../../gcc/config/i386/i386.c:11347 0x11aaf2a gen_prologue() ../../gcc/config/i386/i386.md:12095 0x99baf9 thread_prologue_and_epilogue_insns() ../../gcc/function.c:5911 0x99cba4 rest_of_handle_thread_prologue_and_epilogue ../../gcc/function.c:6481 0x99cc0c execute ../../gcc/function.c:6519 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See http://gcc.gnu.org/bugs.html for instructions. I opened: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63977 H.J.