This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Use of stack VECs in df-scan.c:df_bb_verify


Diego Novillo <dnovillo@google.com> writes:

> I've converted vec.[hc] to C++ and this meant some subtle changes to
> how VEC(T,stack) works.  We no longer need all those macro expansions.

But it took me hours to write those macros....


> This means that the allocation function for vectors can detect when a
> stack vector is initially allocated on the heap.  This happens when
> the vector is implicitly allocated when the first element is pushed
> (and the vector is nil).
>
> This was causing an ICE in df_bb_verify() because of this code:
>
>   collection_rec.def_vec = VEC_alloc (df_ref, stack, 128);
>   collection_rec.use_vec = VEC_alloc (df_ref, stack, 32);
>   collection_rec.eq_use_vec = VEC_alloc (df_ref, stack, 32);
>   collection_rec.mw_vec = VEC_alloc (df_mw_hardreg_ptr, stack, 32);
>
>   gcc_assert (bb_info);
>
>   /* Scan the block, one insn at a time, from beginning to end.  */
>   FOR_BB_INSNS_REVERSE (bb, insn)
>     {
>       if (!INSN_P (insn))
>         continue;
>       df_insn_refs_verify (&collection_rec, bb, insn, true);
>       df_free_collection_rec (&collection_rec);
>     }
>
>
> Note that we initially allocate the various vectors on the stack, but
> then the FOR_BB_INSNS_REVERSE loop explicitly deallocates them.  The
> next time df_insns_ref_verify tries to push something on these VECs,
> the pushing routine will try to do an initial allocation on the heap,
> which causes an ICE.
>
> I *think* what you meant in that loop is to clear COLLECTION_REC?  Or
> should we clear it and reallocate the vectors?  I am currently running
> with the call to df_free_collection_rec() taken out, but I'm not sure
> if that's the right thing here.

It looks like it should free all the elements in the vectors in
collection_rec, and then truncate but not free the vectors.  It works
today because the start of df_insn_refs_verify truncates the vectors (in
df_insn_refs_collect), and freeing a stack vector doesn't really do
anything to the vector structure.

Actually simply moving the call to df_free_collection_rec out of the
loop should work fine, since df_insn_refs_verify truncates the vectors
anyhow.

Ian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]