aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2017-06-09 18:44:28 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2017-06-09 18:44:28 +0000
commita1f427e9a5750602aca0419f947d1612729b5793 (patch)
treecc12d6764d5fc554e61f0f5dafc58ce91099a908 /gcc
parentcb59f689a37fc39178b9ac5fa595c63b3d7eddc0 (diff)
downloadgcc-a1f427e9a5750602aca0419f947d1612729b5793.zip
gcc-a1f427e9a5750602aca0419f947d1612729b5793.tar.gz
gcc-a1f427e9a5750602aca0419f947d1612729b5793.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/doc/invoke.texi4
-rw-r--r--gcc/go/ChangeLog5
-rw-r--r--gcc/go/go-lang.c9
-rw-r--r--gcc/opts.c10
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.dg/tree-prof/split-1.c41
7 files changed, 80 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 866f3ab..9cbae2a 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+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>
* builtin-attrs.def (ATTR_NORETURN_NOTHROW_LEAF_COLD_LIST,
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index c116882..5d41649 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -8656,7 +8656,9 @@ paging and cache locality performance.
This optimization is automatically turned off in the presence of
exception handling, for linkonce sections, for functions with a user-defined
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}.
diff --git a/gcc/go/ChangeLog b/gcc/go/ChangeLog
index 59b4e6e..ac0dbe3 100644
--- a/gcc/go/ChangeLog
+++ b/gcc/go/ChangeLog
@@ -1,3 +1,8 @@
+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>
* go-gcc.cc (Gcc_backend::call_expression): Add caller parameter.
diff --git a/gcc/go/go-lang.c b/gcc/go/go-lang.c
index 780d737..09e4fea 100644
--- a/gcc/go/go-lang.c
+++ b/gcc/go/go-lang.c
@@ -304,6 +304,15 @@ go_langhook_post_options (const char **pfilename ATTRIBUTE_UNUSED)
&& targetm_common.supports_split_stack (false, &global_options))
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. */
return false;
}
diff --git a/gcc/opts.c b/gcc/opts.c
index ac409f4..5ec9980 100644
--- a/gcc/opts.c
+++ b/gcc/opts.c
@@ -863,6 +863,16 @@ finish_options (struct gcc_options *opts, struct gcc_options *opts_set,
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
&& !opts_set->x_flag_reorder_functions)
opts->x_flag_reorder_functions = 1;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 8a1c361..05a5827 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+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>
* gcc.dg/predict-14.c: Avoid cold function detection.
diff --git a/gcc/testsuite/gcc.dg/tree-prof/split-1.c b/gcc/testsuite/gcc.dg/tree-prof/split-1.c
new file mode 100644
index 0000000..a42fccf
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-prof/split-1.c
@@ -0,0 +1,41 @@
+/* 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;
+}