aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2016-06-29 14:12:56 +0200
committerMartin Liska <marxin@gcc.gnu.org>2016-06-29 12:12:56 +0000
commit5c846a81ffb1fa4464f89d2884c85a690d75adf0 (patch)
tree4f5aeff2bf657ac79726ca12e33177d042abbe77
parentfafe9318b735a4b3276b39a73c42aef7a69249d1 (diff)
downloadgcc-5c846a81ffb1fa4464f89d2884c85a690d75adf0.zip
gcc-5c846a81ffb1fa4464f89d2884c85a690d75adf0.tar.gz
gcc-5c846a81ffb1fa4464f89d2884c85a690d75adf0.tar.bz2
Mark -fstack-protect as optimization flag.
PR middle-end/71585 * common.opt (flag_stack_protect): Mark the flag as optimization flag. * ipa-inline-transform.c (inline_call): Remove unnecessary call of build_optimization_node. * gcc.dg/pr71585.c: New test. * gcc.dg/pr71585-2.c: New test. * gcc.dg/pr71585-3.c: New test. From-SVN: r237845
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/common.opt8
-rw-r--r--gcc/ipa-inline-transform.c3
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/gcc.dg/pr71585-2.c23
-rw-r--r--gcc/testsuite/gcc.dg/pr71585-3.c24
-rw-r--r--gcc/testsuite/gcc.dg/pr71585.c23
7 files changed, 89 insertions, 6 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index a086524..1c63e41 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+2016-06-29 Martin Liska <mliska@suse.cz>
+
+ PR middle-end/71585
+ * common.opt (flag_stack_protect): Mark the flag as optimization
+ flag.
+ * ipa-inline-transform.c (inline_call): Remove unnecessary call
+ of build_optimization_node.
+
2016-06-29 Yuri Rumyantsev <ysrumyan@gmail.com>
PR tree-optimization/70729
diff --git a/gcc/common.opt b/gcc/common.opt
index 5d90385..a7c5125 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -2221,19 +2221,19 @@ Common RejectNegative Joined Var(common_deferred_options) Defer
-fstack-limit-symbol=<name> Trap if the stack goes past symbol <name>.
fstack-protector
-Common Report Var(flag_stack_protect, 1) Init(-1)
+Common Report Var(flag_stack_protect, 1) Init(-1) Optimization
Use propolice as a stack protection method.
fstack-protector-all
-Common Report RejectNegative Var(flag_stack_protect, 2) Init(-1)
+Common Report RejectNegative Var(flag_stack_protect, 2) Init(-1) Optimization
Use a stack protection method for every function.
fstack-protector-strong
-Common Report RejectNegative Var(flag_stack_protect, 3) Init(-1)
+Common Report RejectNegative Var(flag_stack_protect, 3) Init(-1) Optimization
Use a smart stack protection method for certain functions.
fstack-protector-explicit
-Common Report RejectNegative Var(flag_stack_protect, 4)
+Common Report RejectNegative Var(flag_stack_protect, 4) Optimization
Use stack protection method only for functions with the stack_protect attribute.
fstack-usage
diff --git a/gcc/ipa-inline-transform.c b/gcc/ipa-inline-transform.c
index f6b7d41..9ac1efc 100644
--- a/gcc/ipa-inline-transform.c
+++ b/gcc/ipa-inline-transform.c
@@ -342,10 +342,10 @@ inline_call (struct cgraph_edge *e, bool update_original,
if (dump_file)
fprintf (dump_file, "Dropping flag_strict_aliasing on %s:%i\n",
to->name (), to->order);
- build_optimization_node (&opts);
DECL_FUNCTION_SPECIFIC_OPTIMIZATION (to->decl)
= build_optimization_node (&opts);
}
+
inline_summary *caller_info = inline_summaries->get (to);
inline_summary *callee_info = inline_summaries->get (callee);
if (!caller_info->fp_expressions && callee_info->fp_expressions)
@@ -402,7 +402,6 @@ inline_call (struct cgraph_edge *e, bool update_original,
if (dump_file)
fprintf (dump_file, "Copying FP flags from %s:%i to %s:%i\n",
callee->name (), callee->order, to->name (), to->order);
- build_optimization_node (&opts);
DECL_FUNCTION_SPECIFIC_OPTIMIZATION (to->decl)
= build_optimization_node (&opts);
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 471e39a..6e132a2 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2016-06-29 Martin Liska <mliska@suse.cz>
+
+ * gcc.dg/pr71585.c: New test.
+ * gcc.dg/pr71585-2.c: New test.
+ * gcc.dg/pr71585-3.c: New test.
+
2016-06-29 Yuri Rumyantsev <ysrumyan@gmail.com>
PR tree-optimization/70729
diff --git a/gcc/testsuite/gcc.dg/pr71585-2.c b/gcc/testsuite/gcc.dg/pr71585-2.c
new file mode 100644
index 0000000..c3010daf
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr71585-2.c
@@ -0,0 +1,23 @@
+/* Test that stack protection is done on chosen functions. */
+
+/* { dg-do compile { target i?86-*-* x86_64-*-* rs6000-*-* s390x-*-* } } */
+/* { dg-options "-O2 -fstack-protector-all" } */
+
+/* This test checks the presence of __stack_chk_fail function in assembler.
+ * Compiler generates _stack_chk_fail_local (wrapper) calls instead for PIC.
+ */
+/* { dg-require-effective-target nonpic } */
+
+static int foo()
+{
+ return 0;
+}
+
+#pragma GCC push_options
+#pragma GCC optimize ("-fno-stack-protector")
+
+int main() { foo (); }
+
+#pragma GCC pop_options
+
+/* { dg-final { scan-assembler-times "stack_chk_fail" 0 } } */
diff --git a/gcc/testsuite/gcc.dg/pr71585-3.c b/gcc/testsuite/gcc.dg/pr71585-3.c
new file mode 100644
index 0000000..5632915
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr71585-3.c
@@ -0,0 +1,24 @@
+/* Test that stack protection is done on chosen functions. */
+
+/* { dg-do compile { target i?86-*-* x86_64-*-* rs6000-*-* s390x-*-* } } */
+/* { dg-options "-O2 -fstack-protector-all" } */
+
+/* This test checks the presence of __stack_chk_fail function in assembler.
+ * Compiler generates _stack_chk_fail_local (wrapper) calls instead for PIC.
+ */
+/* { dg-require-effective-target nonpic } */
+
+
+#pragma GCC push_options
+#pragma GCC optimize ("-fno-stack-protector")
+
+int foo()
+{
+ return 0;
+}
+
+#pragma GCC pop_options
+
+int main() { foo (); }
+
+/* { dg-final { scan-assembler-times "stack_chk_fail" 1 } } */
diff --git a/gcc/testsuite/gcc.dg/pr71585.c b/gcc/testsuite/gcc.dg/pr71585.c
new file mode 100644
index 0000000..444aaa1
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr71585.c
@@ -0,0 +1,23 @@
+/* Test that stack protection is done on chosen functions. */
+
+/* { dg-do compile { target i?86-*-* x86_64-*-* rs6000-*-* s390x-*-* } } */
+/* { dg-options "-O2 -fstack-protector-all" } */
+
+/* This test checks the presence of __stack_chk_fail function in assembler.
+ * Compiler generates _stack_chk_fail_local (wrapper) calls instead for PIC.
+ */
+/* { dg-require-effective-target nonpic } */
+
+#pragma GCC push_options
+
+#pragma GCC optimize ("-fno-stack-protector")
+__attribute__((constructor)) void foo()
+{
+ asm ("");
+}
+
+#pragma GCC pop_options
+
+int main() { return 0; }
+
+/* { dg-final { scan-assembler-times "stack_chk_fail" 1 } } */