re PR tree-optimization/37879 (ICE with "wrong" use of noreturn attribute and optimization)

PR tree-optimization/37879
	* predict.c (tree_estimate_probability): Check if last_stmt is
	non-NULL before dereferencing it.

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

From-SVN: r141390
This commit is contained in:
Jakub Jelinek 2008-10-27 21:36:32 +01:00 committed by Jakub Jelinek
parent 8f0f2a1dfd
commit 6a16e93455
4 changed files with 42 additions and 1 deletions

View 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.

View 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;

View 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

View File

@ -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 ("");
}