]> git.pld-linux.org Git - packages/crossavr-gcc.git/blob - 502-gcc-pr54796.patch
- cleanup, updated BRs, stub texinfo build (not packaged and would require patch...
[packages/crossavr-gcc.git] / 502-gcc-pr54796.patch
1 diff -Naurp gcc/alias.c gcc/alias.c
2 --- gcc/alias.c 2012-03-01 22:28:11.000000000 +0530
3 +++ gcc/alias.c 2012-11-06 15:25:38.000000000 +0530
4 @@ -1595,6 +1595,9 @@ find_base_term (rtx x)
5        if (!val)
6         return ret;
7  
8 +      if (cselib_sp_based_value_p (val))
9 +       return static_reg_base_value[STACK_POINTER_REGNUM];
10 +
11        f = val->locs;
12        /* Temporarily reset val->locs to avoid infinite recursion.  */
13        val->locs = NULL;
14 diff -Naurp gcc/cselib.c gcc/cselib.c
15 --- gcc/cselib.c        2012-03-01 22:28:11.000000000 +0530
16 +++ gcc/cselib.c        2012-11-06 15:25:38.000000000 +0530
17 @@ -209,6 +209,9 @@ void (*cselib_record_sets_hook) (rtx ins
18  #define PRESERVED_VALUE_P(RTX) \
19    (RTL_FLAG_CHECK1("PRESERVED_VALUE_P", (RTX), VALUE)->unchanging)
20  
21 +#define SP_BASED_VALUE_P(RTX) \
22 +  (RTL_FLAG_CHECK1("SP_BASED_VALUE_P", (RTX), VALUE)->jump)
23 +
24  \f
25  
26  /* Allocate a struct elt_list and fill in its two elements with the
27 @@ -738,6 +741,23 @@ cselib_preserve_only_values (void)
28    gcc_assert (first_containing_mem == &dummy_val);
29  }
30  
31 +/* Arrange for a value to be marked as based on stack pointer
32 +   for find_base_term purposes.  */
33 +
34 +void
35 +cselib_set_value_sp_based (cselib_val *v)
36 +{
37 +  SP_BASED_VALUE_P (v->val_rtx) = 1;
38 +}
39 +
40 +/* Test whether a value is preserved.  */
41 +
42 +bool
43 +cselib_sp_based_value_p (cselib_val *v)
44 +{
45 +  return SP_BASED_VALUE_P (v->val_rtx);
46 +}
47 +
48  /* Return the mode in which a register was last set.  If X is not a
49     register, return its mode.  If the mode in which the register was
50     set is not known, or the value was already clobbered, return
51 diff -Naurp gcc/cselib.h gcc/cselib.h
52 --- gcc/cselib.h        2012-03-01 22:28:11.000000000 +0530
53 +++ gcc/cselib.h        2012-11-06 15:25:38.000000000 +0530
54 @@ -99,6 +99,8 @@ extern void cselib_preserve_only_values 
55  extern void cselib_preserve_cfa_base_value (cselib_val *, unsigned int);
56  extern void cselib_add_permanent_equiv (cselib_val *, rtx, rtx);
57  extern bool cselib_have_permanent_equivalences (void);
58 +extern void cselib_set_value_sp_based (cselib_val *);
59 +extern bool cselib_sp_based_value_p (cselib_val *);
60  
61  extern void dump_cselib_table (FILE *);
62  
63 diff -Naurp gcc/rtl.h gcc/rtl.h
64 --- gcc/rtl.h   2012-01-25 00:36:38.000000000 +0530
65 +++ gcc/rtl.h   2012-11-06 15:25:38.000000000 +0530
66 @@ -266,7 +266,8 @@ struct GTY((chain_next ("RTX_NEXT (&%h)"
67       1 in a CALL_INSN if it is a sibling call.
68       1 in a SET that is for a return.
69       In a CODE_LABEL, part of the two-bit alternate entry field.
70 -     1 in a CONCAT is VAL_EXPR_IS_COPIED in var-tracking.c.  */
71 +     1 in a CONCAT is VAL_EXPR_IS_COPIED in var-tracking.c.
72 +     1 in a VALUE is SP_BASED_VALUE_P in cselib.c.  */
73    unsigned int jump : 1;
74    /* In a CODE_LABEL, part of the two-bit alternate entry field.
75       1 in a MEM if it cannot trap.
76 diff -Naurp gcc/testsuite/gcc.dg/guality/pr54796.c gcc/testsuite/gcc.dg/guality/pr54796.c
77 --- gcc/testsuite/gcc.dg/guality/pr54796.c      1970-01-01 05:30:00.000000000 +0530
78 +++ gcc/testsuite/gcc.dg/guality/pr54796.c      2012-11-06 15:25:38.000000000 +0530
79 @@ -0,0 +1,25 @@
80 +/* PR debug/54796 */
81 +/* { dg-do run } */
82 +/* { dg-options "-g" } */
83 +
84 +__attribute__((noinline, noclone)) void
85 +bar (char *a, int b)
86 +{
87 +  __asm volatile ("" : "+r" (a), "+r" (b) : : "memory");
88 +}
89 +
90 +__attribute__((noinline, noclone)) void
91 +foo (int a, int b)
92 +{
93 +  int c = a;
94 +  char d[b];   /* { dg-final { gdb-test 17 "a" "5" } } */
95 +  bar (d, 2);  /* { dg-final { gdb-test 17 "b" "6" } } */
96 +  bar (d, 4);  /* { dg-final { gdb-test 17 "c" "5" } } */
97 +}
98 +
99 +int
100 +main ()
101 +{
102 +  foo (5, 6);
103 +  return 0;
104 +}
105 diff -Naurp gcc/var-tracking.c gcc/var-tracking.c
106 --- gcc/var-tracking.c  2012-02-25 17:39:27.000000000 +0530
107 +++ gcc/var-tracking.c  2012-11-06 15:25:38.000000000 +0530
108 @@ -5521,6 +5521,11 @@ add_stores (rtx loc, const_rtx expr, voi
109  
110    resolve = preserve = !cselib_preserved_value_p (v);
111  
112 +  if (loc == stack_pointer_rtx
113 +      && hard_frame_pointer_adjustment != -1
114 +      && preserve)
115 +    cselib_set_value_sp_based (v);
116 +
117    nloc = replace_expr_with_values (oloc);
118    if (nloc)
119      oloc = nloc;
120 @@ -9446,6 +9451,19 @@ vt_initialize (void)
121                     {
122                       vt_init_cfa_base ();
123                       hard_frame_pointer_adjustment = fp_cfa_offset;
124 +                     /* Disassociate sp from fp now.  */
125 +                     if (MAY_HAVE_DEBUG_INSNS)
126 +                       {
127 +                         cselib_val *v;
128 +                         cselib_invalidate_rtx (stack_pointer_rtx);
129 +                         v = cselib_lookup (stack_pointer_rtx, Pmode, 1,
130 +                                            VOIDmode);
131 +                         if (v && !cselib_preserved_value_p (v))
132 +                           {
133 +                             cselib_set_value_sp_based (v);
134 +                             preserve_value (v);
135 +                           }
136 +                       }
137                     }
138                 }
139             }
This page took 0.053902 seconds and 3 git commands to generate.