public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Add verifier for leaked SSA names
@ 2015-10-02  7:37 Richard Biener
  2015-10-02 15:24 ` Jeff Law
  0 siblings, 1 reply; 4+ messages in thread
From: Richard Biener @ 2015-10-02  7:37 UTC (permalink / raw)
  To: gcc-patches; +Cc: law


The following patch doesn't pass bootstrap & regtest.  It did at some
point though and its comment hints that fixing leaks after inlining
was too interesting a problem to solve ;)

Thus patch is FYI.

Richard.

Index: tree-ssa.c
===================================================================
--- tree-ssa.c  (revision 228320)
+++ tree-ssa.c  (working copy)
@@ -693,6 +693,16 @@ verify_def (basic_block bb, basic_block
       goto err;
     }
 
+  if (bb == NULL
+      /* ???  Too many latent cases in the main opt pipeline.  But it's
+         worth to fix all cases before inlining as that reduces the
+        amount of garbage kept live.  */
+      && !cfun->after_inlining)
+    {
+      error ("removed STMT failed to release SSA name");
+      goto err;
+    }
+
   if (definition_block[SSA_NAME_VERSION (ssa_name)])
     {
       error ("SSA_NAME created in two different blocks %i and %i",

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Add verifier for leaked SSA names
  2015-10-02  7:37 [PATCH] Add verifier for leaked SSA names Richard Biener
@ 2015-10-02 15:24 ` Jeff Law
  2015-10-05  8:56   ` Richard Biener
  0 siblings, 1 reply; 4+ messages in thread
From: Jeff Law @ 2015-10-02 15:24 UTC (permalink / raw)
  To: Richard Biener, gcc-patches

On 10/02/2015 01:37 AM, Richard Biener wrote:
>
> The following patch doesn't pass bootstrap & regtest.  It did at some
> point though and its comment hints that fixing leaks after inlining
> was too interesting a problem to solve ;)
>
> Thus patch is FYI.
>
> Richard.
>
> Index: tree-ssa.c
> ===================================================================
> --- tree-ssa.c  (revision 228320)
> +++ tree-ssa.c  (working copy)
> @@ -693,6 +693,16 @@ verify_def (basic_block bb, basic_block
>         goto err;
>       }
>
> +  if (bb == NULL
> +      /* ???  Too many latent cases in the main opt pipeline.  But it's
> +         worth to fix all cases before inlining as that reduces the
> +        amount of garbage kept live.  */
> +      && !cfun->after_inlining)
> +    {
> +      error ("removed STMT failed to release SSA name");
> +      goto err;
> +    }
> +
I was building the verification step into the ssa name manager. 
Essentially at the point where we flush from the pending to the free 
list, we should have a consistent state.

Thus we ought to be able to walk the IL marking everything we can see, 
combine that with the contents of the freelist and the result ought to 
be every SSA_NAME ever created.

Reality is somewhat different, of course.

Yours takes a slightly different approach.  Ultimately if we get the 
leaks plugged, we might even consider using both.

jeff



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Add verifier for leaked SSA names
  2015-10-02 15:24 ` Jeff Law
@ 2015-10-05  8:56   ` Richard Biener
  2015-10-05 15:39     ` Jeff Law
  0 siblings, 1 reply; 4+ messages in thread
From: Richard Biener @ 2015-10-05  8:56 UTC (permalink / raw)
  To: Jeff Law; +Cc: Richard Biener, GCC Patches

On Fri, Oct 2, 2015 at 5:24 PM, Jeff Law <law@redhat.com> wrote:
> On 10/02/2015 01:37 AM, Richard Biener wrote:
>>
>>
>> The following patch doesn't pass bootstrap & regtest.  It did at some
>> point though and its comment hints that fixing leaks after inlining
>> was too interesting a problem to solve ;)
>>
>> Thus patch is FYI.
>>
>> Richard.
>>
>> Index: tree-ssa.c
>> ===================================================================
>> --- tree-ssa.c  (revision 228320)
>> +++ tree-ssa.c  (working copy)
>> @@ -693,6 +693,16 @@ verify_def (basic_block bb, basic_block
>>         goto err;
>>       }
>>
>> +  if (bb == NULL
>> +      /* ???  Too many latent cases in the main opt pipeline.  But it's
>> +         worth to fix all cases before inlining as that reduces the
>> +        amount of garbage kept live.  */
>> +      && !cfun->after_inlining)
>> +    {
>> +      error ("removed STMT failed to release SSA name");
>> +      goto err;
>> +    }
>> +
>
> I was building the verification step into the ssa name manager. Essentially
> at the point where we flush from the pending to the free list, we should
> have a consistent state.

Yeah, though when SSA verifiers run the state should also be consistent
and we'd get to pinpoint the offending pass easier.

> Thus we ought to be able to walk the IL marking everything we can see,
> combine that with the contents of the freelist and the result ought to be
> every SSA_NAME ever created.
>
> Reality is somewhat different, of course.
>
> Yours takes a slightly different approach.  Ultimately if we get the leaks
> plugged, we might even consider using both.

Sure.  Note that the above is from simply walking all SSA names.

Richard.

> jeff
>
>
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Add verifier for leaked SSA names
  2015-10-05  8:56   ` Richard Biener
@ 2015-10-05 15:39     ` Jeff Law
  0 siblings, 0 replies; 4+ messages in thread
From: Jeff Law @ 2015-10-05 15:39 UTC (permalink / raw)
  To: Richard Biener; +Cc: Richard Biener, GCC Patches

On 10/05/2015 02:56 AM, Richard Biener wrote:
>> I was building the verification step into the ssa name manager. Essentially
>> at the point where we flush from the pending to the free list, we should
>> have a consistent state.
>
> Yeah, though when SSA verifiers run the state should also be consistent
> and we'd get to pinpoint the offending pass easier.
Agreed.

>
>> Thus we ought to be able to walk the IL marking everything we can see,
>> combine that with the contents of the freelist and the result ought to be
>> every SSA_NAME ever created.
>>
>> Reality is somewhat different, of course.
>>
>> Yours takes a slightly different approach.  Ultimately if we get the leaks
>> plugged, we might even consider using both.
>
> Sure.  Note that the above is from simply walking all SSA names.
Right.  That's precisely what I was referring to.  Yours walks the 
SSA_NAMEs and declares those with an empty block for the defining 
statement as leaks.

Mine walks the IL and declares any name that was allocated, but not 
found in the IL as a leak.

Mine is obviously more expensive, but possibly catches more leaks.

The one conclusion I did come to over the weekend is that without a 
recycle immediate policy, there's no value in explicitly releasing the 
names.  ie, we could just drop all the explicit management and rely on 
garbage collection at safe points.

If we added either a mode to allow immediate recycling or an adaptive 
behaviour in the manager to recycle immediately until it wasn't safe to 
do so, then there's obviously value in the explicit releases and 
plugging  the leaks.

jeff


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-10-05 15:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-02  7:37 [PATCH] Add verifier for leaked SSA names Richard Biener
2015-10-02 15:24 ` Jeff Law
2015-10-05  8:56   ` Richard Biener
2015-10-05 15:39     ` Jeff Law

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).