[trunk] patch to clean up handling of pure and constant functions.

Diego Novillo dnovillo@google.com
Wed May 7 00:23:00 GMT 2008


On Wed, Apr 23, 2008 at 16:01, Kenneth Zadeck <zadeck@naturalbridge.com> wrote:

> -#define DECL_IS_PURE(NODE) (FUNCTION_DECL_CHECK (NODE)->function_decl.pure_flag)
> +#define DECL_PURE_P(NODE) (FUNCTION_DECL_CHECK (NODE)->function_decl.pure_flag)
> +
> +/* Nonzero only if one of TREE_READONLY or DECL_PURE_P is nonzero AND
> +   the const or pure function may not terminate.  When this is nonzero
> +   for a const or pure function, it can be dealt with by cse passes
> +   but cannot be removed by dce passes since you are not allowed to
> +   change an infinite looping program into one that terminates without
> +   error.  */
> +#define DECL_LOOPING_CONST_OR_PURE_P(NODE) \
> +  (FUNCTION_DECL_CHECK (NODE)->function_decl.looping_const_or_pure_flag)

Could you add a check to verify_stmts()?  Every call whose DECL
has this set should also have one of the other two bits set.

> Index: cfgrtl.c
> ===================================================================
> --- cfgrtl.c	(revision 134565)
> +++ cfgrtl.c	(working copy)
> @@ -2745,7 +2745,7 @@ need_fake_edge_p (const_rtx insn)
>    if ((CALL_P (insn)
>         && !SIBLING_CALL_P (insn)
>         && !find_reg_note (insn, REG_NORETURN, NULL)
> -       && !CONST_OR_PURE_CALL_P (insn)))
> +       && !(RTL_CONST_CALL_P (insn) || RTL_PURE_CALL_P (insn))))

This predicate pattern seems pretty common throughout the patch.
Maybe it's worth converting it into a predicate macro?

The rest looks fine.


Thanks.  Diego.



More information about the Gcc-patches mailing list