summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/gcc/gcc-4.6.0/gcc-4_6-branch-backports/0252-PR-debug-48159.patch
blob: 814028e1b1541a597b8c45d09875c44c1775ba72 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
From 36c5622ac8aca9636fb541d3689b9dd3ca9e0c27 Mon Sep 17 00:00:00 2001
From: jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Wed, 11 May 2011 13:07:54 +0000
Subject: [PATCH] 	PR debug/48159
 	* tree-ssa.c (reset_debug_uses): New function.
 	* tree-flow.h (reset_debug_uses): New prototype.
 	* tree-data-ref.c (stmts_from_loop): Ignore debug stmts.
 	* tree-loop-distribution.c (generate_loops_for_partition): Call
 	reset_debug_uses on the stmts that will be removed.  Keep around
 	all debug stmts, don't count them as bits in partition bitmap.
 	(generate_builtin): Don't count debug stmts or labels as bits in
 	partition bitmap.

	* gcc.dg/pr48159-1.c: New test.
	* gcc.dg/pr48159-2.c: New test.


git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_6-branch@173657 138bc75d-0d04-0410-961f-82ee72b054a4

index 3b64229..209b80b 100644
new file mode 100644
index 0000000..cd67e63
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr48159-1.c
@@ -0,0 +1,10 @@
+/* PR debug/48159 */
+/* { dg-do compile } */
+/* { dg-options "-O3 -fcompare-debug" } */
+
+void
+foo (double x, int y, double *__restrict z, double *__restrict w)
+{
+  while (y--)
+    *z++ = (*w++ = 0) * x;
+}
diff --git a/gcc/testsuite/gcc.dg/pr48159-2.c b/gcc/testsuite/gcc.dg/pr48159-2.c
new file mode 100644
index 0000000..25596bf
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr48159-2.c
@@ -0,0 +1,22 @@
+/* PR debug/48159 */
+/* { dg-do compile } */ 
+/* { dg-options "-O2 -ftree-loop-distribution -fcompare-debug" } */
+
+int foo (int * __restrict__ ia, int * __restrict__ ib,
+	 int * __restrict__ oxa, int * __restrict__ oxb)
+{
+  int i;
+  int oya[52], oyb[52];
+  for (i = 0; i < 52; i++)
+    {
+      int w1 = ia[i];
+      int w2 = oxa[i];
+      int w3 = ib[i];
+      int w4 = oxb[i];
+      int w5 = w1 + w2 + 5;
+      oya[i] = (w1 * w2) >> 10;
+      int w6 = w3 + w4 + 6;
+      oyb[i] = (w3 * w4) >> 10;
+    }
+  return oya[22] + oyb[21];
+}
diff --git a/gcc/tree-data-ref.c b/gcc/tree-data-ref.c
index 54cb46c..39eab47 100644
--- a/gcc/tree-data-ref.c
+++ b/gcc/tree-data-ref.c
@@ -1,5 +1,5 @@
 /* Data references and dependences detectors.
-   Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+   Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
    Free Software Foundation, Inc.
    Contributed by Sebastian Pop <pop@cri.ensmp.fr>
 
@@ -4975,7 +4975,7 @@ stmts_from_loop (struct loop *loop, VEC (gimple, heap) **stmts)
       for (bsi = gsi_start_bb (bb); !gsi_end_p (bsi); gsi_next (&bsi))
 	{
 	  stmt = gsi_stmt (bsi);
-	  if (gimple_code (stmt) != GIMPLE_LABEL)
+	  if (gimple_code (stmt) != GIMPLE_LABEL && !is_gimple_debug (stmt))
 	    VEC_safe_push (gimple, heap, *stmts, stmt);
 	}
     }
diff --git a/gcc/tree-flow.h b/gcc/tree-flow.h
index 14c8827..0777aec 100644
--- a/gcc/tree-flow.h
+++ b/gcc/tree-flow.h
@@ -559,6 +559,7 @@ extern void walk_use_def_chains (tree, walk_use_def_chains_fn, void *, bool);
 
 void insert_debug_temps_for_defs (gimple_stmt_iterator *);
 void insert_debug_temp_for_var_def (gimple_stmt_iterator *, tree);
+void reset_debug_uses (gimple);
 void release_defs_bitset (bitmap toremove);
 
 /* In tree-into-ssa.c  */
diff --git a/gcc/tree-loop-distribution.c b/gcc/tree-loop-distribution.c
index 5b147e3..1d6944e 100644
--- a/gcc/tree-loop-distribution.c
+++ b/gcc/tree-loop-distribution.c
@@ -1,5 +1,5 @@
 /* Loop distribution.
-   Copyright (C) 2006, 2007, 2008, 2009, 2010
+   Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011
    Free Software Foundation, Inc.
    Contributed by Georges-Andre Silber <Georges-Andre.Silber@ensmp.fr>
    and Sebastian Pop <sebastian.pop@amd.com>.
@@ -181,6 +181,25 @@ generate_loops_for_partition (struct loop *loop, bitmap partition, bool copy_p)
      stmts_from_loop.  */
   bbs = get_loop_body_in_dom_order (loop);
 
+  if (MAY_HAVE_DEBUG_STMTS)
+    for (x = 0, i = 0; i < loop->num_nodes; i++)
+      {
+	basic_block bb = bbs[i];
+
+	for (bsi = gsi_start_phis (bb); !gsi_end_p (bsi); gsi_next (&bsi))
+	  if (!bitmap_bit_p (partition, x++))
+	    reset_debug_uses (gsi_stmt (bsi));
+
+	for (bsi = gsi_start_bb (bb); !gsi_end_p (bsi); gsi_next (&bsi))
+	  {
+	    gimple stmt = gsi_stmt (bsi);
+	    if (gimple_code (stmt) != GIMPLE_LABEL
+		&& !is_gimple_debug (stmt)
+		&& !bitmap_bit_p (partition, x++))
+	      reset_debug_uses (stmt);
+	  }
+      }
+
   for (x = 0, i = 0; i < loop->num_nodes; i++)
     {
       basic_block bb = bbs[i];
@@ -199,7 +218,8 @@ generate_loops_for_partition (struct loop *loop, bitmap partition, bool copy_p)
       for (bsi = gsi_start_bb (bb); !gsi_end_p (bsi);)
 	{
 	  gimple stmt = gsi_stmt (bsi);
-	  if (gimple_code (gsi_stmt (bsi)) != GIMPLE_LABEL
+	  if (gimple_code (stmt) != GIMPLE_LABEL
+	      && !is_gimple_debug (stmt)
 	      && !bitmap_bit_p (partition, x++))
 	    {
 	      unlink_stmt_vdef (stmt);
@@ -312,7 +332,9 @@ generate_builtin (struct loop *loop, bitmap partition, bool copy_p)
 	{
 	  gimple stmt = gsi_stmt (bsi);
 
-	  if (bitmap_bit_p (partition, x++)
+	  if (gimple_code (stmt) != GIMPLE_LABEL
+	      && !is_gimple_debug (stmt)
+	      && bitmap_bit_p (partition, x++)
 	      && is_gimple_assign (stmt)
 	      && !is_gimple_reg (gimple_assign_lhs (stmt)))
 	    {
diff --git a/gcc/tree-ssa.c b/gcc/tree-ssa.c
index da6cc9b..0455680 100644
--- a/gcc/tree-ssa.c
+++ b/gcc/tree-ssa.c
@@ -507,6 +507,37 @@ insert_debug_temps_for_defs (gimple_stmt_iterator *gsi)
     }
 }
 
+/* Reset all debug stmts that use SSA_NAME(s) defined in STMT.  */
+
+void
+reset_debug_uses (gimple stmt)
+{
+  ssa_op_iter op_iter;
+  def_operand_p def_p;
+  imm_use_iterator imm_iter;
+  gimple use_stmt;
+
+  if (!MAY_HAVE_DEBUG_STMTS)
+    return;
+
+  FOR_EACH_PHI_OR_STMT_DEF (def_p, stmt, op_iter, SSA_OP_DEF)
+    {
+      tree var = DEF_FROM_PTR (def_p);
+
+      if (TREE_CODE (var) != SSA_NAME)
+	continue;
+
+      FOR_EACH_IMM_USE_STMT (use_stmt, imm_iter, var)
+	{
+	  if (!gimple_debug_bind_p (use_stmt))
+	    continue;
+
+	  gimple_debug_bind_reset_value (use_stmt);
+	  update_stmt (use_stmt);
+	}
+    }
+}
+
 /* Delete SSA DEFs for SSA versions in the TOREMOVE bitmap, removing
    dominated stmts before their dominators, so that release_ssa_defs
    stands a chance of propagating DEFs into debug bind stmts.  */
-- 
1.7.0.4