aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJan Hubicka <jh@suse.cz>2010-06-01 23:55:49 +0200
committerJan Hubicka <hubicka@gcc.gnu.org>2010-06-01 21:55:49 +0000
commit73add7fe2951139ec8508968888c1f5b12eceae7 (patch)
tree9b44105d588d9c7a44fc7884f12ec8614194f420 /gcc
parenta669ca47cbc34571d9e6d590a4083cddfce3c744 (diff)
downloadgcc-73add7fe2951139ec8508968888c1f5b12eceae7.zip
gcc-73add7fe2951139ec8508968888c1f5b12eceae7.tar.gz
gcc-73add7fe2951139ec8508968888c1f5b12eceae7.tar.bz2
ipa-pure-const.c (local_pure_const): Do NORETURN discovery.
* ipa-pure-const.c (local_pure_const): Do NORETURN discovery. * testsuite/gcc.dg/noreturn-8.c: New testcase. From-SVN: r160124
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog4
-rw-r--r--gcc/ipa-pure-const.c21
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.dg/noreturn-8.c16
4 files changed, 45 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 513b318..a87a41d 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,9 @@
2010-06-01 Jan Hubicka <jh@suse.cz>
+ * ipa-pure-const.c (local_pure_const): Do NORETURN discovery.
+
+2010-06-01 Jan Hubicka <jh@suse.cz>
+
* tree-cfgcleanup.c (fixup_noreturn_call): Break out from ...;
remove return value.
(split_bbs_on_noreturn_calls) .... here.
diff --git a/gcc/ipa-pure-const.c b/gcc/ipa-pure-const.c
index df2f8c8..d785389 100644
--- a/gcc/ipa-pure-const.c
+++ b/gcc/ipa-pure-const.c
@@ -1362,6 +1362,27 @@ local_pure_const (void)
&& !warn_suggest_attribute_pure
&& skip)
return 0;
+
+ /* First do NORETURN discovery. */
+ if (!skip && !TREE_THIS_VOLATILE (current_function_decl)
+ && EDGE_COUNT (EXIT_BLOCK_PTR->preds) == 0)
+ {
+ if (warn_missing_noreturn
+ && !lang_hooks.missing_noreturn_ok_p (cfun->decl))
+ warning_at (DECL_SOURCE_LOCATION (cfun->decl), OPT_Wmissing_noreturn,
+ "function might be possible candidate "
+ "for attribute %<noreturn%>");
+ if (dump_file)
+ fprintf (dump_file, "Function found to be noreturn: %s\n",
+ lang_hooks.decl_printable_name (current_function_decl, 2));
+
+ /* Update declaration and reduce profile to executed once. */
+ TREE_THIS_VOLATILE (current_function_decl) = 1;
+ if (node->frequency > NODE_FREQUENCY_EXECUTED_ONCE)
+ node->frequency = NODE_FREQUENCY_EXECUTED_ONCE;
+
+ changed = true;
+ }
l = analyze_function (node, false);
switch (l->pure_const_state)
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index efbec90..cd4fdc3 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,9 @@
2010-05-31 Jan Hubicka <jh@suse.cz>
+ * testsuite/gcc.dg/noreturn-8.c: New testcase.
+
+2010-05-31 Jan Hubicka <jh@suse.cz>
+
* testsuite/gcc.dg/lto/noreturn-1_1.c: Remove dg-do annotations.
* testsuite/gcc.dg/lto/noreturn-1_0.c: Move it here.
diff --git a/gcc/testsuite/gcc.dg/noreturn-8.c b/gcc/testsuite/gcc.dg/noreturn-8.c
new file mode 100644
index 0000000..50765da
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/noreturn-8.c
@@ -0,0 +1,16 @@
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+void exit (int);
+void noreturn_autodetection_failed ();
+__attribute__ ((noinline))
+detect_noreturn ()
+{
+ exit (0);
+}
+int
+main (void)
+{
+ detect_noreturn ();
+ noreturn_autodetection_failed ();
+ return 0;
+}