This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

sibcall tweek


Hi,
this patch makes sibcall to recognize case with unreturned value,
such as

a()
{
  b();
}

Still there is problem remaining with multiple exit points, as before
exit basic block, another basic block is emitted that contains the clobber.
Sibcall refuses to recognize the call, as it checks whether EXIT_BLOCK
is call's block suceesor.

That would require more changes to get it working, and can reuse
function from this patch.


Thu Jun  7 15:35:25 CEST 2001  Jan Hubicka  <jh@suse.cz>
	* sibcall.c (skip_use_of_return_value): New function.
	(call_ends_block_p): Use it.

Index: sibcall.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/sibcall.c,v
retrieving revision 1.17
diff -c -3 -p -r1.17 sibcall.c
*** sibcall.c	2001/06/04 20:20:35	1.17
--- sibcall.c	2001/06/07 13:35:12
*************** skip_use_of_return_value (orig_insn, cod
*** 220,225 ****
--- 220,254 ----
    return orig_insn;
  }
  
+ /* In case function does not return value,  we get clobber of pseudo followed
+    by set to hard return value.  */
+ rtx
+ skip_unreturned_value (orig_insn)
+      rtx orig_insn;
+ {
+   rtx insn = next_nonnote_insn (orig_insn);
+ 
+   /* Skip possible clobber of pseudo return register.  */
+   if (insn
+       && GET_CODE (insn) == INSN
+       && GET_CODE (PATTERN (insn)) == CLOBBER
+       && REG_P (XEXP (PATTERN (insn), 0))
+       && (REGNO (XEXP (PATTERN (insn), 0)) >= FIRST_PSEUDO_REGISTER))
+     {
+       rtx set_insn = next_nonnote_insn (insn);
+       rtx set;
+       if (!set_insn)
+ 	return insn;
+       set = single_set (set_insn);
+       if (!set
+ 	  || SET_SRC (set) != XEXP (PATTERN (insn), 0)
+ 	  || SET_DEST (set) != current_function_return_rtx)
+ 	return insn;
+       return set_insn;
+     }
+   return orig_insn;
+ }
+ 
  /* If the first real insn after ORIG_INSN adjusts the stack pointer
     by a constant, return the insn with the stack pointer adjustment.
     Otherwise return ORIG_INSN.  */
*************** call_ends_block_p (insn, end)
*** 314,319 ****
--- 343,353 ----
  
    /* Skip over a CLOBBER of the return value as a hard reg.  */
    insn = skip_use_of_return_value (insn, CLOBBER);
+   if (insn == end)
+     return 1;
+ 
+   /* Skip over a CLOBBER of the return value as a hard reg.  */
+   insn = skip_unreturned_value (insn);
    if (insn == end)
      return 1;
  


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]