Did you try with the latest version in the svn repo ? I think it fixes this
issue.
Tristan.
----- Mail original -----
> On Mon, 2012-12-03 at 17:07 +0000, Brian Drummond wrote:
> > On Mon, 2012-11-12 at 20:57 +0100, Lluís Batlle i Rossell wrote:
> > > So, only very simple vhd files build fine for me with -O2.
> > >
> > > Regards,
> > > Lluís.
> >
> > I have started to look at this.
>
> Narrowing this down slowly.
>
> The patch below gets through the segfault compiling Unisims with -O2.
> It bypasses a specific constant folding optimisation returning
> NULL_TREE when
> the erroneous circumstance arises. This ought to be safe; other
> erroneous conditions
> in the same function already do the same.
>
> Test results from this patch and comments are welcome.
>
>
>
>
> I am not entirely satisfied with it because it is the first change
> required to the
> base GCC source rather than to GHDL. I have traced the origin of this
> problem to
> function Create_Static_Array_Subtype_Bounds in translation.adb.
>
> This creates a record containing a single element, which is passed to
> "fold_nonarray_ctor_reference" in gimple-fold.c. Somehow this element
> is not
> accompanied by a FIELD_DECL defining its size and location within the
> record
> (hence "cfield == null" and the segfault accessing cfield)
>
> In fact the single element is itself a record containing the array
> bounds
> (which may or may not have their own FIELD_DECLs).
>
> And that's as far as I have got. The way I see it:
> either Create_Static_Array_Subtype_Bounds wrapping the array bound
> record in
> another record is not necessary (maybe it was, but this bit of GCC
> changed in 2010)
> - or "fold_nonarray_ctor_reference" should unwrap the first record
> and apply
> the folding optimisation to the record it contains...
>
> But that is just a guess; I don't have the bigger picture here as to
> why
> Create_Static_Array_Subtype_Bounds is the way it is; without that
> understanding,
> I am wary of messing with it. I don't know if there are regression
> tests to catch
> anything I break here...
>
>
>
> As I say, any suggestions or further information would be welcome.
>
>
> - Brian
>
>
> ------------------------------------------------------------------------
>
> --- /home/brian/Projects/gcc4.7/4.7.2/gcc-4.7.2/gcc/gimple-fold.c
> 2012-07-19 22:26:17.000000000 +0100
> +++ /home/brian/Projects/ghdl/gcc-4.7.2/gcc/gimple-fold.c 2012-12-07
> 18:07:49.679974119 +0000
> @@ -2862,6 +2862,12 @@
> FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (ctor), cnt, cfield,
> cval)
> {
> +
> + if (cfield == NULL)
> + return NULL_TREE;
> +
> tree byte_offset = DECL_FIELD_OFFSET (cfield);
> tree field_offset = DECL_FIELD_BIT_OFFSET (cfield);
> tree field_size = DECL_SIZE (cfield);
>
>
> _______________________________________________
> Ghdl-discuss mailing list
> [email protected]
> https://mail.gna.org/listinfo/ghdl-discuss
>
_______________________________________________
Ghdl-discuss mailing list
[email protected]
https://mail.gna.org/listinfo/ghdl-discuss