This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: PATCH: optimise call graph for coverage data
On Fri, 2008-04-04 at 03:04 +0200, Michael Matz wrote:
> > tree-cfg.c creates a fake edge from a call to a builtin to the exit
> > block of the enclosing function because the call is not a noreturn
> > function (ie. it may longjmp). Thus, the builtin is treated as a
> > regular function call. Many of the GCC builtins are neither const nor
> > pure, so a new ECF constant seems to be needed. I chose
> > ECF_RETURNS_ONCE.
>
> Isn't this the same as ECF_NOTHROW && !ECF_NORETURN && !ECF_RETURNS_TWICE?
> After all, if a function doesn't throw, does return, but doesn't return
> twice, it returns exactly once. Couldn't the predicate for
> need_fake_edge_p be adjusted to take ECF_NOTHROW into account?
Thanks for the review. How about this revised patch? (Testing
underway.)
Ben
2008-04-04 Ben Elliston <bje@au.ibm.com>
* tree-cfg.c (need_fake_edge_p): Return false for calls to
builtins that return once and do not throw.
Index: tree-cfg.c
===================================================================
--- tree-cfg.c (revision 133889)
+++ tree-cfg.c (working copy)
@@ -6403,6 +6403,16 @@ need_fake_edge_p (tree t)
the counter incrementation code from -fprofile-arcs
leads to different results from -fbranch-probabilities. */
call = get_call_expr_in (t);
+
+ if (call
+ && CALL_EXPR_FN (call)
+ && TREE_CODE (TREE_OPERAND (CALL_EXPR_FN (call), 0)) == FUNCTION_DECL
+ && DECL_BUILT_IN (TREE_OPERAND (CALL_EXPR_FN (call), 0))
+ && (call_expr_flags (call) & ECF_NOTHROW)
+ && !(call_expr_flags (call) & ECF_NORETURN)
+ && !(call_expr_flags (call) & ECF_RETURNS_TWICE))
+ return false;
+
if (call
&& !(call_expr_flags (call) & ECF_NORETURN))
return true;