]> git.pld-linux.org Git - packages/gcc.git/blob - gcc-pr25654.patch
- pr24897: fix SSE3 intrinsic bug.
[packages/gcc.git] / gcc-pr25654.patch
1 --- gcc-4_1-branch/gcc/cfgexpand.c      (revision 110109)
2 +++ gcc-4_1-branch/gcc/cfgexpand.c      (revision 110110)
3 @@ -272,11 +272,39 @@
4    gcc_assert (index < stack_vars_conflict_alloc);
5    return stack_vars_conflict[index];
6  }
7 -  
8
9 +/* Returns true if TYPE is or contains a union type.  */
10 +
11 +static bool
12 +aggregate_contains_union_type (tree type)
13 +{
14 +  tree field;
15 +
16 +  if (TREE_CODE (type) == UNION_TYPE
17 +      || TREE_CODE (type) == QUAL_UNION_TYPE)
18 +    return true;
19 +  if (TREE_CODE (type) == ARRAY_TYPE)
20 +    return aggregate_contains_union_type (TREE_TYPE (type));
21 +  if (TREE_CODE (type) != RECORD_TYPE)
22 +    return false;
23 +
24 +  for (field = TYPE_FIELDS (type); field; field = TREE_CHAIN (field))
25 +    if (TREE_CODE (field) == FIELD_DECL)
26 +      if (aggregate_contains_union_type (TREE_TYPE (field)))
27 +       return true;
28 +
29 +  return false;
30 +}
31 +
32  /* A subroutine of expand_used_vars.  If two variables X and Y have alias
33     sets that do not conflict, then do add a conflict for these variables
34 -   in the interference graph.  We also have to mind MEM_IN_STRUCT_P and
35 -   MEM_SCALAR_P.  */
36 +   in the interference graph.  We also need to make sure to add conflicts
37 +   for union containing structures.  Else RTL alias analysis comes along
38 +   and due to type based aliasing rules decides that for two overlapping
39 +   union temporaries { short s; int i; } accesses to the same mem through
40 +   different types may not alias and happily reorders stores across
41 +   life-time boundaries of the temporaries (See PR25654).
42 +   We also have to mind MEM_IN_STRUCT_P and MEM_SCALAR_P.  */
43  
44  static void
45  add_alias_set_conflicts (void)
46 @@ -287,12 +315,23 @@
47      {
48        tree type_i = TREE_TYPE (stack_vars[i].decl);
49        bool aggr_i = AGGREGATE_TYPE_P (type_i);
50 +      bool contains_union;
51  
52 +      contains_union = aggregate_contains_union_type (type_i);
53        for (j = 0; j < i; ++j)
54         {
55           tree type_j = TREE_TYPE (stack_vars[j].decl);
56           bool aggr_j = AGGREGATE_TYPE_P (type_j);
57 -         if (aggr_i != aggr_j || !objects_must_conflict_p (type_i, type_j))
58 +         if (aggr_i != aggr_j
59 +             /* Either the objects conflict by means of type based
60 +                aliasing rules, or we need to add a conflict.  */
61 +             || !objects_must_conflict_p (type_i, type_j)
62 +             /* In case the types do not conflict ensure that access
63 +                to elements will conflict.  In case of unions we have
64 +                to be careful as type based aliasing rules may say
65 +                access to the same memory does not conflict.  So play
66 +                safe and add a conflict in this case.  */
67 +             || contains_union)
68             add_stack_var_conflict (i, j);
69         }
70      }
This page took 0.032794 seconds and 3 git commands to generate.