Commit a1f427e9 by Ian Lance Taylor Committed by Ian Lance Taylor

opts.c (finish_options): If -fsplit-stack, disable implicit -forder-blocks-and-partition.

gcc/:
	* opts.c (finish_options): If -fsplit-stack, disable implicit
	-forder-blocks-and-partition.
	* doc/invoke.texi (Optimize Options): Document that when using
	-fsplit-stack -forder-blocks-and-partition is not implicitly
	enabled.
gcc/go/:
	* go-lang.c (go_langhook_post_options): If -fsplit-stack is turned
	on, disable implicit -forder-blocks-and-partition.
gcc/testsuite/:
	* gcc.dg/tree-prof/split-1.c: New test.

From-SVN: r249071
parent cb59f689
2017-06-9 Ian Lance Taylor <iant@golang.org>
* opts.c (finish_options): If -fsplit-stack, disable implicit
-forder-blocks-and-partition.
* doc/invoke.texi (Optimize Options): Document that when using
-fsplit-stack -forder-blocks-and-partition is not implicitly
enabled.
2017-06-09 Jan Hubicka <hubicka@ucw.cz> 2017-06-09 Jan Hubicka <hubicka@ucw.cz>
* builtin-attrs.def (ATTR_NORETURN_NOTHROW_LEAF_COLD_LIST, * builtin-attrs.def (ATTR_NORETURN_NOTHROW_LEAF_COLD_LIST,
......
...@@ -8656,7 +8656,9 @@ paging and cache locality performance. ...@@ -8656,7 +8656,9 @@ paging and cache locality performance.
This optimization is automatically turned off in the presence of This optimization is automatically turned off in the presence of
exception handling, for linkonce sections, for functions with a user-defined exception handling, for linkonce sections, for functions with a user-defined
section attribute and on any architecture that does not support named section attribute and on any architecture that does not support named
sections. sections. When @option{-fsplit-stack} is used this option is not
enabled by default (to avoid linker errors), but may be enabled
explicitly (if using a working linker).
Enabled for x86 at levels @option{-O2}, @option{-O3}. Enabled for x86 at levels @option{-O2}, @option{-O3}.
......
2017-06-09 Ian Lance Taylor <iant@golang.org>
* go-lang.c (go_langhook_post_options): If -fsplit-stack is turned
on, disable implicit -forder-blocks-and-partition.
2017-05-12 Than McIntosh <thanm@google.com> 2017-05-12 Than McIntosh <thanm@google.com>
* go-gcc.cc (Gcc_backend::call_expression): Add caller parameter. * go-gcc.cc (Gcc_backend::call_expression): Add caller parameter.
......
...@@ -304,6 +304,15 @@ go_langhook_post_options (const char **pfilename ATTRIBUTE_UNUSED) ...@@ -304,6 +304,15 @@ go_langhook_post_options (const char **pfilename ATTRIBUTE_UNUSED)
&& targetm_common.supports_split_stack (false, &global_options)) && targetm_common.supports_split_stack (false, &global_options))
global_options.x_flag_split_stack = 1; global_options.x_flag_split_stack = 1;
/* If stack splitting is turned on, and the user did not explicitly
request function partitioning, turn off partitioning, as it
confuses the linker when trying to handle partitioned split-stack
code that calls a non-split-stack function. */
if (global_options.x_flag_split_stack
&& global_options.x_flag_reorder_blocks_and_partition
&& !global_options_set.x_flag_reorder_blocks_and_partition)
global_options.x_flag_reorder_blocks_and_partition = 0;
/* Returning false means that the backend should be used. */ /* Returning false means that the backend should be used. */
return false; return false;
} }
......
...@@ -863,6 +863,16 @@ finish_options (struct gcc_options *opts, struct gcc_options *opts_set, ...@@ -863,6 +863,16 @@ finish_options (struct gcc_options *opts, struct gcc_options *opts_set,
opts->x_flag_reorder_blocks = 1; opts->x_flag_reorder_blocks = 1;
} }
/* If stack splitting is turned on, and the user did not explicitly
request function partitioning, turn off partitioning, as it
confuses the linker when trying to handle partitioned split-stack
code that calls a non-split-stack functions. But if partitioning
was turned on explicitly just hope for the best. */
if (opts->x_flag_split_stack
&& opts->x_flag_reorder_blocks_and_partition
&& !opts_set->x_flag_reorder_blocks_and_partition)
opts->x_flag_reorder_blocks_and_partition = 0;
if (opts->x_flag_reorder_blocks_and_partition if (opts->x_flag_reorder_blocks_and_partition
&& !opts_set->x_flag_reorder_functions) && !opts_set->x_flag_reorder_functions)
opts->x_flag_reorder_functions = 1; opts->x_flag_reorder_functions = 1;
......
2017-06-09 Ian Lance Taylor <iant@golang.org>
* gcc.dg/tree-prof/split-1.c: New test.
2017-06-09 Jan Hubicka <hubicka@ucw.cz> 2017-06-09 Jan Hubicka <hubicka@ucw.cz>
* gcc.dg/predict-14.c: Avoid cold function detection. * gcc.dg/predict-14.c: Avoid cold function detection.
......
/* Test case that we don't get a link-time error when using
-fsplit-stack with -freorder-blocks-and-partition. */
/* { dg-require-effective-target freorder } */
/* { dg-options "-O2 -fsplit-stack" } */
extern unsigned int sleep (unsigned int);
#define SIZE 10000
const char *sarr[SIZE];
const char *buf_hot;
const char *buf_cold;
__attribute__((noinline))
void
foo (int path)
{
int i;
if (path)
{
for (i = 0; i < SIZE; i++)
sarr[i] = buf_hot;
}
else
{
for (i = 0; i < SIZE; i++)
sarr[i] = buf_cold;
sleep (0);
}
}
int
main (int argc, char *argv[])
{
int i;
buf_hot = "hello";
buf_cold = "world";
for (i = 0; i < 1000000; i++)
foo (argc);
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment