From 68052d59d6c867e7346e91900d287ba2d374a3b4 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Mon, 2 Nov 2009 14:57:13 +0100 Subject: [PATCH] re PR tree-optimization/41841 (segfault using '-O -fipa-cp -fipa-struct-reorg -fwhole-program -fprofile-generate') PR tree-optimization/41841 * ipa-struct-reorg.c (build_data_structure): Don't attempt to look at local variables of not yet materialized clones. * gcc.dg/pr41841.c: New test. From-SVN: r153807 --- gcc/ChangeLog | 4 ++++ gcc/ipa-struct-reorg.c | 8 ++++++++ gcc/testsuite/ChangeLog | 3 +++ gcc/testsuite/gcc.dg/pr41841.c | 22 ++++++++++++++++++++++ 4 files changed, 37 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/pr41841.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f18488d22e1..7ecad8bb37c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,9 @@ 2009-11-02 Jakub Jelinek + PR tree-optimization/41841 + * ipa-struct-reorg.c (build_data_structure): Don't attempt to look at + local variables of not yet materialized clones. + PR debug/41893 * cfgexpand.c (expand_debug_expr): Don't attempt to create DECL_RTL for a VOIDmode variable. diff --git a/gcc/ipa-struct-reorg.c b/gcc/ipa-struct-reorg.c index 7b05bf64c0d..147610a43e4 100644 --- a/gcc/ipa-struct-reorg.c +++ b/gcc/ipa-struct-reorg.c @@ -3380,6 +3380,14 @@ build_data_structure (VEC (tree, heap) **unsuitable_types) if (is_candidate (var, &type, unsuitable_types)) add_structure (type); + if (fn == NULL) + { + /* Skip cones that haven't been materialized yet. */ + gcc_assert (c_node->clone_of + && c_node->clone_of->decl != c_node->decl); + continue; + } + /* Check function local variables. */ for (var_list = fn->local_decls; var_list; var_list = TREE_CHAIN (var_list)) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 09bf48cae28..d6ee45e20d8 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2009-11-02 Jakub Jelinek + PR tree-optimization/41841 + * gcc.dg/pr41841.c: New test. + PR debug/41893 * gcc.dg/debug/pr41893-1.c: New test. * gcc.dg/debug/pr41893-2.c: New file. diff --git a/gcc/testsuite/gcc.dg/pr41841.c b/gcc/testsuite/gcc.dg/pr41841.c new file mode 100644 index 00000000000..595bc759207 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr41841.c @@ -0,0 +1,22 @@ +/* PR tree-optimization/41841 */ +/* { dg-do compile } */ +/* { dg-options "-O -fipa-struct-reorg -fwhole-program -fipa-cp" } */ + +typedef struct S *T; +typedef struct { } *U; +extern int f1 (void); + +static void +f3 (U x, int y) +{ + T a = (T) x; + y && f1 (); +} + +static void +f2 (T x) +{ + f3 ((U) x, 1); +} + +void *volatile a __attribute__((used)) = f2;