Propolice for GCC 3.3 based on:
[dragonfly.git] / gnu / usr.bin / cc3 / cc_int / patches / function.c.patch
1 $DragonFly: src/gnu/usr.bin/cc3/cc_int/patches/Attic/function.c.patch,v 1.1 2004/03/05 21:38:44 joerg Exp $
2 Index: function.c
3 ===================================================================
4 RCS file: /cvs/src/contrib/gcc-3.3/gcc/function.c,v
5 retrieving revision 1.1
6 diff -u -r1.1 function.c
7 --- function.c  2 Feb 2004 23:09:47 -0000       1.1
8 +++ function.c  4 Mar 2004 15:18:33 -0000
9 @@ -59,6 +59,7 @@
10  #include "tm_p.h"
11  #include "integrate.h"
12  #include "langhooks.h"
13 +#include "protector.h"
14  
15  #ifndef TRAMPOLINE_ALIGNMENT
16  #define TRAMPOLINE_ALIGNMENT FUNCTION_BOUNDARY
17 @@ -145,6 +146,10 @@
18  /* Array of INSN_UIDs to hold the INSN_UIDs for each sibcall epilogue
19     in this function.  */
20  static GTY(()) varray_type sibcall_epilogue;
21 +
22 +/* Current boundary mark for character arrays.  */
23 +int temp_boundary_mark = 0;
24 +
25  \f
26  /* In order to evaluate some expressions, such as function calls returning
27     structures in memory, we need to temporarily allocate stack locations.
28 @@ -198,6 +203,8 @@
29    /* The size of the slot, including extra space for alignment.  This
30       info is for combine_temp_slots.  */
31    HOST_WIDE_INT full_size;
32 +  /* Boundary mark of a character array and the others. This info is for propolice */
33 +  int boundary_mark;
34  };
35  \f
36  /* This structure is used to record MEMs or pseudos used to replace VAR, any
37 @@ -632,6 +639,7 @@
38     whose lifetime is controlled by CLEANUP_POINT_EXPRs.  KEEP is 3
39     if we are to allocate something at an inner level to be treated as
40     a variable in the block (e.g., a SAVE_EXPR).
41 +   KEEP is 5 if we allocate a place to return structure.
42  
43     TYPE is the type that will be used for the stack slot.  */
44  
45 @@ -645,6 +653,8 @@
46    unsigned int align;
47    struct temp_slot *p, *best_p = 0;
48    rtx slot;
49 +  int char_array = (flag_propolice_protection
50 +                   && keep == 1 && search_string_def (type));
51  
52    /* If SIZE is -1 it means that somebody tried to allocate a temporary
53       of a variable size.  */
54 @@ -670,7 +680,8 @@
55         && ! p->in_use
56         && objects_must_conflict_p (p->type, type)
57         && (best_p == 0 || best_p->size > p->size
58 -           || (best_p->size == p->size && best_p->align > p->align)))
59 +           || (best_p->size == p->size && best_p->align > p->align))
60 +       && (! char_array || p->boundary_mark != 0))
61        {
62         if (p->align == align && p->size == size)
63           {
64 @@ -705,6 +716,7 @@
65               p->address = 0;
66               p->rtl_expr = 0;
67               p->type = best_p->type;
68 +             p->boundary_mark = best_p->boundary_mark;
69               p->next = temp_slots;
70               temp_slots = p;
71  
72 @@ -765,6 +777,7 @@
73        p->full_size = frame_offset - frame_offset_old;
74  #endif
75        p->address = 0;
76 +      p->boundary_mark = char_array?++temp_boundary_mark:0;
77        p->next = temp_slots;
78        temp_slots = p;
79      }
80 @@ -935,14 +948,16 @@
81             int delete_q = 0;
82             if (! q->in_use && GET_MODE (q->slot) == BLKmode)
83               {
84 -               if (p->base_offset + p->full_size == q->base_offset)
85 +               if (p->base_offset + p->full_size == q->base_offset &&
86 +                   p->boundary_mark == q->boundary_mark)
87                   {
88                     /* Q comes after P; combine Q into P.  */
89                     p->size += q->size;
90                     p->full_size += q->full_size;
91                     delete_q = 1;
92                   }
93 -               else if (q->base_offset + q->full_size == p->base_offset)
94 +               else if (q->base_offset + q->full_size == p->base_offset &&
95 +                        p->boundary_mark == q->boundary_mark)
96                   {
97                     /* P comes after Q; combine P into Q.  */
98                     q->size += p->size;
99 @@ -1502,7 +1517,9 @@
100      new = func->x_parm_reg_stack_loc[regno];
101  
102    if (new == 0)
103 -    new = assign_stack_local_1 (decl_mode, GET_MODE_SIZE (decl_mode), 0, func);
104 +    new = function ?
105 +       assign_stack_local_1 (decl_mode, GET_MODE_SIZE (decl_mode), 0, func):
106 +       assign_stack_local_for_pseudo_reg (decl_mode, GET_MODE_SIZE (decl_mode), 0);
107  
108    PUT_CODE (reg, MEM);
109    PUT_MODE (reg, decl_mode);
110 @@ -3982,7 +3999,8 @@
111                  constant with that register.  */
112               temp = gen_reg_rtx (Pmode);
113               XEXP (x, 0) = new;
114 -             if (validate_change (object, &XEXP (x, 1), temp, 0))
115 +             if (validate_change (object, &XEXP (x, 1), temp, 0)
116 +                 && ! flag_propolice_protection)
117                 emit_insn_before (gen_move_insn (temp, new_offset), object);
118               else
119                 {