OSDN Git Service

* cppinit.c (cpp_start_read): Free the imacros list as we
[pf3gnuchains/gcc-fork.git] / gcc / sibcall.c
1 /* Generic sibling call optimization support
2    Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
3
4 This file is part of GCC.
5
6 GCC is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 2, or (at your option) any later
9 version.
10
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14 for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING.  If not, write to the Free
18 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
19 02111-1307, USA.  */
20
21 #include "config.h"
22 #include "system.h"
23
24 #include "rtl.h"
25 #include "regs.h"
26 #include "function.h"
27 #include "hard-reg-set.h"
28 #include "flags.h"
29 #include "insn-config.h"
30 #include "recog.h"
31 #include "basic-block.h"
32 #include "output.h"
33 #include "except.h"
34
35 /* In case alternate_exit_block contains copy from pseudo, to return value,
36    record the pseudo here.  In such case the pseudo must be set to function
37    return in the sibcall sequence.  */
38 static rtx return_value_pseudo;
39
40 static int identify_call_return_value   PARAMS ((rtx, rtx *, rtx *));
41 static rtx skip_copy_to_return_value    PARAMS ((rtx));
42 static rtx skip_use_of_return_value     PARAMS ((rtx, enum rtx_code));
43 static rtx skip_stack_adjustment        PARAMS ((rtx));
44 static rtx skip_pic_restore             PARAMS ((rtx));
45 static rtx skip_jump_insn               PARAMS ((rtx));
46 static int call_ends_block_p            PARAMS ((rtx, rtx));
47 static int uses_addressof               PARAMS ((rtx));
48 static int sequence_uses_addressof      PARAMS ((rtx));
49 static void purge_reg_equiv_notes       PARAMS ((void));
50 static void purge_mem_unchanging_flag   PARAMS ((rtx));
51 static rtx skip_unreturned_value        PARAMS ((rtx));
52
53 /* Examine a CALL_PLACEHOLDER pattern and determine where the call's
54    return value is located.  P_HARD_RETURN receives the hard register
55    that the function used; P_SOFT_RETURN receives the pseudo register
56    that the sequence used.  Return non-zero if the values were located.  */
57
58 static int
59 identify_call_return_value (cp, p_hard_return, p_soft_return)
60      rtx cp;
61      rtx *p_hard_return, *p_soft_return;
62 {
63   rtx insn, set, hard, soft;
64
65   insn = XEXP (cp, 0);
66   /* Search backward through the "normal" call sequence to the CALL insn.  */
67   while (NEXT_INSN (insn))
68     insn = NEXT_INSN (insn);
69   while (GET_CODE (insn) != CALL_INSN)
70     insn = PREV_INSN (insn);
71
72   /* Assume the pattern is (set (dest) (call ...)), or that the first
73      member of a parallel is.  This is the hard return register used
74      by the function.  */
75   if (GET_CODE (PATTERN (insn)) == SET
76       && GET_CODE (SET_SRC (PATTERN (insn))) == CALL)
77     hard = SET_DEST (PATTERN (insn));
78   else if (GET_CODE (PATTERN (insn)) == PARALLEL
79            && GET_CODE (XVECEXP (PATTERN (insn), 0, 0)) == SET
80            && GET_CODE (SET_SRC (XVECEXP (PATTERN (insn), 0, 0))) == CALL)
81     hard = SET_DEST (XVECEXP (PATTERN (insn), 0, 0));
82   else
83     return 0;
84
85   /* If we didn't get a single hard register (e.g. a parallel), give up.  */
86   if (GET_CODE (hard) != REG)
87     return 0;
88     
89   /* Stack adjustment done after call may appear here.  */
90   insn = skip_stack_adjustment (insn);
91   if (! insn)
92     return 0;
93
94   /* Restore of GP register may appear here.  */
95   insn = skip_pic_restore (insn);
96   if (! insn)
97     return 0;
98
99   /* If there's nothing after, there's no soft return value.  */
100   insn = NEXT_INSN (insn);
101   if (! insn)
102     return 0;
103   
104   /* We're looking for a source of the hard return register.  */
105   set = single_set (insn);
106   if (! set || SET_SRC (set) != hard)
107     return 0;
108
109   soft = SET_DEST (set);
110   insn = NEXT_INSN (insn);
111
112   /* Allow this first destination to be copied to a second register,
113      as might happen if the first register wasn't the particular pseudo
114      we'd been expecting.  */
115   if (insn
116       && (set = single_set (insn)) != NULL_RTX
117       && SET_SRC (set) == soft)
118     {
119       soft = SET_DEST (set);
120       insn = NEXT_INSN (insn);
121     }
122
123   /* Don't fool with anything but pseudo registers.  */
124   if (GET_CODE (soft) != REG || REGNO (soft) < FIRST_PSEUDO_REGISTER)
125     return 0;
126
127   /* This value must not be modified before the end of the sequence.  */
128   if (reg_set_between_p (soft, insn, NULL_RTX))
129     return 0;
130
131   *p_hard_return = hard;
132   *p_soft_return = soft;
133
134   return 1;
135 }
136
137 /* If the first real insn after ORIG_INSN copies to this function's
138    return value from RETVAL, then return the insn which performs the
139    copy.  Otherwise return ORIG_INSN.  */
140
141 static rtx
142 skip_copy_to_return_value (orig_insn)
143      rtx orig_insn;
144 {
145   rtx insn, set = NULL_RTX;
146   rtx hardret, softret;
147
148   /* If there is no return value, we have nothing to do.  */
149   if (! identify_call_return_value (PATTERN (orig_insn), &hardret, &softret))
150     return orig_insn;
151
152   insn = next_nonnote_insn (orig_insn);
153   if (! insn)
154     return orig_insn;
155
156   set = single_set (insn);
157   if (! set)
158     return orig_insn;
159
160   if (return_value_pseudo)
161     {
162       if (SET_DEST (set) == return_value_pseudo)
163         return insn;
164       return orig_insn;
165     }
166
167   /* The destination must be the same as the called function's return
168      value to ensure that any return value is put in the same place by the
169      current function and the function we're calling. 
170
171      Further, the source must be the same as the pseudo into which the
172      called function's return value was copied.  Otherwise we're returning
173      some other value.  */
174
175 #ifndef OUTGOING_REGNO
176 #define OUTGOING_REGNO(N) (N)
177 #endif
178
179   if (SET_DEST (set) == current_function_return_rtx
180       && REG_P (SET_DEST (set))
181       && OUTGOING_REGNO (REGNO (SET_DEST (set))) == REGNO (hardret)
182       && SET_SRC (set) == softret)
183     return insn;
184
185   /* Recognize the situation when the called function's return value
186      is copied in two steps: first into an intermediate pseudo, then
187      the into the calling functions return value register.  */
188
189   if (REG_P (SET_DEST (set))
190       && SET_SRC (set) == softret)
191     {
192       rtx x = SET_DEST (set);
193
194       insn = next_nonnote_insn (insn);
195       if (! insn)
196         return orig_insn;
197
198       set = single_set (insn);
199       if (! set)
200         return orig_insn;
201
202       if (SET_DEST (set) == current_function_return_rtx
203           && REG_P (SET_DEST (set))
204           && OUTGOING_REGNO (REGNO (SET_DEST (set))) == REGNO (hardret)
205           && SET_SRC (set) == x)
206         return insn;
207     }
208
209   /* It did not look like a copy of the return value, so return the
210      same insn we were passed.  */
211   return orig_insn;
212 }
213
214 /* If the first real insn after ORIG_INSN is a CODE of this function's return
215    value, return insn.  Otherwise return ORIG_INSN.  */
216
217 static rtx
218 skip_use_of_return_value (orig_insn, code)
219      rtx orig_insn;
220      enum rtx_code code;
221 {
222   rtx insn;
223
224   insn = next_nonnote_insn (orig_insn);
225
226   if (insn
227       && GET_CODE (insn) == INSN
228       && GET_CODE (PATTERN (insn)) == code
229       && (XEXP (PATTERN (insn), 0) == current_function_return_rtx
230           || XEXP (PATTERN (insn), 0) == const0_rtx))
231     return insn;
232
233   return orig_insn;
234 }
235
236 /* In case function does not return value,  we get clobber of pseudo followed
237    by set to hard return value.  */
238 static rtx
239 skip_unreturned_value (orig_insn)
240      rtx orig_insn;
241 {
242   rtx insn = next_nonnote_insn (orig_insn);
243
244   /* Skip possible clobber of pseudo return register.  */
245   if (insn
246       && GET_CODE (insn) == INSN
247       && GET_CODE (PATTERN (insn)) == CLOBBER
248       && REG_P (XEXP (PATTERN (insn), 0))
249       && (REGNO (XEXP (PATTERN (insn), 0)) >= FIRST_PSEUDO_REGISTER))
250     {
251       rtx set_insn = next_nonnote_insn (insn);
252       rtx set;
253       if (!set_insn)
254         return insn;
255       set = single_set (set_insn);
256       if (!set
257           || SET_SRC (set) != XEXP (PATTERN (insn), 0)
258           || SET_DEST (set) != current_function_return_rtx)
259         return insn;
260       return set_insn;
261     }
262   return orig_insn;
263 }
264
265 /* If the first real insn after ORIG_INSN adjusts the stack pointer
266    by a constant, return the insn with the stack pointer adjustment.
267    Otherwise return ORIG_INSN.  */
268
269 static rtx
270 skip_stack_adjustment (orig_insn)
271      rtx orig_insn;
272 {
273   rtx insn, set = NULL_RTX;
274
275   insn = next_nonnote_insn (orig_insn);
276
277   if (insn)
278     set = single_set (insn);
279
280   if (insn
281       && set
282       && GET_CODE (SET_SRC (set)) == PLUS
283       && XEXP (SET_SRC (set), 0) == stack_pointer_rtx
284       && GET_CODE (XEXP (SET_SRC (set), 1)) == CONST_INT
285       && SET_DEST (set) == stack_pointer_rtx)
286     return insn;
287
288   return orig_insn;
289 }
290
291 /* If the first real insn after ORIG_INSN sets the pic register,
292    return it.  Otherwise return ORIG_INSN.  */
293
294 static rtx
295 skip_pic_restore (orig_insn)
296      rtx orig_insn;
297 {
298   rtx insn, set = NULL_RTX;
299
300   insn = next_nonnote_insn (orig_insn);
301
302   if (insn)
303     set = single_set (insn);
304
305   if (insn && set && SET_DEST (set) == pic_offset_table_rtx)
306     return insn;
307
308   return orig_insn;
309 }
310
311 /* If the first real insn after ORIG_INSN is a jump, return the JUMP_INSN.
312    Otherwise return ORIG_INSN.  */
313
314 static rtx
315 skip_jump_insn (orig_insn)
316      rtx orig_insn;
317 {
318   rtx insn;
319
320   insn = next_nonnote_insn (orig_insn);
321
322   if (insn
323       && GET_CODE (insn) == JUMP_INSN
324       && any_uncondjump_p (insn))
325     return insn;
326
327   return orig_insn;
328 }
329 \f
330 /* Using the above functions, see if INSN, skipping any of the above,
331    goes all the way to END, the end of a basic block.  Return 1 if so.  */
332
333 static int
334 call_ends_block_p (insn, end)
335      rtx insn;
336      rtx end;
337 {
338   rtx new_insn;
339   /* END might be a note, so get the last nonnote insn of the block.  */
340   end = next_nonnote_insn (PREV_INSN (end));
341
342   /* If the call was the end of the block, then we're OK.  */
343   if (insn == end)
344     return 1;
345
346   /* Skip over copying from the call's return value pseudo into
347      this function's hard return register and if that's the end
348      of the block, we're OK.  */
349   new_insn = skip_copy_to_return_value (insn);
350
351   /* In case we return value in pseudo, we must set the pseudo to
352      return value of called function, otherwise we are returning
353      something else.  */
354   if (return_value_pseudo && insn == new_insn)
355     return 0;
356   insn = new_insn;
357
358   if (insn == end)
359     return 1;
360
361   /* Skip any stack adjustment.  */
362   insn = skip_stack_adjustment (insn);
363   if (insn == end)
364     return 1;
365
366   /* Skip over a CLOBBER of the return value as a hard reg.  */
367   insn = skip_use_of_return_value (insn, CLOBBER);
368   if (insn == end)
369     return 1;
370
371   /* Skip over a CLOBBER of the return value as a hard reg.  */
372   insn = skip_unreturned_value (insn);
373   if (insn == end)
374     return 1;
375
376   /* Skip over a USE of the return value (as a hard reg).  */
377   insn = skip_use_of_return_value (insn, USE);
378   if (insn == end)
379     return 1;
380
381   /* Skip over a JUMP_INSN at the end of the block.  If that doesn't end the
382      block, the original CALL_INSN didn't.  */
383   insn = skip_jump_insn (insn);
384   return insn == end;
385 }
386
387 /* Scan the rtx X for ADDRESSOF expressions or
388    current_function_internal_arg_pointer registers.
389    Return nonzero if an ADDRESSOF or current_function_internal_arg_pointer
390    is found outside of some MEM expression, else return zero.  */
391
392 static int
393 uses_addressof (x)
394      rtx x;
395 {
396   RTX_CODE code;
397   int i, j;
398   const char *fmt;
399
400   if (x == NULL_RTX)
401     return 0;
402
403   code = GET_CODE (x);
404
405   if (code == ADDRESSOF || x == current_function_internal_arg_pointer)
406     return 1;
407
408   if (code == MEM)
409     return 0;
410
411   /* Scan all subexpressions.  */
412   fmt = GET_RTX_FORMAT (code);
413   for (i = 0; i < GET_RTX_LENGTH (code); i++, fmt++)
414     {
415       if (*fmt == 'e')
416         {
417           if (uses_addressof (XEXP (x, i)))
418             return 1;
419         }
420       else if (*fmt == 'E')
421         {
422           for (j = 0; j < XVECLEN (x, i); j++)
423             if (uses_addressof (XVECEXP (x, i, j)))
424               return 1;
425         }
426     }
427   return 0;
428 }
429
430 /* Scan the sequence of insns in SEQ to see if any have an ADDRESSOF
431    rtl expression or current_function_internal_arg_pointer occurences
432    not enclosed within a MEM.  If an ADDRESSOF expression or
433    current_function_internal_arg_pointer is found, return nonzero, otherwise
434    return zero.
435
436    This function handles CALL_PLACEHOLDERs which contain multiple sequences
437    of insns.  */
438
439 static int
440 sequence_uses_addressof (seq)
441      rtx seq;
442 {
443   rtx insn;
444
445   for (insn = seq; insn; insn = NEXT_INSN (insn))
446     if (INSN_P (insn))
447       {
448         /* If this is a CALL_PLACEHOLDER, then recursively call ourselves
449            with each nonempty sequence attached to the CALL_PLACEHOLDER.  */
450         if (GET_CODE (insn) == CALL_INSN
451             && GET_CODE (PATTERN (insn)) == CALL_PLACEHOLDER)
452           {
453             if (XEXP (PATTERN (insn), 0) != NULL_RTX
454                 && sequence_uses_addressof (XEXP (PATTERN (insn), 0)))
455               return 1;
456             if (XEXP (PATTERN (insn), 1) != NULL_RTX
457                 && sequence_uses_addressof (XEXP (PATTERN (insn), 1)))
458               return 1;
459             if (XEXP (PATTERN (insn), 2) != NULL_RTX
460                 && sequence_uses_addressof (XEXP (PATTERN (insn), 2)))
461               return 1;
462           }
463         else if (uses_addressof (PATTERN (insn))
464                  || (REG_NOTES (insn) && uses_addressof (REG_NOTES (insn))))
465           return 1;
466       }
467   return 0;
468 }
469
470 /* Remove all REG_EQUIV notes found in the insn chain.  */
471
472 static void
473 purge_reg_equiv_notes ()
474 {
475   rtx insn;
476
477   for (insn = get_insns (); insn; insn = NEXT_INSN (insn))
478     {
479       while (1)
480         {
481           rtx note = find_reg_note (insn, REG_EQUIV, 0);
482           if (note)
483             {
484               /* Remove the note and keep looking at the notes for
485                  this insn.  */
486               remove_note (insn, note);
487               continue;
488             }
489           break;
490         }
491     }
492 }
493
494 /* Clear RTX_UNCHANGING_P flag of incoming argument MEMs.  */
495
496 static void
497 purge_mem_unchanging_flag (x)
498      rtx x;
499 {
500   RTX_CODE code;
501   int i, j;
502   const char *fmt;
503
504   if (x == NULL_RTX)
505     return;
506
507   code = GET_CODE (x);
508
509   if (code == MEM)
510     {
511       if (RTX_UNCHANGING_P (x)
512           && (XEXP (x, 0) == current_function_internal_arg_pointer
513               || (GET_CODE (XEXP (x, 0)) == PLUS
514                   && XEXP (XEXP (x, 0), 0) ==
515                      current_function_internal_arg_pointer
516                   && GET_CODE (XEXP (XEXP (x, 0), 1)) == CONST_INT)))
517         RTX_UNCHANGING_P (x) = 0;
518       return;
519     }
520
521   /* Scan all subexpressions.  */
522   fmt = GET_RTX_FORMAT (code);
523   for (i = 0; i < GET_RTX_LENGTH (code); i++, fmt++)
524     {
525       if (*fmt == 'e')
526         purge_mem_unchanging_flag (XEXP (x, i));
527       else if (*fmt == 'E')
528         for (j = 0; j < XVECLEN (x, i); j++)
529           purge_mem_unchanging_flag (XVECEXP (x, i, j));
530     }
531 }
532
533 /* Replace the CALL_PLACEHOLDER with one of its children.  INSN should be
534    the CALL_PLACEHOLDER insn; USE tells which child to use.  */
535
536 void
537 replace_call_placeholder (insn, use)
538      rtx insn;
539      sibcall_use_t use;
540 {
541   if (use == sibcall_use_tail_recursion)
542     emit_insns_before (XEXP (PATTERN (insn), 2), insn);
543   else if (use == sibcall_use_sibcall)
544     emit_insns_before (XEXP (PATTERN (insn), 1), insn);
545   else if (use == sibcall_use_normal)
546     emit_insns_before (XEXP (PATTERN (insn), 0), insn);
547   else
548     abort();
549
550   /* Turn off LABEL_PRESERVE_P for the tail recursion label if it
551      exists.  We only had to set it long enough to keep the jump
552      pass above from deleting it as unused.  */
553   if (XEXP (PATTERN (insn), 3))
554     LABEL_PRESERVE_P (XEXP (PATTERN (insn), 3)) = 0;
555   
556   /* "Delete" the placeholder insn.  */
557   PUT_CODE (insn, NOTE);
558   NOTE_SOURCE_FILE (insn) = 0;
559   NOTE_LINE_NUMBER (insn) = NOTE_INSN_DELETED;
560 }
561
562 /* Given a (possibly empty) set of potential sibling or tail recursion call
563    sites, determine if optimization is possible.
564
565    Potential sibling or tail recursion calls are marked with CALL_PLACEHOLDER
566    insns.  The CALL_PLACEHOLDER insn holds chains of insns to implement a
567    normal call, sibling call or tail recursive call.
568
569    Replace the CALL_PLACEHOLDER with an appropriate insn chain.  */
570
571 void
572 optimize_sibling_and_tail_recursive_calls ()
573 {
574   rtx insn, insns;
575   basic_block alternate_exit = EXIT_BLOCK_PTR;
576   int current_function_uses_addressof;
577   int successful_sibling_call = 0;
578   int replaced_call_placeholder = 0;
579   edge e;
580
581   insns = get_insns ();
582
583   /* We do not perform these calls when flag_exceptions is true, so this
584      is probably a NOP at the current time.  However, we may want to support
585      sibling and tail recursion optimizations in the future, so let's plan
586      ahead and find all the EH labels.  */
587   find_exception_handler_labels ();
588
589   rebuild_jump_labels (insns);
590   /* We need cfg information to determine which blocks are succeeded
591      only by the epilogue.  */
592   find_basic_blocks (insns, max_reg_num (), 0);
593   cleanup_cfg (CLEANUP_PRE_SIBCALL | CLEANUP_PRE_LOOP);
594
595   /* If there are no basic blocks, then there is nothing to do.  */
596   if (n_basic_blocks == 0)
597     return;
598
599   return_value_pseudo = NULL_RTX;
600
601   /* Find the exit block.
602
603      It is possible that we have blocks which can reach the exit block
604      directly.  However, most of the time a block will jump (or fall into)
605      N_BASIC_BLOCKS - 1, which in turn falls into the exit block.  */
606   for (e = EXIT_BLOCK_PTR->pred;
607        e && alternate_exit == EXIT_BLOCK_PTR;
608        e = e->pred_next)
609     {
610       rtx insn;
611
612       if (e->dest != EXIT_BLOCK_PTR || e->succ_next != NULL)
613         continue;
614
615       /* Walk forwards through the last normal block and see if it
616          does nothing except fall into the exit block.  */
617       for (insn = BLOCK_HEAD (n_basic_blocks - 1);
618            insn;
619            insn = NEXT_INSN (insn))
620         {
621           rtx set;
622           /* This should only happen once, at the start of this block.  */
623           if (GET_CODE (insn) == CODE_LABEL)
624             continue;
625
626           if (GET_CODE (insn) == NOTE)
627             continue;
628
629           if (GET_CODE (insn) == INSN
630               && GET_CODE (PATTERN (insn)) == USE)
631             continue;
632
633           /* Exit block also may contain copy from pseudo containing
634              return value to hard register.  */
635           if (GET_CODE (insn) == INSN
636               && (set = single_set (insn))
637               && SET_DEST (set) == current_function_return_rtx
638               && REG_P (SET_SRC (set))
639               && !return_value_pseudo)
640             {
641               return_value_pseudo = SET_SRC (set);
642               continue;
643             }
644
645           break;
646         }
647
648       /* If INSN is zero, then the search walked all the way through the
649          block without hitting anything interesting.  This block is a
650          valid alternate exit block.  */
651       if (insn == NULL)
652         alternate_exit = e->src;
653       else
654         return_value_pseudo = NULL;
655     }
656
657   /* If the function uses ADDRESSOF, we can't (easily) determine
658      at this point if the value will end up on the stack.  */
659   current_function_uses_addressof = sequence_uses_addressof (insns);
660
661   /* Walk the insn chain and find any CALL_PLACEHOLDER insns.  We need to
662      select one of the insn sequences attached to each CALL_PLACEHOLDER.
663
664      The different sequences represent different ways to implement the call,
665      ie, tail recursion, sibling call or normal call.
666
667      Since we do not create nested CALL_PLACEHOLDERs, the scan
668      continues with the insn that was after a replaced CALL_PLACEHOLDER;
669      we don't rescan the replacement insns.  */
670   for (insn = insns; insn; insn = NEXT_INSN (insn))
671     {
672       if (GET_CODE (insn) == CALL_INSN
673           && GET_CODE (PATTERN (insn)) == CALL_PLACEHOLDER)
674         {
675           int sibcall = (XEXP (PATTERN (insn), 1) != NULL_RTX);
676           int tailrecursion = (XEXP (PATTERN (insn), 2) != NULL_RTX);
677           basic_block call_block = BLOCK_FOR_INSN (insn);
678
679           /* alloca (until we have stack slot life analysis) inhibits
680              sibling call optimizations, but not tail recursion.
681              Similarly if we use varargs or stdarg since they implicitly
682              may take the address of an argument.  */
683           if (current_function_calls_alloca
684               || current_function_varargs || current_function_stdarg)
685             sibcall = 0;
686
687           /* See if there are any reasons we can't perform either sibling or
688              tail call optimizations.  We must be careful with stack slots
689              which are live at potential optimization sites.  ??? The first
690              test is overly conservative and should be replaced.  */
691           if (frame_offset
692               /* Can't take address of local var if used by recursive call.  */
693               || current_function_uses_addressof
694               /* Any function that calls setjmp might have longjmp called from
695                  any called function.  ??? We really should represent this
696                  properly in the CFG so that this needn't be special cased.  */
697               || current_function_calls_setjmp
698               /* Can't if more than one successor or single successor is not
699                  exit block.  These two tests prevent tail call optimization
700                  in the presense of active exception handlers.  */
701               || call_block->succ == NULL
702               || call_block->succ->succ_next != NULL
703               || (call_block->succ->dest != EXIT_BLOCK_PTR
704                   && call_block->succ->dest != alternate_exit)
705               /* If this call doesn't end the block, there are operations at
706                  the end of the block which we must execute after returning.  */
707               || ! call_ends_block_p (insn, call_block->end))
708             sibcall = 0, tailrecursion = 0;
709
710           /* Select a set of insns to implement the call and emit them.
711              Tail recursion is the most efficient, so select it over
712              a tail/sibling call.  */
713           if (sibcall)
714             successful_sibling_call = 1;
715
716           replaced_call_placeholder = 1;
717           replace_call_placeholder (insn, 
718                                     tailrecursion != 0 
719                                       ? sibcall_use_tail_recursion
720                                       : sibcall != 0
721                                          ? sibcall_use_sibcall
722                                          : sibcall_use_normal);
723         }
724     }
725
726   if (successful_sibling_call)
727     {
728       rtx insn;
729
730       /* A sibling call sequence invalidates any REG_EQUIV notes made for
731          this function's incoming arguments. 
732
733          At the start of RTL generation we know the only REG_EQUIV notes
734          in the rtl chain are those for incoming arguments, so we can safely
735          flush any REG_EQUIV note. 
736
737          This is (slight) overkill.  We could keep track of the highest
738          argument we clobber and be more selective in removing notes, but it
739          does not seem to be worth the effort.  */
740       purge_reg_equiv_notes ();
741
742       /* A sibling call sequence also may invalidate RTX_UNCHANGING_P
743          flag of some incoming arguments MEM RTLs, because it can write into
744          those slots.  We clear all those bits now.
745          
746          This is (slight) overkill, we could keep track of which arguments
747          we actually write into.  */
748       for (insn = get_insns (); insn; insn = NEXT_INSN (insn))
749         {
750           if (GET_CODE (insn) == NOTE)
751             {
752               if (NOTE_LINE_NUMBER (insn) == NOTE_INSN_FUNCTION_BEG)
753                 break;
754             }
755           else if (INSN_P (insn))
756             purge_mem_unchanging_flag (PATTERN (insn));
757         }
758     }
759
760   /* There may have been NOTE_INSN_BLOCK_{BEGIN,END} notes in the 
761      CALL_PLACEHOLDER alternatives that we didn't emit.  Rebuild the
762      lexical block tree to correspond to the notes that still exist.  */
763   if (replaced_call_placeholder)
764     reorder_blocks ();
765
766   /* This information will be invalid after inline expansion.  Kill it now.  */
767   free_basic_block_vars (0);
768 }