From: Ramana Radhakrishnan <ramana.radhakrishnan@foss.arm.com>
To: Christian Bruel <christian.bruel@st.com>,
Bernd Schmidt <bschmidt@redhat.com>,
"law@redhat.com" <law@redhat.com>
Cc: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>,
"Ramana.Radhakrishnan@arm.com" <Ramana.Radhakrishnan@arm.com>,
"kyrylo.tkachov@arm.com" <kyrylo.tkachov@arm.com>,
"richard.earnshaw@arm.com" <richard.earnshaw@arm.com>
Subject: Re: [PATCH ARM]: PR67745: Fix function alignment after __attribute__ 2/2
Date: Tue, 13 Oct 2015 08:03:00 -0000 [thread overview]
Message-ID: <561CBAB7.7080104@foss.arm.com> (raw)
In-Reply-To: <561B91DE.5040909@st.com>
>
> yes I see, I was hoping to avoid a new hook, but as you said it seems mandatory for the mere declaration case.
>
> Here is one proposal, it defaults to nothing and the ARM implementation does not need to handle the vptr bit setting. so that simplifies a lot the things.
>
> The hook is called from rest_of_decl_compilation for mere declarations and allocate_struct_function for definitions.
I'm not sure we have testsuite coverage for this - can you add a test or 2 ?
>
>
>
>
>
>
>
> align_hook.patch
>
>
> 2015-09-29 Christian Bruel <christian.bruel@st.com>
>
> PR target/67745
> * config/arm/arm.h (FUNCTION_BOUNDARY): Use FUNCTION_BOUNDARY_P.
> (FUNCTION_BOUNDARY_P): New macro:
> * config/arm/arm.c (TARGET_RELAYOUT_FUNCTION, arm_relayout_function):
> New hook.
The ARM changes look ok to me. Please as usual watch out for any regressions.
> * doc/tm.texi.in (TARGET_RELAYOUT_FUNCTION): Document.
> * doc/tm.texi (TARGET_RELAYOUT_FUNCTION): New hook.
> * gcc/target.def (TARGET_RELAYOUT_FUNCTION): Likewise.
> * gcc/function.c (allocate_struct_function): Call relayout_function hook.
> * gcc/passes.c (rest_of_decl_compilation): Likewise.
> * gcc/targhooks.c (default_relayout_function): New function.
> * gcc/targhooks.h (default_relayout_function): Declare.
>
> --- gnu_trunk.p0/gcc/gcc/config/arm/arm.c 2015-10-12 10:34:27.599740376 +0200
> +++ gnu_trunk.devs/gcc/gcc/config/arm/arm.c 2015-10-12 12:26:51.607398021 +0200
> @@ -250,6 +250,7 @@ static void arm_override_options_after_c
> static void arm_option_print (FILE *, int, struct cl_target_option *);
> static void arm_set_current_function (tree);
> static bool arm_can_inline_p (tree, tree);
> +static void arm_relayout_function (tree);
> static bool arm_valid_target_attribute_p (tree, tree, tree, int);
> static unsigned HOST_WIDE_INT arm_shift_truncation_mask (machine_mode);
> static bool arm_macro_fusion_p (void);
> @@ -405,6 +406,9 @@ static const struct attribute_spec arm_a
> #undef TARGET_CAN_INLINE_P
> #define TARGET_CAN_INLINE_P arm_can_inline_p
>
> +#undef TARGET_RELAYOUT_FUNCTION
> +#define TARGET_RELAYOUT_FUNCTION arm_relayout_function
> +
> #undef TARGET_OPTION_OVERRIDE
> #define TARGET_OPTION_OVERRIDE arm_option_override
>
> @@ -29825,6 +29829,23 @@ arm_can_inline_p (tree caller ATTRIBUTE_
> return true;
> }
>
> +/* Hook to fix function's alignment affected by target attribute. */
> +
> +static void
> +arm_relayout_function (tree fndecl)
> +{
> + if (DECL_USER_ALIGN (fndecl))
> + return;
> +
> + tree callee_tree = DECL_FUNCTION_SPECIFIC_TARGET (fndecl);
> +
> + if (!callee_tree)
> + callee_tree = target_option_default_node;
> +
> + DECL_ALIGN (fndecl) =
> + FUNCTION_BOUNDARY_P (TREE_TARGET_OPTION (callee_tree)->x_target_flags);
> +}
> +
> /* Inner function to process the attribute((target(...))), take an argument and
> set the current options from the argument. If we have a list, recursively
> go over the list. */
> diff '--exclude=.svn' '--exclude=*~' -r -up gnu_trunk.p0/gcc/gcc/config/arm/arm.h gnu_trunk.devs/gcc/gcc/config/arm/arm.h
> --- gnu_trunk.p0/gcc/gcc/config/arm/arm.h 2015-10-12 10:34:27.607740391 +0200
> +++ gnu_trunk.devs/gcc/gcc/config/arm/arm.h 2015-10-12 12:27:55.507546958 +0200
> @@ -565,7 +565,8 @@ extern int arm_arch_crc;
> #define PREFERRED_STACK_BOUNDARY \
> (arm_abi == ARM_ABI_ATPCS ? 64 : STACK_BOUNDARY)
>
> -#define FUNCTION_BOUNDARY (TARGET_THUMB ? 16 : 32)
> +#define FUNCTION_BOUNDARY_P(flags) (TARGET_THUMB_P (flags) ? 16 : 32)
> +#define FUNCTION_BOUNDARY (FUNCTION_BOUNDARY_P (target_flags))
>
> /* The lowest bit is used to indicate Thumb-mode functions, so the
> vbit must go into the delta field of pointers to member
> diff '--exclude=.svn' '--exclude=*~' -r -up gnu_trunk.p0/gcc/gcc/doc/tm.texi gnu_trunk.devs/gcc/gcc/doc/tm.texi
> --- gnu_trunk.p0/gcc/gcc/doc/tm.texi 2015-10-12 10:33:29.907630642 +0200
> +++ gnu_trunk.devs/gcc/gcc/doc/tm.texi 2015-10-12 12:33:33.880332253 +0200
> @@ -9985,6 +9985,10 @@ default, inlining is not allowed if the
> specific target options and the caller does not use the same options.
> @end deftypefn
>
> +@deftypefn {Target Hook} void TARGET_RELAYOUT_FUNCTION (tree @var{fndecl})
> +This target hook fixes function @var{fndecl} after attributes are processed. Default does nothing. On ARM, the default function's alignment is updated with the attribute target.
> +@end deftypefn
> +
> @node Emulated TLS
> @section Emulating TLS
> @cindex Emulated TLS
> diff '--exclude=.svn' '--exclude=*~' -r -up gnu_trunk.p0/gcc/gcc/doc/tm.texi.in gnu_trunk.devs/gcc/gcc/doc/tm.texi.in
> --- gnu_trunk.p0/gcc/gcc/doc/tm.texi.in 2015-10-12 10:33:29.919630666 +0200
> +++ gnu_trunk.devs/gcc/gcc/doc/tm.texi.in 2015-10-12 11:28:16.350590629 +0200
> @@ -7274,6 +7274,8 @@ on this implementation detail.
>
> @hook TARGET_CAN_INLINE_P
>
> +@hook TARGET_RELAYOUT_FUNCTION
> +
> @node Emulated TLS
> @section Emulating TLS
> @cindex Emulated TLS
> diff '--exclude=.svn' '--exclude=*~' -r -up gnu_trunk.p0/gcc/gcc/function.c gnu_trunk.devs/gcc/gcc/function.c
> --- gnu_trunk.p0/gcc/gcc/function.c 2015-10-12 10:33:32.715635978 +0200
> +++ gnu_trunk.devs/gcc/gcc/function.c 2015-10-12 10:04:42.764482359 +0200
> @@ -4840,6 +4840,9 @@ allocate_struct_function (tree fndecl, b
> for (tree parm = DECL_ARGUMENTS (fndecl); parm;
> parm = DECL_CHAIN (parm))
> relayout_decl (parm);
> +
> + /* Similarly relayout the function decl. */
> + targetm.target_option.relayout_function (fndecl);
> }
>
> if (!abstract_p && aggregate_value_p (result, fndecl))
> --- gnu_trunk.p0/gcc/gcc/passes.c 2015-10-05 14:22:31.082400039 +0200
> +++ gnu_trunk.devs/gcc/gcc/passes.c 2015-10-12 11:31:55.343150983 +0200
> @@ -253,6 +253,11 @@ rest_of_decl_compilation (tree decl,
> }
> #endif
>
> + /* Now that we have activated any function-specific attributes
> + that might affect function decl, particularly align, relayout it. */
> + if (TREE_CODE (decl) == FUNCTION_DECL)
> + targetm.target_option.relayout_function (decl);
> +
> timevar_pop (TV_VARCONST);
> }
> else if (TREE_CODE (decl) == TYPE_DECL
> diff '--exclude=.svn' '--exclude=*~' -r -up gnu_trunk.p0/gcc/gcc/target.def gnu_trunk.devs/gcc/gcc/target.def
> --- gnu_trunk.p0/gcc/gcc/target.def 2015-10-05 14:22:20.142374948 +0200
> +++ gnu_trunk.devs/gcc/gcc/target.def 2015-10-12 12:34:23.744447530 +0200
> @@ -5620,6 +5620,12 @@ specific target options and the caller d
> bool, (tree caller, tree callee),
> default_target_can_inline_p)
>
> +DEFHOOK
> +(relayout_function,
> +"This target hook fixes function @var{fndecl} after attributes are processed. Default does nothing. On ARM, the default function's alignment is updated with the attribute target.",
> + void, (tree fndecl),
> + default_relayout_function)
Can this just be hook_void_tree ? Then you don't need the empty default_relayout_function ?
> +
> HOOK_VECTOR_END (target_option)
>
> /* For targets that need to mark extra registers as live on entry to
> diff '--exclude=.svn' '--exclude=*~' -r -up gnu_trunk.p0/gcc/gcc/targhooks.c gnu_trunk.devs/gcc/gcc/targhooks.c
> --- gnu_trunk.p0/gcc/gcc/targhooks.c 2015-08-25 10:28:00.504946542 +0200
> +++ gnu_trunk.devs/gcc/gcc/targhooks.c 2015-10-12 11:24:50.866063124 +0200
> @@ -1311,6 +1311,11 @@ default_target_option_pragma_parse (tree
> return false;
> }
>
> +void
> +default_relayout_function (tree fndecl)
> +{
> +}
> +
> bool
> default_target_can_inline_p (tree caller, tree callee)
> {
> diff '--exclude=.svn' '--exclude=*~' -r -up gnu_trunk.p0/gcc/gcc/targhooks.h gnu_trunk.devs/gcc/gcc/targhooks.h
> --- gnu_trunk.p0/gcc/gcc/targhooks.h 2015-10-05 14:22:17.774369515 +0200
> +++ gnu_trunk.devs/gcc/gcc/targhooks.h 2015-10-12 11:24:40.914042025 +0200
> @@ -161,6 +161,7 @@ extern bool default_hard_regno_scratch_o
> extern bool default_mode_dependent_address_p (const_rtx, addr_space_t);
> extern bool default_target_option_valid_attribute_p (tree, tree, tree, int);
> extern bool default_target_option_pragma_parse (tree, tree);
> +extern void default_relayout_function (tree);
> extern bool default_target_can_inline_p (tree, tree);
> extern bool default_valid_pointer_mode (machine_mode);
> extern bool default_ref_may_alias_errno (struct ao_ref *);
>
next prev parent reply other threads:[~2015-10-13 8:03 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-29 13:44 Christian Bruel
2015-09-29 13:59 ` Christian Bruel
2015-09-30 19:30 ` Jeff Law
2015-10-01 7:12 ` Christian Bruel
2015-10-01 16:11 ` Christian Bruel
2015-10-07 7:05 ` Christian Bruel
2015-10-07 10:18 ` Bernd Schmidt
2015-10-07 10:45 ` Christian Bruel
2015-10-07 17:37 ` Bernd Schmidt
2015-10-07 17:50 ` Bernd Schmidt
2015-10-08 13:14 ` Christian Bruel
2015-10-08 13:20 ` Bernd Schmidt
2015-10-08 13:51 ` Christian Bruel
2015-10-08 14:30 ` Bernd Schmidt
2015-10-12 10:56 ` Christian Bruel
2015-10-12 11:19 ` Bernd Schmidt
2015-10-12 11:26 ` Christian Bruel
2015-10-16 8:03 ` refactoring TARGET_PTRMEMFUNC_VBIT_LOCATION checks Christian Bruel
2015-10-16 9:47 ` Bernd Schmidt
2015-10-16 10:50 ` Christian Bruel
2015-10-16 10:56 ` Bernd Schmidt
2015-10-16 10:56 ` Christian Bruel
2015-10-13 8:03 ` Ramana Radhakrishnan [this message]
2015-10-13 10:18 ` [PATCH ARM]: PR67745: Fix function alignment after __attribute__ 2/2 Christian Bruel
2015-10-16 14:18 ` Christian Bruel
2015-10-08 14:01 ` Christian Bruel
2015-10-08 14:05 ` Bernd Schmidt
2015-10-07 17:40 ` Jeff Law
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=561CBAB7.7080104@foss.arm.com \
--to=ramana.radhakrishnan@foss.arm.com \
--cc=Ramana.Radhakrishnan@arm.com \
--cc=bschmidt@redhat.com \
--cc=christian.bruel@st.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=kyrylo.tkachov@arm.com \
--cc=law@redhat.com \
--cc=richard.earnshaw@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).