diff mbox

Preserve return statements at -O0

Message ID 201104060857.10184.ebotcazou@adacore.com
State New
Headers show

Commit Message

Eric Botcazou April 6, 2011, 6:57 a.m. UTC
Hi,

this patchlet ensures that return statements are preserved at -O0 so that you 
can put a breakpoint on them in the debugger.

Bootstrapped/regtested on x86_64-suse-linux, OK for the mainline?


2011-04-06  Eric Botcazou  <ebotcazou@adacore.com>

	* gimple-low.c (lower_gimple_return): When not optimizing, force
	labels associated with user returns to be preserved.


2011-04-06  Eric Botcazou  <ebotcazou@adacore.com>

	* gnat.dg/return3.adb: New test.

Comments

Richard Biener April 6, 2011, 9:18 a.m. UTC | #1
On Wed, Apr 6, 2011 at 8:57 AM, Eric Botcazou <ebotcazou@adacore.com> wrote:
> Hi,
>
> this patchlet ensures that return statements are preserved at -O0 so that you
> can put a breakpoint on them in the debugger.
>
> Bootstrapped/regtested on x86_64-suse-linux, OK for the mainline?

Ok.

Thanks,
Richard.

>
> 2011-04-06  Eric Botcazou  <ebotcazou@adacore.com>
>
>        * gimple-low.c (lower_gimple_return): When not optimizing, force
>        labels associated with user returns to be preserved.
>
>
> 2011-04-06  Eric Botcazou  <ebotcazou@adacore.com>
>
>        * gnat.dg/return3.adb: New test.
>
>
> --
> Eric Botcazou
>
Steven Bosscher April 6, 2011, 6:07 p.m. UTC | #2
On Wed, Apr 6, 2011 at 8:57 AM, Eric Botcazou <ebotcazou@adacore.com> wrote:
> this patchlet ensures that return statements are preserved at -O0 so that you
> can put a breakpoint on them in the debugger.

Isn't one of the effects of this patch to generate debug info for the
artificial label decl?

When I first saw your patch, I thought "FORCED_LABEL()", perhaps I'm
not sure that it's any better than your solution... Have you tried
that?

Ciao!
Steven
Eric Botcazou April 6, 2011, 6:23 p.m. UTC | #3
> Isn't one of the effects of this patch to generate debug info for the
> artificial label decl?

No, DECL_IGNORED_P is preserved on the label decl.

> When I first saw your patch, I thought "FORCED_LABEL()", perhaps I'm
> not sure that it's any better than your solution... Have you tried
> that?

No, that isn't necessary at -O0 IMO, user labels are explicitly preserved.
diff mbox

Patch

Index: gimple-low.c
===================================================================
--- gimple-low.c	(revision 172018)
+++ gimple-low.c	(working copy)
@@ -758,6 +758,9 @@  lower_gimple_return (gimple_stmt_iterato
 
   /* Generate a goto statement and remove the return statement.  */
  found:
+  /* When not optimizing, make sure user returns are preserved.  */
+  if (!optimize && gimple_has_location (stmt))
+    DECL_ARTIFICIAL (tmp_rs.label) = 0;
   t = gimple_build_goto (tmp_rs.label);
   gimple_set_location (t, gimple_location (stmt));
   gimple_set_block (t, gimple_block (stmt));