From fb0653ab96ba450a5f364cbf9463060dfe5729f5 Mon Sep 17 00:00:00 2001 From: Ilya Enkovich Date: Fri, 13 Feb 2015 09:44:07 +0000 Subject: [PATCH] re PR tree-optimization/65002 (ICE: Segmentation fault) gcc/ PR tree-optimization/65002 * tree-cfg.c (pass_data_fixup_cfg): Don't update SSA on start. * tree-sra.c (some_callers_have_no_vuse_p): New. (ipa_early_sra): Reject functions whose callers assume function is read only. gcc/testsuite/ PR tree-optimization/65002 * gcc.dg/pr65002.C: New. From-SVN: r220679 --- gcc/ChangeLog | 9 +++++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/pr65002.C | 26 ++++++++++++++++++++++++++ gcc/tree-cfg.c | 2 +- gcc/tree-sra.c | 23 +++++++++++++++++++++++ 5 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/pr65002.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 1815502e576..19e729bba97 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2015-02-13 Ilya Enkovich + + PR tree-optimization/65002 + * tree-cfg.c (pass_data_fixup_cfg): Don't update + SSA on start. + * tree-sra.c (some_callers_have_no_vuse_p): New. + (ipa_early_sra): Reject functions whose callers + assume function is read only. + 2015-02-13 Richard Biener PR lto/65015 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d958264df10..1aca0b55a92 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-02-13 Ilya Enkovich + + PR tree-optimization/65002 + * gcc.dg/pr65002.C: New. + 2015-02-13 Marek Polacek PR c/65040 diff --git a/gcc/testsuite/gcc.dg/pr65002.C b/gcc/testsuite/gcc.dg/pr65002.C new file mode 100644 index 00000000000..ac7c66bd19a --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr65002.C @@ -0,0 +1,26 @@ +/* PR tree-optimization/65002 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +namespace fastmath { + template float floor(const T &) __attribute__((const)); + template float floor(const T &p1) { return p1; } +} +using fastmath::floor; +class A { +public: + A(int, int); + virtual int m_fn1(float) const; +}; +class B : A { +public: + B(int, int p2) : A(entity, p2) {} + int m_fn1(float p1) const { long b(floor(p1)); } + int entity; +}; + +int a; +void Convert() { + if (int *c = 0) + B(*c, a); +} diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index 2e23553229f..006bc08bbca 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -8754,7 +8754,7 @@ const pass_data pass_data_fixup_cfg = PROP_cfg, /* properties_required */ 0, /* properties_provided */ 0, /* properties_destroyed */ - TODO_update_ssa_only_virtuals, /* todo_flags_start */ + 0, /* todo_flags_start */ 0, /* todo_flags_finish */ }; diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c index c6726a89cb9..023b8172300 100644 --- a/gcc/tree-sra.c +++ b/gcc/tree-sra.c @@ -4890,6 +4890,20 @@ some_callers_have_mismatched_arguments_p (struct cgraph_node *node, return false; } +/* Return false if all callers have vuse attached to a call statement. */ + +static bool +some_callers_have_no_vuse_p (struct cgraph_node *node, + void *data ATTRIBUTE_UNUSED) +{ + struct cgraph_edge *cs; + for (cs = node->callers; cs; cs = cs->next_caller) + if (!cs->call_stmt || !gimple_vuse (cs->call_stmt)) + return true; + + return false; +} + /* Convert all callers of NODE. */ static bool @@ -5116,6 +5130,15 @@ ipa_early_sra (void) goto simple_out; } + if (node->call_for_symbol_thunks_and_aliases + (some_callers_have_no_vuse_p, NULL, true)) + { + if (dump_file) + fprintf (dump_file, "There are callers with no VUSE attached " + "to a call stmt.\n"); + goto simple_out; + } + bb_dereferences = XCNEWVEC (HOST_WIDE_INT, func_param_count * last_basic_block_for_fn (cfun)); -- 2.30.2