[PATCH] Clean up the gimple type verifier [2/2]
Richard Guenther
rguenther@suse.de
Thu Sep 4 11:21:00 GMT 2008
On Wed, 3 Sep 2008, Richard Guenther wrote:
>
> This splits apart and "completes" verifying of GIMPLE_ASSIGN.
> Unfortunately during the time the checks were incomplete/disabled
> we have gathered some new problems (maybe due to tuplification of
> the gimplifier, I'll have to investigate).
>
> Bootstrapped on x86_64-unknown-linux-gnu, the C testsuite is clean,
> as are the Ada, java, objc and libstdc++ ones. C++ has got one
> problem (back?):
Here is a patch to address the following two:
> g++.old-deja/g++.law/casts2.C:30: error: non-register as LHS of unary
> operation^M
> q = (struct method1) m;^M
For this one I "punted" (see also PR37354) and fixed up the IL
in the gimplifier. The fix is to force the use of a VIEW_CONVERT_EXPR
if converting non-register types.
[...]
> and a strange one,
>
> gfortran.fortran-torture/execute/intrinsic_si_kind.f90:2: error:
> non-register as LHS of unary operation^M
> D.1546 = (integer(kind=4)) t;^M
This one results from fortran passing parameters by reference. We
have something like foo ((int) float_var); which get's presented
to the gimplifier as
res = _gfortran_selected_int_kind (&(integer(kind=4)) t);
and is gimplified to
t = __builtin_log10f (t);
D.1534 = (integer(kind=4)) t;
res.1 = _gfortran_selected_int_kind (&D.1534);
this is obviously not correct, as D.1534 = (integer(kind=4)) t; is not
a valid gimple store. Instead whenever we need to mark a variable
addressable in gimplify_addr_expr (that is, the frontend didn't do it
already), we have to make sure to only mark something addressable
that is initialized by a rhs that is a valid rhs for a store.
Instead of trying to re-gimplify those after marking the lhs addresable
I chose to simply use another temporary initialized by a simple copy.
So for the above we now get
t = __builtin_log10f (t);
D.1534 = (integer(kind=4)) t;
D.1535 = D.1534;
res.1 = _gfortran_selected_int_kind (&D.1535);
which is correct.
Bootstrap & regtest running. Diego, are you fine with these changes?
Thanks,
Richard.
PR middle-end/37354
* gimplify.c (gimplify_conversion): Change conversions of
non-register type to VIEW_CONVERT_EXPRs.
(gimplify_addr_expr): If we need to make the operand
addressable make sure to use a properly initialized
temporary for that so it gets a valid gimple store.
Index: gimplify.c
===================================================================
*** gimplify.c (revision 139978)
--- gimplify.c (working copy)
*************** gimplify_conversion (tree *expr_p)
*** 1872,1877 ****
--- 1872,1883 ----
canonicalize_addr_expr (expr_p);
}
+ /* If we have a conversion to a non-register type force the
+ use of a VIEW_CONVERT_EXPR instead. */
+ if (!is_gimple_reg_type (TREE_TYPE (*expr_p)))
+ *expr_p = fold_build1 (VIEW_CONVERT_EXPR, TREE_TYPE (*expr_p),
+ TREE_OPERAND (*expr_p, 0));
+
return GS_OK;
}
*************** gimplify_addr_expr (tree *expr_p, gimple
*** 4555,4574 ****
/* Mark the RHS addressable. */
ret = gimplify_expr (&TREE_OPERAND (expr, 0), pre_p, post_p,
is_gimple_addressable, fb_either);
! if (ret != GS_ERROR)
! {
! op0 = TREE_OPERAND (expr, 0);
! /* For various reasons, the gimplification of the expression
! may have made a new INDIRECT_REF. */
! if (TREE_CODE (op0) == INDIRECT_REF)
! goto do_indirect_ref;
! /* Make sure TREE_CONSTANT and TREE_SIDE_EFFECTS are set properly. */
! recompute_tree_invariant_for_addr_expr (expr);
! mark_addressable (TREE_OPERAND (expr, 0));
! }
break;
}
--- 4561,4592 ----
/* Mark the RHS addressable. */
ret = gimplify_expr (&TREE_OPERAND (expr, 0), pre_p, post_p,
is_gimple_addressable, fb_either);
! if (ret == GS_ERROR)
! break;
! /* We cannot rely on making the RHS addressable if a
! variable is not already addressable. In this case create a
! new temporary that is initialized by a copy (which will
! become a store after we mark it addressable).
! This mostly happens if the frontend passed us something that
! it could not mark addressable yet, like a fortran
! pass-by-reference parameter (int) floatvar. */
! if (is_gimple_variable (TREE_OPERAND (expr, 0))
! && !TREE_ADDRESSABLE (TREE_OPERAND (expr, 0)))
! TREE_OPERAND (expr, 0)
! = get_initialized_tmp_var (TREE_OPERAND (expr, 0), pre_p, post_p);
!
! op0 = TREE_OPERAND (expr, 0);
!
! /* For various reasons, the gimplification of the expression
! may have made a new INDIRECT_REF. */
! if (TREE_CODE (op0) == INDIRECT_REF)
! goto do_indirect_ref;
! /* Make sure TREE_CONSTANT and TREE_SIDE_EFFECTS are set properly. */
! recompute_tree_invariant_for_addr_expr (expr);
! mark_addressable (TREE_OPERAND (expr, 0));
break;
}
More information about the Fortran
mailing list