summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorvondele <vondele@138bc75d-0d04-0410-961f-82ee72b054a4>2015-10-19 10:24:37 +0000
committervondele <vondele@138bc75d-0d04-0410-961f-82ee72b054a4>2015-10-19 10:24:37 +0000
commitc071eedcfe0006760508441c11f8d64802d472e4 (patch)
tree29da81662086457f8b063de69a5914e50c81d499 /gcc
parentcd5ad70a2a1af200e0087490d30a857a2fa24a36 (diff)
downloadgcc-c071eedcfe0006760508441c11f8d64802d472e4.tar.gz
Fix PR68002, add -fkeep-static-functions
gcc/ChangeLog: 2015-10-17 Joost VandeVondele <vondele@gnu.gcc.org> PR middle-end/68002 * common.opt (fkeep-static-functions): New option. * doc/invoke.texi: Document it. * cgraphunit.c (cgraph_node::finalize_function): Use it. gcc/testsuite/ChangeLog: 2015-10-17 Joost VandeVondele <vondele@gnu.gcc.org> PR middle-end/68002 * gcc.dg/PR68002.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@228965 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/cgraphunit.c2
-rw-r--r--gcc/common.opt4
-rw-r--r--gcc/doc/invoke.texi9
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/PR68002.c7
6 files changed, 31 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index c9a1a11ca08..43d6a3f83bf 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2015-10-19 Joost VandeVondele <vondele@gnu.gcc.org>
+
+ PR middle-end/68002
+ * common.opt (fkeep-static-functions): New option.
+ * doc/invoke.texi: Document it.
+ * cgraphunit.c (cgraph_node::finalize_function): Use it.
+
2015-10-19 Kyrylo Tkachov <kyrylo.tkachov@arm.com>
* sched-int.h (struct autopref_multipass_data_): Remove offset
diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
index 04a4d3f1100..0b0c0f4b6f4 100644
--- a/gcc/cgraphunit.c
+++ b/gcc/cgraphunit.c
@@ -451,7 +451,7 @@ cgraph_node::finalize_function (tree decl, bool no_collect)
declared inline and nested functions. These were optimized out
in the original implementation and it is unclear whether we want
to change the behavior here. */
- if ((!opt_for_fn (decl, optimize)
+ if (((!opt_for_fn (decl, optimize) || flag_keep_static_functions)
&& !node->cpp_implicit_alias
&& !DECL_DISREGARD_INLINE_LIMITS (decl)
&& !DECL_DECLARED_INLINE_P (decl)
diff --git a/gcc/common.opt b/gcc/common.opt
index 50602082173..224d3ad7fbd 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -1589,6 +1589,10 @@ fkeep-inline-functions
Common Report Var(flag_keep_inline_functions)
Generate code for functions even if they are fully inlined
+fkeep-static-functions
+Common Report Var(flag_keep_static_functions)
+Generate code for static functions even if they are never called
+
fkeep-static-consts
Common Report Var(flag_keep_static_consts) Init(1)
Emit static const variables even if they are not used
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 54e9f128634..dba40230360 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -410,8 +410,8 @@ Objective-C and Objective-C++ Dialects}.
-fira-loop-pressure -fno-ira-share-save-slots @gol
-fno-ira-share-spill-slots -fira-verbose=@var{n} @gol
-fisolate-erroneous-paths-dereference -fisolate-erroneous-paths-attribute @gol
--fivopts -fkeep-inline-functions -fkeep-static-consts @gol
--flive-range-shrinkage @gol
+-fivopts -fkeep-inline-functions -fkeep-static-functions @gol
+-fkeep-static-consts -flive-range-shrinkage @gol
-floop-block -floop-interchange -floop-strip-mine @gol
-floop-unroll-and-jam -floop-nest-optimize @gol
-floop-parallelize-all -flra-remat -flto -flto-compression-level @gol
@@ -8013,6 +8013,11 @@ of its callers. This switch does not affect functions using the
@code{extern inline} extension in GNU C90@. In C++, emit any and all
inline functions into the object file.
+@item -fkeep-static-functions
+@optindex fkeep-static-functions
+Emit @code{static} functions into the object file, even if the function
+is never used.
+
@item -fkeep-static-consts
@opindex fkeep-static-consts
Emit variables declared @code{static const} when optimization isn't turned
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 380297d91fb..874632de3b2 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2015-10-17 Joost VandeVondele <vondele@gnu.gcc.org>
+
+ PR middle-end/68002
+ * gcc.dg/PR68002.c: New test.
+
2015-10-19 Richard Sandiford <richard.sandiford@arm.com>
* gcc.dg/builtins-20.c: Remove undefined behavior.
diff --git a/gcc/testsuite/gcc.dg/PR68002.c b/gcc/testsuite/gcc.dg/PR68002.c
new file mode 100644
index 00000000000..b61b0950f19
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/PR68002.c
@@ -0,0 +1,7 @@
+/* Ensure static functions can be kept. */
+/* { dg-do compile } */
+/* { dg-options "-O1 -fkeep-static-functions" } */
+
+static void bar () { }
+
+/* { dg-final { scan-assembler "bar" } } */