From: Segher Boessenkool <segher@kernel.crashing.org>
To: gcc-patches@gcc.gnu.org
Cc: bschmidt@redhat.com, Segher Boessenkool <segher@kernel.crashing.org>
Subject: [PATCH 1/9] separate shrink-wrap: New command-line flag, status flag, hooks, and doc
Date: Mon, 01 Aug 2016 01:43:00 -0000 [thread overview]
Message-ID: <4b44888ff2f1237b364ccd0a566a4b739db0a032.1470015604.git.segher@kernel.crashing.org> (raw)
In-Reply-To: <cover.1470015604.git.segher@kernel.crashing.org>
In-Reply-To: <cover.1470015604.git.segher@kernel.crashing.org>
This patch adds a new command-line flag "-fshrink-wrap-separate", a status
flag "shrink_wrapped_separate", hooks for abstracting the target components,
and documentation for all those.
2016-06-07 Segher Boessenkool <segher@kernel.crashing.org>
* common.opt (-fshrink-wrap-separate): New flag.
* doc/invoke.texi: Document it.
* doc/tm.texi.in (Shrink-wrapping separate components): New subsection.
* doc/tm.texi: Regenerate.
* emit-rtl.h (struct rtl_data): New field shrink_wrapped_separate.
* target.def (shrink_wrap): New hook vector.
(get_separate_components, components_for_bb, disqualify_components,
emit_prologue_components, emit_epilogue_components,
set_handled_components): New hooks.
---
gcc/common.opt | 4 ++++
gcc/doc/invoke.texi | 11 ++++++++++-
gcc/doc/tm.texi | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++
gcc/doc/tm.texi.in | 29 +++++++++++++++++++++++++++
gcc/emit-rtl.h | 4 ++++
gcc/target.def | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++
6 files changed, 158 insertions(+), 1 deletion(-)
diff --git a/gcc/common.opt b/gcc/common.opt
index 8a292ed..97d305f 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -2168,6 +2168,10 @@ Common Report Var(flag_shrink_wrap) Optimization
Emit function prologues only before parts of the function that need it,
rather than at the top of the function.
+fshrink-wrap-separate
+Common Report Var(flag_shrink_wrap_separate) Init(1) Optimization
+Shrink-wrap parts of the prologue and epilogue separately.
+
fsignaling-nans
Common Report Var(flag_signaling_nans) Optimization SetByCombined
Disable optimizations observable by IEEE signaling NaNs.
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 22001f9..2ea1727 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -397,7 +397,8 @@ Objective-C and Objective-C++ Dialects}.
-fschedule-insns -fschedule-insns2 -fsection-anchors @gol
-fselective-scheduling -fselective-scheduling2 @gol
-fsel-sched-pipelining -fsel-sched-pipelining-outer-loops @gol
--fsemantic-interposition -fshrink-wrap -fsignaling-nans @gol
+-fsemantic-interposition -fshrink-wrap -fshrink-wrap-separate @gol
+-fsignaling-nans @gol
-fsingle-precision-constant -fsplit-ivs-in-unroller @gol
-fsplit-paths @gol
-fsplit-wide-types -fssa-backprop -fssa-phiopt @gol
@@ -6322,6 +6323,7 @@ compilation time.
-fmove-loop-invariants @gol
-freorder-blocks @gol
-fshrink-wrap @gol
+-fshrink-wrap-separate @gol
-fsplit-wide-types @gol
-fssa-backprop @gol
-fssa-phiopt @gol
@@ -7231,6 +7233,13 @@ Emit function prologues only before parts of the function that need it,
rather than at the top of the function. This flag is enabled by default at
@option{-O} and higher.
+@item -fshrink-wrap-separate
+@opindex fshrink-wrap-separate
+Shrink-wrap separate parts of the prologue and epilogue separately, so that
+those parts are only executed when needed.
+This option is on by default, but has no effect unless @option{-fshrink-wrap}
+is also turned on.
+
@item -fcaller-saves
@opindex fcaller-saves
Enable allocation of values to registers that are clobbered by
diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
index 9edb006..5a5c5cab 100644
--- a/gcc/doc/tm.texi
+++ b/gcc/doc/tm.texi
@@ -2924,6 +2924,7 @@ This describes the stack layout and calling conventions.
* Function Entry::
* Profiling::
* Tail Calls::
+* Shrink-wrapping separate components::
* Stack Smashing Protection::
* Miscellaneous Register Hooks::
@end menu
@@ -4852,6 +4853,59 @@ This hook should add additional registers that are computed by the prologue to t
True if a function's return statements should be checked for matching the function's return type. This includes checking for falling off the end of a non-void function. Return false if no such check should be made.
@end deftypefn
+@node Shrink-wrapping separate components
+@subsection Shrink-wrapping separate components
+@cindex shrink-wrapping separate components
+
+The prologue does a lot of separate things: save callee-saved registers,
+do whatever needs to be done to be able to call things (save the return
+address, align the stack, whatever; different for each target), set up a
+stack frame, do whatever needs to be done for the static chain (if anything),
+set up registers for PIC, etc. Using the following hooks those prologue
+or epilogue components can be shrink-wrapped separately, so that the
+initialization (and possibly teardown) those components do is not done on
+execution paths where it is unnecessary.
+
+What exactly those components are is up to the target code; the generic
+code treats them abstractly.
+
+@deftypefn {Target Hook} sbitmap TARGET_SHRINK_WRAP_GET_SEPARATE_COMPONENTS (void)
+This hook should return an @code{sbitmap} with the bits set for those
+components that can be separately shrink-wrapped in the current function.
+Return @code{NULL} if the current function should not get any separate
+shrink-wrapping.
+Don't define this hook if it would always return @code{NULL}.
+If it is defined, the other hooks in this group have to be defined as well.
+@end deftypefn
+
+@deftypefn {Target Hook} sbitmap TARGET_SHRINK_WRAP_COMPONENTS_FOR_BB (basic_block)
+This hook should return an @code{sbitmap} with the bits set for those
+components where either the prologue component has to be executed before
+the @code{basic_block}, or the epilogue component after it, or both.
+@end deftypefn
+
+@deftypefn {Target Hook} void TARGET_SHRINK_WRAP_DISQUALIFY_COMPONENTS (sbitmap @var{components}, edge @var{e}, sbitmap @var{edge_components}, bool @var{is_prologue})
+This hook should clear the bits in the @var{components} bitmap for those
+components in @var{edge_components} that the target cannot handle on edge
+@var{e}, where @var{is_prologue} says if this is for a prologue or an
+epilogue instead.
+@end deftypefn
+
+@deftypefn {Target Hook} void TARGET_SHRINK_WRAP_EMIT_PROLOGUE_COMPONENTS (sbitmap)
+Emit prologue insns for the components indicated by the parameter.
+@end deftypefn
+
+@deftypefn {Target Hook} void TARGET_SHRINK_WRAP_EMIT_EPILOGUE_COMPONENTS (sbitmap)
+Emit epilogue insns for the components indicated by the parameter.
+@end deftypefn
+
+@deftypefn {Target Hook} void TARGET_SHRINK_WRAP_SET_HANDLED_COMPONENTS (sbitmap)
+Mark the components in the parameter as handled, so that the
+@code{prologue} and @code{epilogue} named patterns know to ignore those
+components. The target code should not hang on to the @code{sbitmap}, it
+will be deleted after this call.
+@end deftypefn
+
@node Stack Smashing Protection
@subsection Stack smashing protection
@cindex stack smashing protection
diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in
index a72c3d8..aaa11e6 100644
--- a/gcc/doc/tm.texi.in
+++ b/gcc/doc/tm.texi.in
@@ -2530,6 +2530,7 @@ This describes the stack layout and calling conventions.
* Function Entry::
* Profiling::
* Tail Calls::
+* Shrink-wrapping separate components::
* Stack Smashing Protection::
* Miscellaneous Register Hooks::
@end menu
@@ -3789,6 +3790,34 @@ the function prologue. Normally, the profiling code comes after.
@hook TARGET_WARN_FUNC_RETURN
+@node Shrink-wrapping separate components
+@subsection Shrink-wrapping separate components
+@cindex shrink-wrapping separate components
+
+The prologue does a lot of separate things: save callee-saved registers,
+do whatever needs to be done to be able to call things (save the return
+address, align the stack, whatever; different for each target), set up a
+stack frame, do whatever needs to be done for the static chain (if anything),
+set up registers for PIC, etc. Using the following hooks those prologue
+or epilogue components can be shrink-wrapped separately, so that the
+initialization (and possibly teardown) those components do is not done on
+execution paths where it is unnecessary.
+
+What exactly those components are is up to the target code; the generic
+code treats them abstractly.
+
+@hook TARGET_SHRINK_WRAP_GET_SEPARATE_COMPONENTS
+
+@hook TARGET_SHRINK_WRAP_COMPONENTS_FOR_BB
+
+@hook TARGET_SHRINK_WRAP_DISQUALIFY_COMPONENTS
+
+@hook TARGET_SHRINK_WRAP_EMIT_PROLOGUE_COMPONENTS
+
+@hook TARGET_SHRINK_WRAP_EMIT_EPILOGUE_COMPONENTS
+
+@hook TARGET_SHRINK_WRAP_SET_HANDLED_COMPONENTS
+
@node Stack Smashing Protection
@subsection Stack smashing protection
@cindex stack smashing protection
diff --git a/gcc/emit-rtl.h b/gcc/emit-rtl.h
index 39dfce9..001f775 100644
--- a/gcc/emit-rtl.h
+++ b/gcc/emit-rtl.h
@@ -254,6 +254,10 @@ struct GTY(()) rtl_data {
/* True if we performed shrink-wrapping for the current function. */
bool shrink_wrapped;
+ /* True if we performed shrink-wrapping for separate components for
+ the current function. */
+ bool shrink_wrapped_separate;
+
/* Nonzero if function being compiled doesn't modify the stack pointer
(ignoring the prologue and epilogue). This is only valid after
pass_stack_ptr_mod has run. */
diff --git a/gcc/target.def b/gcc/target.def
index 929d9ea..b951aec 100644
--- a/gcc/target.def
+++ b/gcc/target.def
@@ -5773,6 +5773,63 @@ DEFHOOK
bool, (tree),
hook_bool_tree_true)
+#undef HOOK_PREFIX
+#define HOOK_PREFIX "TARGET_SHRINK_WRAP_"
+HOOK_VECTOR (TARGET_SHRINK_WRAP_HOOKS, shrink_wrap)
+
+DEFHOOK
+(get_separate_components,
+ "This hook should return an @code{sbitmap} with the bits set for those\n\
+components that can be separately shrink-wrapped in the current function.\n\
+Return @code{NULL} if the current function should not get any separate\n\
+shrink-wrapping.\n\
+Don't define this hook if it would always return @code{NULL}.\n\
+If it is defined, the other hooks in this group have to be defined as well.",
+ sbitmap, (void),
+ NULL)
+
+DEFHOOK
+(components_for_bb,
+ "This hook should return an @code{sbitmap} with the bits set for those\n\
+components where either the prologue component has to be executed before\n\
+the @code{basic_block}, or the epilogue component after it, or both.",
+ sbitmap, (basic_block),
+ NULL)
+
+DEFHOOK
+(disqualify_components,
+ "This hook should clear the bits in the @var{components} bitmap for those\n\
+components in @var{edge_components} that the target cannot handle on edge\n\
+@var{e}, where @var{is_prologue} says if this is for a prologue or an\n\
+epilogue instead.",
+ void, (sbitmap components, edge e, sbitmap edge_components, bool is_prologue),
+ NULL)
+
+DEFHOOK
+(emit_prologue_components,
+ "Emit prologue insns for the components indicated by the parameter.",
+ void, (sbitmap),
+ NULL)
+
+DEFHOOK
+(emit_epilogue_components,
+ "Emit epilogue insns for the components indicated by the parameter.",
+ void, (sbitmap),
+ NULL)
+
+DEFHOOK
+(set_handled_components,
+ "Mark the components in the parameter as handled, so that the\n\
+@code{prologue} and @code{epilogue} named patterns know to ignore those\n\
+components. The target code should not hang on to the @code{sbitmap}, it\n\
+will be deleted after this call.",
+ void, (sbitmap),
+ NULL)
+
+HOOK_VECTOR_END (shrink_wrap)
+#undef HOOK_PREFIX
+#define HOOK_PREFIX "TARGET_"
+
/* Determine the type of unwind info to emit for debugging. */
DEFHOOK
(debug_unwind_info,
--
1.9.3
next prev parent reply other threads:[~2016-08-01 1:43 UTC|newest]
Thread overview: 74+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-01 1:43 [PATCH v2 0/9] Separate shrink-wrapping Segher Boessenkool
2016-08-01 1:43 ` [PATCH 3/9] dce: Don't dead-code delete separately wrapped restores Segher Boessenkool
2016-09-08 17:52 ` Jeff Law
2016-09-09 15:59 ` Segher Boessenkool
2016-09-09 16:39 ` Jeff Law
2016-08-01 1:43 ` [PATCH 2/9] cfgcleanup: Don't confuse CFI when -fshrink-wrap-separate Segher Boessenkool
2016-09-08 17:51 ` Jeff Law
2016-08-01 1:43 ` Segher Boessenkool [this message]
2016-08-29 9:31 ` [PATCH 1/9] separate shrink-wrap: New command-line flag, status flag, hooks, and doc Bernd Schmidt
2016-08-29 14:30 ` Segher Boessenkool
2016-09-08 17:37 ` Jeff Law
2016-09-09 11:03 ` Bernd Schmidt
2016-09-09 15:13 ` Segher Boessenkool
2016-09-09 18:31 ` Jeff Law
2016-09-09 20:41 ` Segher Boessenkool
2016-09-12 16:49 ` Jeff Law
2016-09-09 15:51 ` Jeff Law
2016-09-09 15:40 ` Segher Boessenkool
2016-09-09 16:58 ` Jeff Law
2016-09-08 17:48 ` Jeff Law
2016-09-09 15:44 ` Segher Boessenkool
2016-08-01 1:57 ` [PATCH 4/9] regrename: Don't rename restores Segher Boessenkool
2016-09-08 17:54 ` Jeff Law
2016-09-09 21:05 ` Segher Boessenkool
2016-09-12 17:01 ` Jeff Law
2016-08-01 1:57 ` [PATCH 8/9] shrink-wrap: shrink-wrapping for separate components Segher Boessenkool
2016-09-08 19:03 ` Jeff Law
2016-09-09 22:03 ` Segher Boessenkool
2016-09-12 18:21 ` Jeff Law
2016-09-14 13:45 ` Segher Boessenkool
2016-09-15 16:47 ` Jeff Law
2016-08-01 1:57 ` [PATCH 9/9] rs6000: Separate shrink-wrapping Segher Boessenkool
2016-08-01 1:57 ` [PATCH 7/9] cprop: Leave RTX_FRAME_RELATED_P instructions alone Segher Boessenkool
2016-09-08 18:34 ` Jeff Law
2016-09-09 21:21 ` Segher Boessenkool
2016-08-01 2:12 ` [PATCH 5/9] regrename: Don't run if function was separately shrink-wrapped Segher Boessenkool
2016-09-08 17:54 ` Jeff Law
2016-08-01 2:12 ` [PATCH 6/9] sel-sched: Don't mess with register restores Segher Boessenkool
2016-08-04 7:33 ` Andrey Belevantsev
2016-09-08 17:55 ` Jeff Law
2016-09-09 21:13 ` Segher Boessenkool
2016-09-12 17:39 ` Jeff Law
2016-09-14 13:28 ` Segher Boessenkool
2016-08-04 0:05 ` [PATCH v2 0/9] Separate shrink-wrapping Segher Boessenkool
2016-08-24 16:04 ` Segher Boessenkool
2016-08-26 13:03 ` Bernd Schmidt
2016-08-26 13:48 ` David Malcolm
2016-08-26 13:55 ` Bernd Schmidt
2016-08-26 14:50 ` Segher Boessenkool
2016-08-26 15:03 ` Bernd Schmidt
2016-08-26 16:27 ` Segher Boessenkool
2016-09-08 16:58 ` Jeff Law
2016-09-09 15:26 ` Segher Boessenkool
2016-09-09 16:26 ` Jeff Law
2016-09-09 16:51 ` Segher Boessenkool
2016-09-09 17:22 ` Jeff Law
2016-08-30 12:31 ` Michael Matz
2016-09-08 16:41 ` Jeff Law
2016-09-09 6:31 ` Segher Boessenkool
2016-09-09 15:28 ` Jeff Law
2016-09-09 15:43 ` Segher Boessenkool
2016-09-09 18:25 ` Jeff Law
2016-09-09 20:29 ` Segher Boessenkool
2016-09-08 17:20 ` Jeff Law
2016-09-09 15:33 ` Segher Boessenkool
2016-09-09 16:49 ` Jeff Law
2016-09-09 17:00 ` Segher Boessenkool
2016-09-09 17:44 ` Jeff Law
2016-09-09 19:36 ` Jeff Law
2016-09-09 21:00 ` Segher Boessenkool
2016-09-12 11:00 ` Bernd Schmidt
2016-09-12 16:59 ` Jeff Law
2016-09-14 13:22 ` Segher Boessenkool
-- strict thread matches above, loose matches on Subject: below --
2016-06-08 1:48 [PATCH 0/9] separate shrink-wrapping Segher Boessenkool
2016-06-08 1:48 ` [PATCH 1/9] separate shrink-wrap: New command-line flag, status flag, hooks, and doc Segher Boessenkool
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=4b44888ff2f1237b364ccd0a566a4b739db0a032.1470015604.git.segher@kernel.crashing.org \
--to=segher@kernel.crashing.org \
--cc=bschmidt@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
/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).