From 17541d72a769ffafcfa9bd84efb74c08a075ff7b Mon Sep 17 00:00:00 2001 From: Kenneth Zadeck Date: Thu, 8 Nov 2007 16:45:53 +0000 Subject: [multiple changes] 2007-11-07 Kenneth Zadeck PR middle-end/33826 * ipa-pure-const (static_execute): Added code to keep recursive functions from being marked as pure or const. * ipa-utils (searchc): Fixed comment. 2007-11-08 Kenneth Zadeck PR middle-end/33826 * gcc.dg/pr33826.c: New. * gcc.dg/tree-ssa/20030714-1.c: Removed two tests that depend on recursive functions being marked pure or const. From-SVN: r130006 --- gcc/ipa-pure-const.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'gcc/ipa-pure-const.c') diff --git a/gcc/ipa-pure-const.c b/gcc/ipa-pure-const.c index d3b880adc83..eb4262a0047 100644 --- a/gcc/ipa-pure-const.c +++ b/gcc/ipa-pure-const.c @@ -644,6 +644,7 @@ static_execute (void) for (i = 0; i < order_pos; i++ ) { enum pure_const_state_e pure_const_state = IPA_CONST; + int count = 0; node = order[i]; /* Find the worst state for any node in the cycle. */ @@ -660,11 +661,40 @@ static_execute (void) if (!w_l->state_set_in_source) { struct cgraph_edge *e; + count++; + + /* FIXME!!! Because of pr33826, we cannot have either + immediate or transitive recursive functions marked as + pure or const because dce can delete a function that + is in reality an infinite loop. A better solution + than just outlawing them is to add another bit the + functions to distinguish recursive from non recursive + pure and const function. This would allow the + recursive ones to be cse'd but not dce'd. In this + same vein, we could allow functions with loops to + also be cse'd but not dce'd. + + Unfortunately we are late in stage 3, and the fix + described above is is not appropriate. */ + if (count > 1) + { + pure_const_state = IPA_NEITHER; + break; + } + for (e = w->callees; e; e = e->next_callee) { struct cgraph_node *y = e->callee; /* Only look at the master nodes and skip external nodes. */ y = cgraph_master_clone (y); + + /* Check for immediate recursive functions. See the + FIXME above. */ + if (w == y) + { + pure_const_state = IPA_NEITHER; + break; + } if (y) { funct_state y_l = get_function_state (y); -- cgit v1.2.1