From 1d8381f13f63fc3871f88f8765a2cdcb75958180 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Wed, 20 Jun 2007 08:39:53 +0200 Subject: [PATCH] re PR middle-end/31959 (ICE in expand_builtin_expect, at builtins.c:5112) PR middle-end/31959 * builtins.c: Include diagnostic.h. (expand_builtin_expect): Make gcc_assert more permissive. * Makefile.in (builtins.o): Depend on $(DIAGNOSTIC_H). * gcc.dg/pr31959.c: New test. From-SVN: r125875 --- gcc/ChangeLog | 5 +++++ gcc/Makefile.in | 2 +- gcc/builtins.c | 4 +++- gcc/testsuite/ChangeLog | 3 +++ gcc/testsuite/gcc.dg/pr31959.c | 20 ++++++++++++++++++++ 5 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/pr31959.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b73ef8135d5..8ea45a1662e 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,10 @@ 2007-06-20 Jakub Jelinek + PR middle-end/31959 + * builtins.c: Include diagnostic.h. + (expand_builtin_expect): Make gcc_assert more permissive. + * Makefile.in (builtins.o): Depend on $(DIAGNOSTIC_H). + PR inline-asm/32109 * gimplify.c (gimplify_asm_expr): Issue error if type is addressable and !allows_mem. diff --git a/gcc/Makefile.in b/gcc/Makefile.in index 040007e9751..0b559c7b100 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -2329,7 +2329,7 @@ builtins.o : builtins.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) \ $(EXPR_H) $(OPTABS_H) insn-config.h $(RECOG_H) output.h typeclass.h \ hard-reg-set.h toplev.h hard-reg-set.h except.h $(TM_P_H) $(PREDICT_H) \ libfuncs.h $(REAL_H) langhooks.h $(BASIC_BLOCK_H) tree-mudflap.h \ - $(BUILTINS_DEF) $(MACHMODE_H) + $(BUILTINS_DEF) $(MACHMODE_H) $(DIAGNOSTIC_H) calls.o : calls.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) \ $(TREE_H) $(FLAGS_H) $(EXPR_H) $(OPTABS_H) langhooks.h $(TARGET_H) \ libfuncs.h $(REGS_H) toplev.h output.h $(FUNCTION_H) $(TIMEVAR_H) $(TM_P_H) \ diff --git a/gcc/builtins.c b/gcc/builtins.c index 6dff9b8f02f..7dd4470d7f9 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -50,6 +50,7 @@ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA #include "tree-mudflap.h" #include "tree-flow.h" #include "value-prof.h" +#include "diagnostic.h" #ifndef PAD_VARARGS_DOWN #define PAD_VARARGS_DOWN BYTES_BIG_ENDIAN @@ -5121,7 +5122,8 @@ expand_builtin_expect (tree exp, rtx target) target = expand_expr (arg, target, VOIDmode, EXPAND_NORMAL); /* When guessing was done, the hints should be already stripped away. */ - gcc_assert (!flag_guess_branch_prob); + gcc_assert (!flag_guess_branch_prob + || optimize == 0 || errorcount || sorrycount); return target; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0cefc19892f..e83e57a6943 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2007-06-20 Jakub Jelinek + PR middle-end/31959 + * gcc.dg/pr31959.c: New test. + PR inline-asm/32109 * g++.dg/ext/asm10.C: New test. diff --git a/gcc/testsuite/gcc.dg/pr31959.c b/gcc/testsuite/gcc.dg/pr31959.c new file mode 100644 index 00000000000..f8090f45cc0 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr31959.c @@ -0,0 +1,20 @@ +/* PR middle-end/31959 */ +/* { dg-do compile } */ +/* { dg-options "-O0 -fguess-branch-probability" } */ + +struct A { int i; }; + +static inline struct A * +bar (struct A *x) +{ + return x; +} + +void * +foo (struct A *x, int y) +{ + void *p = (void *) 0; + if (__builtin_expect (y >= 6, 0)) + p = bar (x); + return p; +}