This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Macros taking a function as argument - and evaluating it at least twice
- From: Richard Biener <richard dot guenther at gmail dot com>
- To: Steven Bosscher <stevenb dot gcc at gmail dot com>
- Cc: Jeff Law <law at redhat dot com>, GCC Development <gcc at gcc dot gnu dot org>
- Date: Wed, 13 Nov 2013 11:36:46 +0100
- Subject: Re: Macros taking a function as argument - and evaluating it at least twice
- Authentication-results: sourceware.org; auth=none
- References: <CABu31nMDGXH0n2OpfsPcTpDU7qqwLGsaeWiOXSK=8pSVDBx8pQ at mail dot gmail dot com>
On Wed, Nov 13, 2013 at 12:30 AM, Steven Bosscher <stevenb.gcc@gmail.com> wrote:
> Hello,
>
> Here is a non-comprehensive list of macros that are used with a
> function passed to the macro's argument, and the macro evaluates that
> argument at least twice:
>
> gimple.c: && (CONVERT_EXPR_CODE_P (gimple_assign_rhs_code (gs))
> gimple-ssa-strength-reduction.c: || !CONVERT_EXPR_CODE_P
> (gimple_assign_rhs_code (gs)))
> ipa-prop.c: && CONVERT_EXPR_CODE_P (gimple_assign_rhs_code (def)))
> tree-inline.c: || CONVERT_EXPR_CODE_P
> (gimple_assign_rhs_code (stmt)));
> tree-ssa-dom.c: && CONVERT_EXPR_CODE_P
> (gimple_assign_rhs_code (defstmt)))
> tree-ssa-forwprop.c: if (CONVERT_EXPR_CODE_P (gimple_assign_rhs_code
> (def_stmt)))
> tree-ssa-forwprop.c: || !CONVERT_EXPR_CODE_P
> (gimple_assign_rhs_code (def_stmt)))
> tree-ssa-ifcombine.c: && CONVERT_EXPR_CODE_P
> (gimple_assign_rhs_code (def_stmt)))
> tree-ssa-ifcombine.c: && ((CONVERT_EXPR_CODE_P
> (gimple_assign_rhs_code (stmt))
> tree-ssa-loop-im.c: if (CONVERT_EXPR_CODE_P (gimple_assign_rhs_code (stmt1)))
> tree-stdarg.c: || CONVERT_EXPR_CODE_P
> (gimple_assign_rhs_code (stmt))
> tree-vect-patterns.c: if (!CONVERT_EXPR_CODE_P
> (gimple_assign_rhs_code (*def_stmt)))
> tree-vect-patterns.c: if (CONVERT_EXPR_CODE_P (gimple_assign_rhs_code
> (use_stmt)))
> tree-vect-patterns.c: && CONVERT_EXPR_CODE_P
> (gimple_assign_rhs_code (use_stmt))
> tree-vrp.c: if (CONVERT_EXPR_CODE_P (gimple_assign_rhs_code (def_stmt))
> tree-vrp.c: if (!CONVERT_EXPR_CODE_P
> (gimple_assign_rhs_code (def_stmt2))
> tree-vrp.c: else if (CONVERT_EXPR_CODE_P (gimple_assign_rhs_code (op_def)))
> tree-vrp.c: || !CONVERT_EXPR_CODE_P (gimple_assign_rhs_code (stmt2))
> tree-vrp.c: || !CONVERT_EXPR_CODE_P (gimple_assign_rhs_code (def_stmt)))
> tree-vrp.c: || !CONVERT_EXPR_CODE_P (gimple_assign_rhs_code (def_stmt)))
> tree-outof-ssa.c: && FLOAT_TYPE_P (gimple_expr_type (stmt)))
> tree-ssa-ccp.c: && (INTEGRAL_TYPE_P (gimple_expr_type (stmt))
> tree-chrec.c: if (POINTER_TYPE_P (chrec_type (poly0)))
> tree-chrec.c: if (POINTER_TYPE_P (chrec_type (chrec)))
> tree-ssa-ccp.c: || POINTER_TYPE_P (gimple_expr_type (stmt))))
> tree-ssa-structalias.c: && !(POINTER_TYPE_P (gimple_expr_type (t))
>
> Not sure what to do about them (if anything) but I don't think this is
> intended...
I'd say refactor the code ... either at the uses or by turning the
macros into inline functions (I know that's what other people think
should happen to all macros in GCC). Refactoring the uses may
end up in uglier code like
|| (tem = gimple_assign_rhs_code (def_stmt),
!CONVERT_EXPR_CODE_P (tem))
(there was even a way to have tem declared at that point in C++...)
Richard.
> Ciao!
> Steven