This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Use of stack VECs in df-scan.c:df_bb_verify
- From: Ian Lance Taylor <iant at google dot com>
- To: Diego Novillo <dnovillo at google dot com>
- Cc: Daniel Berlin <dannyb at google dot com>, Ken Zadeck <zadeck at naturalbridge dot com>, gcc <gcc at gcc dot gnu dot org>
- Date: Fri, 18 May 2012 10:59:20 -0700
- Subject: Re: Use of stack VECs in df-scan.c:df_bb_verify
- References: <4FB67579.5070905@google.com>
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