This is the mail archive of the
mailing list for the GCC project.
Re: increase alignment of global structs in increase_alignment pass
- From: Richard Biener <rguenther at suse dot de>
- To: Prathamesh Kulkarni <prathamesh dot kulkarni at linaro dot org>
- Cc: "gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>
- Date: Mon, 22 Feb 2016 13:06:27 +0100 (CET)
- Subject: Re: increase alignment of global structs in increase_alignment pass
- Authentication-results: sourceware.org; auth=none
- References: <CAAgBjMnzo0xM_+JAiRS7J3P9sDF-Uoe-k6Q_7fL1dZD+W+x3qA at mail dot gmail dot com>
On Mon, 22 Feb 2016, Prathamesh Kulkarni wrote:
> Hi Richard,
> As discussed in private mail, this version of patch attempts to
> increase alignment
> of global struct decl if it contains an an array field(s) and array's
> offset is a multiple of the alignment of vector type corresponding to
> it's scalar type and recursively checks for nested structs.
> static struct
> int a, b, c, d;
> int k;
> float f;
> k is a candidate array since it's offset is 16 and alignment of
> "vector (4) int" is 8.
> Similarly for f.
> I haven't been able to create a test-case where there are
> multiple candidate arrays and vector alignment of arrays are different.
> I suppose in this case we will have to increase alignment
> of the struct by the max alignment ?
> static struct
> T1 k[S1]
> T2 f[S2]
> if V1 is vector type corresponding to T1, and V2 corresponding vector
> type to T2,
> offset (k) % align(V1) == 0 and offset (f) % align(V2) == 0
> and align (V1) > align(V2) then we will increase alignment of struct
> by align(V1).
> Testing showed FAIL for g++.dg/torture/pr31863.C due to program timeout.
> Initially it appeared to me, it went in infinite loop. However
> on second thoughts I think it's probably not an infinite loop, rather
> taking (extraordinarily) large amount of time
> to compile the test-case with the patch.
> The test-case builds quickly for only 2 instantiations of ClassSpec
> (ClassSpec<Key, A001, 1>,
> ClassSpec<Key, A002, 2>)
> Building with 22 instantiations (upto ClassSpec<Key, A0023, 22>) takes up
> to ~1m to compile.
> 23 instantiations: ~2m
> 24 instantiations: ~5m
> For 30 instantiations I terminated cc1plus after 13m (by SIGKILL).
> I guess it shouldn't go in an infinite loop because:
> a) structs cannot have circular references.
> b) works for lower number of instantiations
> However I have no sound evidence that it cannot be in infinite loop.
> I don't understand why a decl node is getting visited more than once
> for that test-case.
> Using a hash_map to store alignments of decl's so that decl node gets visited
> only once prevents the issue.
Maybe aliases. Try not walking vnode->alias == true vars.