This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix PR89463 (and dups?), wrong-debug with loop removal
- From: Richard Biener <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Cc: aoliva at redhat dot com
- Date: Wed, 27 Mar 2019 10:33:30 +0100 (CET)
- Subject: Re: [PATCH] Fix PR89463 (and dups?), wrong-debug with loop removal
- References: <alpine.LSU.2.20.1903251457290.4934@zhemvz.fhfr.qr>
On Mon, 25 Mar 2019, Richard Biener wrote:
>
> This PR and possibly quite some dups that have been accumulating lately
> run into an artifact of DCEs edge removal code when generating debug
> stmts. Here DCE removes edges from the CFG at the same time it removes
> dead controlling stmts but before PHI nodes are removed. This causes
> us to remove PHI arguments associated with removed edges and make
> those PHI appearing as degenerate, causing wrong debug stmts to be
> generated. Consider for example i_1 = PHI <i_2, 0> where the edge
> leading to i_2 is removed - at the time we remove the PHI it looks
> like i_1 = PHI <0> and a i = 0 debug-stmt is generated.
>
> The fix is to delay edge removal and move PHI removal back to the
> place it had originally been, doing that in reverse dominator order
> as intended for debug stmt creation (it jumped from where it'll be
> after the patch to all-before to all-after).
>
> The testcase shows up as UNRESOLVED where it formerly was
> wrong-debug because we change from i = 0 to i = NULL. I've seen
> no way to mark "optimized-out" as expected and at -O1 we
> retain the loop and the correct value of i.
>
> Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.
>
> OK (well, I think it is, just double-checking).
I have applied this now, it doesn't immediately solve any of the
other issues.
Richard.