Merge from vendor branch OPENSSH:
[dragonfly.git] / gnu / usr.bin / cc34 / cc_prep / patches / function.c.patch
1 $DragonFly: src/gnu/usr.bin/cc34/cc_prep/patches/function.c.patch,v 1.2 2004/06/20 00:10:52 joerg Exp $
2
3 diff -u ../gcc.orig/function.c function.c
4 --- ../gcc.orig/function.c      2004-06-19 22:27:11.000000000 +0200
5 +++ function.c  2004-06-20 01:16:04.000000000 +0200
6 @@ -63,6 +63,7 @@
7  #include "integrate.h"
8  #include "langhooks.h"
9  #include "target.h"
10 +#include "protector.h"
11  
12  #ifndef TRAMPOLINE_ALIGNMENT
13  #define TRAMPOLINE_ALIGNMENT FUNCTION_BOUNDARY
14 @@ -155,6 +156,10 @@
15  /* Array of INSN_UIDs to hold the INSN_UIDs for each sibcall epilogue
16     in this function.  */
17  static GTY(()) varray_type sibcall_epilogue;
18 +
19 +/* Current boundary mark for character arrays.  */
20 +static int temp_boundary_mark = 0;
21 +
22  \f
23  /* In order to evaluate some expressions, such as function calls returning
24     structures in memory, we need to temporarily allocate stack locations.
25 @@ -208,6 +213,8 @@
26    /* The size of the slot, including extra space for alignment.  This
27       info is for combine_temp_slots.  */
28    HOST_WIDE_INT full_size;
29 +  /* Boundary mark of a character array and the others. This info is for propolice.  */
30 +  int boundary_mark;
31  };
32  \f
33  /* This structure is used to record MEMs or pseudos used to replace VAR, any
34 @@ -638,6 +645,7 @@
35     whose lifetime is controlled by CLEANUP_POINT_EXPRs.  KEEP is 3
36     if we are to allocate something at an inner level to be treated as
37     a variable in the block (e.g., a SAVE_EXPR).
38 +   KEEP is 5 if we allocate a place to return structure.
39  
40     TYPE is the type that will be used for the stack slot.  */
41  
42 @@ -648,6 +656,8 @@
43    unsigned int align;
44    struct temp_slot *p, *best_p = 0;
45    rtx slot;
46 +  int char_array = (flag_propolice_protection
47 +                   && keep == 1 && search_string_def (type));
48  
49    /* If SIZE is -1 it means that somebody tried to allocate a temporary
50       of a variable size.  */
51 @@ -673,7 +683,8 @@
52         && ! p->in_use
53         && objects_must_conflict_p (p->type, type)
54         && (best_p == 0 || best_p->size > p->size
55 -           || (best_p->size == p->size && best_p->align > p->align)))
56 +           || (best_p->size == p->size && best_p->align > p->align))
57 +       && (! char_array || p->boundary_mark != 0))
58        {
59         if (p->align == align && p->size == size)
60           {
61 @@ -708,6 +719,7 @@
62               p->address = 0;
63               p->rtl_expr = 0;
64               p->type = best_p->type;
65 +             p->boundary_mark = best_p->boundary_mark;
66               p->next = temp_slots;
67               temp_slots = p;
68  
69 @@ -768,6 +780,7 @@
70        p->full_size = frame_offset - frame_offset_old;
71  #endif
72        p->address = 0;
73 +      p->boundary_mark = char_array ? ++temp_boundary_mark : 0;
74        p->next = temp_slots;
75        temp_slots = p;
76      }
77 @@ -932,14 +945,16 @@
78             int delete_q = 0;
79             if (! q->in_use && GET_MODE (q->slot) == BLKmode)
80               {
81 -               if (p->base_offset + p->full_size == q->base_offset)
82 +               if (p->base_offset + p->full_size == q->base_offset &&
83 +                   p->boundary_mark == q->boundary_mark)
84                   {
85                     /* Q comes after P; combine Q into P.  */
86                     p->size += q->size;
87                     p->full_size += q->full_size;
88                     delete_q = 1;
89                   }
90 -               else if (q->base_offset + q->full_size == p->base_offset)
91 +               else if (q->base_offset + q->full_size == p->base_offset &&
92 +                        p->boundary_mark == q->boundary_mark)
93                   {
94                     /* P comes after Q; combine P into Q.  */
95                     q->size += p->size;
96 @@ -1449,7 +1464,9 @@
97      }
98  
99    if (new == 0)
100 -    new = assign_stack_local_1 (decl_mode, GET_MODE_SIZE (decl_mode), 0, func);
101 +    new = function ?
102 +      assign_stack_local_1 (decl_mode, GET_MODE_SIZE (decl_mode), 0, func)
103 +      :        assign_stack_local_for_pseudo_reg (decl_mode, GET_MODE_SIZE (decl_mode), 0);
104  
105    PUT_CODE (reg, MEM);
106    PUT_MODE (reg, decl_mode);
107 @@ -3930,7 +3947,8 @@
108                  constant with that register.  */
109               temp = gen_reg_rtx (Pmode);
110               XEXP (x, 0) = new;
111 -             if (validate_change (object, &XEXP (x, 1), temp, 0))
112 +             if (validate_change (object, &XEXP (x, 1), temp, 0)
113 +                 && !flag_propolice_protection)
114                 emit_insn_before (gen_move_insn (temp, new_offset), object);
115               else
116                 {