public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: Function clobber_return_register
@ 2002-12-12  5:17 Richard Kenner
  0 siblings, 0 replies; 5+ messages in thread
From: Richard Kenner @ 2002-12-12  5:17 UTC (permalink / raw)
  To: rth; +Cc: gcc

    So can I see this abort on mainline, or is it only reproducible
    in ACT trees?

Well, it isn't an abort, just bad code generated (the restore of $0 is
deleted).

I doubt the Ada sources matter since there isn't much involved at that level,
so that shouldn't be an issue.  However, I found out yesterday that it
requires the following GCC patch (which has not yet been submitted: I'm
waiting for after the 3.3 release) in order to trigger it, though I strongly
doubt the patch itself is the problem:

*** explow.c    23 Aug 2002 12:00:35 -0000      1.91.6.1
--- explow.c    12 Dec 2002 13:08:50 -0000
*************** emit_stack_restore (save_level, sa, afte
*** 1077,1081 ****
--- 1077,1088 ----
 
    if (sa != 0)
+     {
      sa = validize_mem (sa);
+       /* This clobber prevents the scheduler from moving
+        references to variable arrays below the code
+        that deletes (pops) the arrays. */
+       emit_insn (gen_rtx_CLOBBER (VOIDmode,
+                  gen_rtx_MEM (BLKmode, stack_pointer_rtx)));
+     }
 
    if (after)

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

* Re: Function clobber_return_register
  2002-12-11 19:18 Richard Kenner
@ 2002-12-12  0:09 ` Richard Henderson
  0 siblings, 0 replies; 5+ messages in thread
From: Richard Henderson @ 2002-12-12  0:09 UTC (permalink / raw)
  To: Richard Kenner; +Cc: gcc

On Wed, Dec 11, 2002 at 09:29:16PM -0500, Richard Kenner wrote:
> I think you are saying that what's wrong is likely
> whatever did that redirection, however, most things after
> reload (where we are here) ignore standalone USE and CLOBBERs.

Possibly.  The clobber of the return register is special though.
See flow_active_insn_p.

So can I see this abort on mainline, or is it only reproducible
in ACT trees?


r~

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

* Re: Function clobber_return_register
@ 2002-12-11 19:18 Richard Kenner
  2002-12-12  0:09 ` Richard Henderson
  0 siblings, 1 reply; 5+ messages in thread
From: Richard Kenner @ 2002-12-11 19:18 UTC (permalink / raw)
  To: rth; +Cc: gcc

  /* Before the return label (if any), clobber the return
     registers so that they are not propagated live to the rest of
     the function.  This can only happen with functions that drop
     through; if there had been a return statement, there would
     have either been a return rtx, or a jump to the return label.

But there *was* a jump to the return label and the clobbering was
still done, so I'm confused.

What we had was a CLOBBER, the return label, and a USE.  Then
something (so far undetermined) removed the return label and
redirected the return jump, so that there was a CLOBBER immediately
followed by the USE.  I think you are saying that what's wrong is likely
whatever did that redirection, however, most things after reload (where we
are here) ignore standalone USE and CLOBBERs.

    Since this works for C++, I can only guess that the Ada front
    end isn't generating either returns or cleanups the way the
    back end is expecting.

Well, it actually works fine in most Ada cases and indeed even in this
case until a fix was made to prevent uses of SP from being scheduled
after an assignment to the SP by adding a (clobber (mem:BLK SP)) when
restoring the stack.  So there's something very peculiar about the
precise RTL here.

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

* Re: Function clobber_return_register
  2002-12-11 15:59 Richard Kenner
@ 2002-12-11 16:44 ` Richard Henderson
  0 siblings, 0 replies; 5+ messages in thread
From: Richard Henderson @ 2002-12-11 16:44 UTC (permalink / raw)
  To: Richard Kenner; +Cc: gcc

On Wed, Dec 11, 2002 at 06:59:57PM -0500, Richard Kenner wrote:
> Can somebody explain what this function is for?  There are no comments
> in front of this function (or do_clobber_return_reg) saying what it does.

It generates a clobber of the return register.  I thought that
was pretty obvious.

Oh you mean *why*.  See expand_function_end and
check_function_return_warnings.  In particular,

  /* Before the return label (if any), clobber the return
     registers so that they are not propagated live to the rest of
     the function.  This can only happen with functions that drop
     through; if there had been a return statement, there would
     have either been a return rtx, or a jump to the return label.

     We delay actual code generation after the current_function_value_rtx
     is computed.  */
  clobber_after = get_last_insn ();

In expand_function_end, note that immediately afterward, the return_label
is emitted, followed by cleanups.

In check_function_return_warnings, note that we've already deleted
unreachable code, so if the clobber insn still exists, it means that
the function reaches the end without returning a value.

> The test case is this tiny Ada code:
> 
> function Tretcln return Integer is
>    S : String := Integer'Image (1);
>    function Ret1 return integer is begin return 1; end;
> begin
>    return Ret1;
> end Tretcln;
> 
> and the issue is that there is a cleanup (due to the 'Image)
> for this function.
> Due to the CLOBBER and USE now being in the same basic block, that block is
> marked as not having $0 live, so the restore of $0 is deleted as a dead insn
> and thus the return value of Ret1 is being lost in the return of Tretcln.

Since this works for C++, I can only guess that the Ada front
end isn't generating either returns or cleanups the way the
back end is expecting.


r~

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

* Function clobber_return_register
@ 2002-12-11 15:59 Richard Kenner
  2002-12-11 16:44 ` Richard Henderson
  0 siblings, 1 reply; 5+ messages in thread
From: Richard Kenner @ 2002-12-11 15:59 UTC (permalink / raw)
  To: gcc

Can somebody explain what this function is for?  There are no comments
in front of this function (or do_clobber_return_reg) saying what it does.

What I have on Alpha is this in 22.postreload:

(insn 300 361 297 (clobber (reg/i:DI 0 $0)) -1 (insn_list:REG_DEP_ANTI 283 (insn_list:REG_DEP_ANTI 286 (nil)))
    (nil))
;; End of basic block 29, registers live:
 15 [$15] 26 [$26] 29 [$29] 30 [$30] 31 [AP] 63 [FP] 69

;; Start of basic block 30, registers live: 15 [$15] 26 [$26] 29 [$29] 30 [$30] 69
(code_label 297 300 341 1 "" "" [1 uses])

(note 341 297 299 [bb 30] NOTE_INSN_BASIC_BLOCK)

(insn 299 341 302 (use (reg/i:DI 0 $0)) -1 (nil)

In 23.flow2, things have been rearranged in a way that I can't follow, but
now there's no label between the CLOBBER and the USE.

The test case is this tiny Ada code:

function Tretcln return Integer is
   S : String := Integer'Image (1);
   function Ret1 return integer is begin return 1; end;
begin
   return Ret1;
end Tretcln;

and the issue is that there is a cleanup (due to the 'Image) for this function.
Due to the CLOBBER and USE now being in the same basic block, that block is
marked as not having $0 live, so the restore of $0 is deleted as a dead insn
and thus the return value of Ret1 is being lost in the return of Tretcln.

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

end of thread, other threads:[~2002-12-12 13:11 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-12-12  5:17 Function clobber_return_register Richard Kenner
  -- strict thread matches above, loose matches on Subject: below --
2002-12-11 19:18 Richard Kenner
2002-12-12  0:09 ` Richard Henderson
2002-12-11 15:59 Richard Kenner
2002-12-11 16:44 ` Richard Henderson

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).