This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH, PR 40464] Intra-SRA workaround so that PR 40464 is not hit
- From: Martin Jambor <mjambor at suse dot cz>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Cc: Richard Guenther <rguenther at suse dot de>
- Date: Thu, 6 Aug 2009 19:54:06 +0200
- Subject: [PATCH, PR 40464] Intra-SRA workaround so that PR 40464 is not hit
Hi,
PR 40464 is a hppa-linux ICE in varasm.c caused by tree-complex.c
almost-resurrecting a long dead variable which was eliminated as early
as early SRA.
tree-complex.c does not do this by itself but through a call to
force_gimple_opernad_gsi on "REALPART_EXPR <b._M_value>" which leads
to invocation of gimplify_var_or_parm_decl on decl "b", which, being
DECL_HAS_VALUE_EXPR_P, is translated by the means of DECL_VALUE_EXPR
into the variable that is already dead. More details are in the bug.
I think that this re-mapping deep down in force_gimple_operand this
late in the compilation seems wrong to me and I think that this
certainly isn't the last bug caused by this. However, I do not have
the time nor guts to remove the mapping but I could hack together
something that makes SRA avoid it which is the patch below.
I'm running a bootstrap and tests on x86_64-linux now. OK for trunk if
it passes?
Thanks,
Martin
2009-08-06 Martin Jambor <mjambor@suse.cz>
* tree-sra.c (find_var_candidates): Disqualify declarations with a
value expr.
(build_accesses_from_assign): Disqualify candidates which are
assigned into from (components of) declarations with a value expr.
Index: mine/gcc/tree-sra.c
===================================================================
--- mine.orig/gcc/tree-sra.c
+++ mine/gcc/tree-sra.c
@@ -761,6 +761,18 @@ build_accesses_from_assign (gimple *stmt
add_link_to_rhs (racc, link);
}
+ else if (lacc && !racc)
+ {
+ tree t = *rhs_ptr;
+ while (handled_component_p (t))
+ t = TREE_OPERAND (t, 0);
+ if (DECL_P (t) && DECL_HAS_VALUE_EXPR_P (t))
+ {
+ disqualify_candidate (lacc->base,
+ "Assigned to from a DECL_HAS_VALUE_EXPR_P decl.");
+ return SRA_SA_NONE;
+ }
+ }
return (lacc || racc) ? SRA_SA_PROCESSED : SRA_SA_NONE;
}
@@ -1154,6 +1166,7 @@ find_var_candidates (void)
if (!AGGREGATE_TYPE_P (type)
|| needs_to_live_in_memory (var)
|| TREE_THIS_VOLATILE (var)
+ || DECL_HAS_VALUE_EXPR_P (var)
|| !COMPLETE_TYPE_P (type)
|| !host_integerp (TYPE_SIZE (type), 1)
|| tree_low_cst (TYPE_SIZE (type), 1) == 0