This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch] 2 patches for PR tree-optimization/34648
- From: Andrew MacLeod <amacleod at redhat dot com>
- To: gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 17 Jan 2008 09:13:28 -0500
- Subject: [patch] 2 patches for PR tree-optimization/34648
As mentioned in the body of the PR, there are really two problems. At
issue is a constant function when -fexceptions is enabled.
1 - SCCVN and PRE do not agree on whether you can regenerate an
expression which may throw.
2 - tree_could_throw_p() currently returns TRUE for CONST and PURE
functions.
The first patch changes SCCVN such that it no longer thinks throwing
expressions can be regenerated. This change should be perfectly safe.
The second patch changes tree_could_throw_p() such that ECF_CONST and
ECF_PURE will also return false. According to the comments in tree.h
this should be true. My concern is that we have some cases where it
isn't true and this will now cause some other issue to pop up. Does
anyone know for a fact that this is a safe change? Can a const function
in C++ or some other language ever throw? and if so, are they marked as
ECF_CONST or ECF_PURE?
In any case, both patches have been tested individually as well as
together. Bootstraps on x86_64-linux-gnu and causes no new regressions
in the testsuite.
Andrew
* tree-ssa-sccvn.c (visit_use): Expressions which can throw are varying.
Index: tree-ssa-sccvn.c
===================================================================
*** tree-ssa-sccvn.c (revision 131551)
--- tree-ssa-sccvn.c (working copy)
*************** visit_use (tree use)
*** 1609,1615 ****
changed = visit_phi (stmt);
}
else if (TREE_CODE (stmt) != GIMPLE_MODIFY_STMT
! || (ann && ann->has_volatile_ops))
{
changed = defs_to_varying (stmt);
}
--- 1609,1616 ----
changed = visit_phi (stmt);
}
else if (TREE_CODE (stmt) != GIMPLE_MODIFY_STMT
! || (ann && ann->has_volatile_ops)
! || tree_could_throw_p (stmt))
{
changed = defs_to_varying (stmt);
}
* tree-eh.c (tree_could_throw_p): CONST and PURE functions can't throw.
Index: tree-eh.c
===================================================================
*** tree-eh.c (revision 131551)
--- tree-eh.c (working copy)
*************** tree_could_throw_p (tree t)
*** 2027,2033 ****
if (TREE_CODE (t) == WITH_SIZE_EXPR)
t = TREE_OPERAND (t, 0);
if (TREE_CODE (t) == CALL_EXPR)
! return (call_expr_flags (t) & ECF_NOTHROW) == 0;
if (flag_non_call_exceptions)
return tree_could_trap_p (t);
return false;
--- 2027,2033 ----
if (TREE_CODE (t) == WITH_SIZE_EXPR)
t = TREE_OPERAND (t, 0);
if (TREE_CODE (t) == CALL_EXPR)
! return (call_expr_flags (t) & (ECF_NOTHROW|ECF_CONST|ECF_PURE)) == 0;
if (flag_non_call_exceptions)
return tree_could_trap_p (t);
return false;