b3180c4c61aad14ddc9e9e7573e29a9c22757d24
[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.3 2004/12/21 13:10:48 joerg Exp $
2
3 ===================================================================
4 RCS file: /home/joerg/wd/repository/dragonflybsd/src/contrib/gcc-3.4/gcc/function.c,v
5 retrieving revision 1.2
6 diff -u -r1.2 function.c
7 --- function.c  20 Dec 2004 19:23:24 -0000      1.2
8 +++ function.c  20 Dec 2004 20:48:10 -0000
9 @@ -63,6 +63,7 @@
10  #include "integrate.h"
11  #include "langhooks.h"
12  #include "target.h"
13 +#include "protector.h"
14  
15  #ifndef TRAMPOLINE_ALIGNMENT
16  #define TRAMPOLINE_ALIGNMENT FUNCTION_BOUNDARY
17 @@ -155,6 +156,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 +static 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 @@ -208,6 +213,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 @@ -638,6 +645,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 @@ -648,6 +656,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 @@ -673,7 +683,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 @@ -708,6 +719,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 @@ -768,6 +780,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 @@ -932,14 +945,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 @@ -1449,7 +1464,9 @@
100      }
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 @@ -3940,7 +3957,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                 {