OSDN Git Service

PR tree-optimization/37879
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 27 Oct 2008 20:36:32 +0000 (20:36 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 27 Oct 2008 20:36:32 +0000 (20:36 +0000)
* predict.c (tree_estimate_probability): Check if last_stmt is
non-NULL before dereferencing it.

* gcc.dg/pr37879.c: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@141390 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/predict.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr37879.c [new file with mode: 0644]

index a683eca..a92a67a 100644 (file)
@@ -1,3 +1,9 @@
+2008-10-27  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/37879
+       * predict.c (tree_estimate_probability): Check if last_stmt is
+       non-NULL before dereferencing it.
+
 2008-10-27  Vladimir Makarov  <vmakarov@redhat.com>
 
        * ira-int.h (ira_allocno): Add member updated_cover_class_cost.
index 5ed6c43..c6e933f 100644 (file)
@@ -1599,6 +1599,7 @@ tree_estimate_probability (void)
     {
       edge e;
       edge_iterator ei;
+      gimple last;
 
       FOR_EACH_EDGE (e, ei, bb->succs)
        {
@@ -1621,7 +1622,8 @@ tree_estimate_probability (void)
              && e->dest != EXIT_BLOCK_PTR
              && single_succ_p (e->dest)
              && single_succ_edge (e->dest)->dest == EXIT_BLOCK_PTR
-             && gimple_code (last_stmt (e->dest)) == GIMPLE_RETURN)
+             && (last = last_stmt (e->dest)) != NULL
+             && gimple_code (last) == GIMPLE_RETURN)
            {
              edge e1;
              edge_iterator ei1;
index 886e542..3aa9a1e 100644 (file)
@@ -1,3 +1,8 @@
+2008-10-27  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/37879
+       * gcc.dg/pr37879.c: New test.
+
 2008-10-24  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
        PR target/37841
diff --git a/gcc/testsuite/gcc.dg/pr37879.c b/gcc/testsuite/gcc.dg/pr37879.c
new file mode 100644 (file)
index 0000000..5dd2527
--- /dev/null
@@ -0,0 +1,28 @@
+/* PR tree-optimization/37879 */
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+static inline void bar (int) __attribute__ ((noreturn));
+void baz () __attribute__ ((noreturn));
+
+inline int
+foo (int i)
+{
+  return i;
+}
+
+int i = 23;
+static inline void
+bar (int j)
+{
+  if (j)
+    asm ("");
+}              /* { dg-warning "does return" } */
+
+void
+baz ()
+{
+  int j;
+  bar (foo (j = i++));
+  asm ("");
+}