]> git.pld-linux.org Git - packages/gcc.git/blob - gcc-branch.diff
- updated.
[packages/gcc.git] / gcc-branch.diff
1 Index: configure
2 ===================================================================
3 --- configure   (.../tags/gcc_4_2_0_release)    (revision 125292)
4 +++ configure   (.../branches/gcc-4_2-branch)   (revision 125292)
5 @@ -7337,6 +7337,12 @@
6  #line 7338 "configure"
7  #include "confdefs.h"
8  
9 +#if (__GNUC__ < 3) \
10 +    || (__GNUC__ == 3 && (__GNUC_MINOR__ < 3 \
11 +                         || (__GNUC_MINOR__ == 3 && __GNUC_PATCHLEVEL__ < 1)))
12 +#error http://gcc.gnu.org/PR29382
13 +#endif
14 +    
15  int main() {
16  
17  ; return 0; }
18 Index: gcc/tree-vrp.c
19 ===================================================================
20 --- gcc/tree-vrp.c      (.../tags/gcc_4_2_0_release)    (revision 125292)
21 +++ gcc/tree-vrp.c      (.../branches/gcc-4_2-branch)   (revision 125292)
22 @@ -195,7 +195,28 @@
23               || operand_equal_p (val, TYPE_MIN_VALUE (TREE_TYPE (val)), 0)));
24  }
25  
26 +/* If VAL is now an overflow infinity, return VAL.  Otherwise, return
27 +   the same value with TREE_OVERFLOW clear.  This can be used to avoid
28 +   confusing a regular value with an overflow value.  */
29  
30 +static inline tree
31 +avoid_overflow_infinity (tree val)
32 +{
33 +  if (!is_overflow_infinity (val))
34 +    return val;
35 +
36 +  if (operand_equal_p (val, TYPE_MAX_VALUE (TREE_TYPE (val)), 0))
37 +    return TYPE_MAX_VALUE (TREE_TYPE (val));
38 +  else
39 +    {
40 +#ifdef ENABLE_CHECKING
41 +      gcc_assert (operand_equal_p (val, TYPE_MIN_VALUE (TREE_TYPE (val)), 0));
42 +#endif
43 +      return TYPE_MIN_VALUE (TREE_TYPE (val));
44 +    }
45 +}
46 +
47 +
48  /* Return whether VAL is equal to the maximum value of its type.  This
49     will be true for a positive overflow infinity.  We can't do a
50     simple equality comparison with TYPE_MAX_VALUE because C typedefs
51 @@ -351,23 +372,11 @@
52     infinity when we shouldn't.  */
53  
54  static inline void
55 -set_value_range_to_value (value_range_t *vr, tree val)
56 +set_value_range_to_value (value_range_t *vr, tree val, bitmap equiv)
57  {
58    gcc_assert (is_gimple_min_invariant (val));
59 -  if (is_overflow_infinity (val))
60 -    {
61 -      if (operand_equal_p (val, TYPE_MAX_VALUE (TREE_TYPE (val)), 0))
62 -       val = TYPE_MAX_VALUE (TREE_TYPE (val));
63 -      else
64 -       {
65 -#ifdef ENABLE_CHECKING
66 -         gcc_assert (operand_equal_p (val,
67 -                                      TYPE_MIN_VALUE (TREE_TYPE (val)), 0));
68 -#endif
69 -         val = TYPE_MIN_VALUE (TREE_TYPE (val));
70 -       }
71 -    }
72 -  set_value_range (vr, VR_RANGE, val, val, NULL);
73 +  val = avoid_overflow_infinity (val);
74 +  set_value_range (vr, VR_RANGE, val, val, equiv);
75  }
76  
77  /* Set value range VR to a non-negative range of type TYPE.
78 @@ -411,8 +420,7 @@
79  static inline void
80  set_value_range_to_null (value_range_t *vr, tree type)
81  {
82 -  tree zero = build_int_cst (type, 0);
83 -  set_value_range (vr, VR_RANGE, zero, zero, vr->equiv);
84 +  set_value_range_to_value (vr, build_int_cst (type, 0), vr->equiv);
85  }
86  
87  
88 @@ -1028,6 +1036,8 @@
89        cond_code = swap_tree_comparison (TREE_CODE (cond));
90      }
91  
92 +  limit = avoid_overflow_infinity (limit);
93 +
94    type = TREE_TYPE (limit);
95    gcc_assert (limit != var);
96  
97 @@ -1619,7 +1629,7 @@
98    if (TREE_CODE (op0) == SSA_NAME)
99      vr0 = *(get_value_range (op0));
100    else if (is_gimple_min_invariant (op0))
101 -    set_value_range_to_value (&vr0, op0);
102 +    set_value_range_to_value (&vr0, op0, NULL);
103    else
104      set_value_range_to_varying (&vr0);
105  
106 @@ -1627,7 +1637,7 @@
107    if (TREE_CODE (op1) == SSA_NAME)
108      vr1 = *(get_value_range (op1));
109    else if (is_gimple_min_invariant (op1))
110 -    set_value_range_to_value (&vr1, op1);
111 +    set_value_range_to_value (&vr1, op1, NULL);
112    else
113      set_value_range_to_varying (&vr1);
114  
115 @@ -2006,7 +2016,7 @@
116    if (TREE_CODE (op0) == SSA_NAME)
117      vr0 = *(get_value_range (op0));
118    else if (is_gimple_min_invariant (op0))
119 -    set_value_range_to_value (&vr0, op0);
120 +    set_value_range_to_value (&vr0, op0, NULL);
121    else
122      set_value_range_to_varying (&vr0);
123  
124 @@ -2393,7 +2403,10 @@
125          its type may be different from _Bool.  Convert VAL to EXPR's
126          type.  */
127        val = fold_convert (TREE_TYPE (expr), val);
128 -      set_value_range (vr, VR_RANGE, val, val, vr->equiv);
129 +      if (is_gimple_min_invariant (val))
130 +       set_value_range_to_value (vr, val, vr->equiv);
131 +      else
132 +       set_value_range (vr, VR_RANGE, val, val, vr->equiv);
133      }
134    else
135      set_value_range_to_varying (vr);
136 @@ -2424,7 +2437,7 @@
137    else if (TREE_CODE_CLASS (code) == tcc_comparison)
138      extract_range_from_comparison (vr, expr);
139    else if (is_gimple_min_invariant (expr))
140 -    set_value_range_to_value (vr, expr);
141 +    set_value_range_to_value (vr, expr, NULL);
142    else
143      set_value_range_to_varying (vr);
144  
145 @@ -4156,7 +4169,7 @@
146        t = retval = NULL_TREE;
147        EXECUTE_IF_SET_IN_BITMAP (e2, 0, i2, bi2)
148         {
149 -         bool sop;
150 +         bool sop = false;
151  
152           value_range_t vr2 = *(vr_value[i2]);
153  
154 Index: gcc/DATESTAMP
155 ===================================================================
156 --- gcc/DATESTAMP       (.../tags/gcc_4_2_0_release)    (revision 125292)
157 +++ gcc/DATESTAMP       (.../branches/gcc-4_2-branch)   (revision 125292)
158 @@ -1 +1 @@
159 -20070514
160 +20070603
161 Index: gcc/pointer-set.c
162 ===================================================================
163 --- gcc/pointer-set.c   (.../tags/gcc_4_2_0_release)    (revision 125292)
164 +++ gcc/pointer-set.c   (.../branches/gcc-4_2-branch)   (revision 125292)
165 @@ -22,13 +22,12 @@
166  #include "system.h"
167  #include "pointer-set.h"
168  
169 -/* A pointer sets is represented as a simple open-addressing hash
170 +/* A pointer set is represented as a simple open-addressing hash
171     table.  Simplifications: The hash code is based on the value of the
172     pointer, not what it points to.  The number of buckets is always a
173     power of 2.  Null pointers are a reserved value.  Deletion is not
174 -   supported.  There is no mechanism for user control of hash
175 -   function, equality comparison, initial size, or resizing policy.
176 -*/
177 +   supported (yet).  There is no mechanism for user control of hash
178 +   function, equality comparison, initial size, or resizing policy.  */
179  
180  struct pointer_set_t
181  {
182 @@ -114,22 +113,16 @@
183      }
184  }
185  
186 -/* Subroutine of pointer_set_insert.  Inserts P into an empty
187 -   element of SLOTS, an array of length N_SLOTS.  Returns nonzero
188 -   if P was already present in N_SLOTS.  */
189 -static int
190 +/* Subroutine of pointer_set_insert.  Return the insertion slot for P into
191 +   an empty element of SLOTS, an array of length N_SLOTS.  */
192 +static inline size_t
193  insert_aux (void *p, void **slots, size_t n_slots, size_t log_slots)
194  {
195    size_t n = hash1 (p, n_slots, log_slots);
196    while (true)
197      {
198 -      if (slots[n] == p)
199 -       return 1;
200 -      else if (slots[n] == 0)
201 -       {
202 -         slots[n] = p;
203 -         return 0;
204 -       }
205 +      if (slots[n] == p || slots[n] == 0)
206 +       return n;
207        else
208         {
209           ++n;
210 @@ -144,12 +137,10 @@
211  int
212  pointer_set_insert (struct pointer_set_t *pset, void *p)
213  {
214 -  if (insert_aux (p, pset->slots, pset->n_slots, pset->log_slots))
215 -    return 1;
216 -      
217 -  /* We've inserted a new element.  Expand the table if necessary to keep
218 -     the load factor small.  */
219 -  ++pset->n_elements;
220 +  size_t n;
221 +
222 +  /* For simplicity, expand the set even if P is already there.  This can be
223 +     superfluous but can happen at most once.  */
224    if (pset->n_elements > pset->n_slots / 4)
225      {
226        size_t new_log_slots = pset->log_slots + 1;
227 @@ -158,9 +149,10 @@
228        size_t i;
229  
230        for (i = 0; i < pset->n_slots; ++i)
231 -       {
232 -         if (pset->slots[i])
233 -           insert_aux (pset->slots[i], new_slots, new_n_slots, new_log_slots);
234 +        {
235 +         void *value = pset->slots[i];
236 +         n = insert_aux (value, new_slots, new_n_slots, new_log_slots);
237 +         new_slots[n] = value;
238         }
239  
240        XDELETEVEC (pset->slots);
241 @@ -169,5 +161,144 @@
242        pset->slots = new_slots;
243      }
244  
245 +  n = insert_aux (p, pset->slots, pset->n_slots, pset->log_slots);
246 +  if (pset->slots[n])
247 +    return 1;
248 +
249 +  pset->slots[n] = p;
250 +  ++pset->n_elements;
251    return 0;
252  }
253 +
254 +/* Pass each pointer in PSET to the function in FN, together with the fixed
255 +   parameter DATA.  If FN returns false, the iteration stops.  */
256 +
257 +void pointer_set_traverse (struct pointer_set_t *pset,
258 +                          bool (*fn) (void *, void *), void *data)
259 +{
260 +  size_t i;
261 +  for (i = 0; i < pset->n_slots; ++i)
262 +    if (pset->slots[i] && !fn (pset->slots[i], data))
263 +      break;
264 +}
265 +
266 +\f
267 +/* A pointer map is represented the same way as a pointer_set, so
268 +   the hash code is based on the address of the key, rather than
269 +   its contents.  Null keys are a reserved value.  Deletion is not
270 +   supported (yet).  There is no mechanism for user control of hash
271 +   function, equality comparison, initial size, or resizing policy.  */
272 +
273 +struct pointer_map_t
274 +{
275 +  size_t log_slots;
276 +  size_t n_slots;              /* n_slots = 2^log_slots */
277 +  size_t n_elements;
278 +
279 +  void **keys;
280 +  void **values;
281 +};
282 +
283 +/* Allocate an empty pointer map.  */
284 +struct pointer_map_t *
285 +pointer_map_create (void)
286 +{
287 +  struct pointer_map_t *result = XNEW (struct pointer_map_t);
288 +
289 +  result->n_elements = 0;
290 +  result->log_slots = 8;
291 +  result->n_slots = (size_t) 1 << result->log_slots;
292 +
293 +  result->keys = XCNEWVEC (void *, result->n_slots);
294 +  result->values = XCNEWVEC (void *, result->n_slots);
295 +  return result;
296 +}
297 +
298 +/* Reclaims all memory associated with PMAP.  */
299 +void pointer_map_destroy (struct pointer_map_t *pmap)
300 +{
301 +  XDELETEVEC (pmap->keys);
302 +  XDELETEVEC (pmap->values);
303 +  XDELETE (pmap);
304 +}
305 +
306 +/* Returns a pointer to the value to which P maps, if PMAP contains P.  P
307 +   must be nonnull.  Return NULL if PMAP does not contain P.
308 +
309 +   Collisions are resolved by linear probing.  */
310 +void **
311 +pointer_map_contains (struct pointer_map_t *pmap, void *p)
312 +{
313 +  size_t n = hash1 (p, pmap->n_slots, pmap->log_slots);
314 +
315 +  while (true)
316 +    {
317 +      if (pmap->keys[n] == p)
318 +       return &pmap->values[n];
319 +      else if (pmap->keys[n] == 0)
320 +       return NULL;
321 +      else
322 +       {
323 +         ++n;
324 +         if (n == pmap->n_slots)
325 +           n = 0;
326 +       }
327 +    }
328 +}
329 +
330 +/* Inserts P into PMAP if it wasn't already there.  Returns a pointer
331 +   to the value.  P must be nonnull.  */
332 +void **
333 +pointer_map_insert (struct pointer_map_t *pmap, void *p)
334 +{
335 +  size_t n;
336 +
337 +  /* For simplicity, expand the map even if P is already there.  This can be
338 +     superfluous but can happen at most once.  */
339 +  if (pmap->n_elements > pmap->n_slots / 4)
340 +    {
341 +      size_t new_log_slots = pmap->log_slots + 1;
342 +      size_t new_n_slots = pmap->n_slots * 2;
343 +      void **new_keys = XCNEWVEC (void *, new_n_slots);
344 +      void **new_values = XCNEWVEC (void *, new_n_slots);
345 +      size_t i;
346 +
347 +      for (i = 0; i < pmap->n_slots; ++i)
348 +       if (pmap->keys[i])
349 +         {
350 +           void *key = pmap->keys[i];
351 +           n = insert_aux (key, new_keys, new_n_slots, new_log_slots);
352 +           new_keys[n] = key;
353 +           new_values[n] = pmap->values[i];
354 +         }
355 +
356 +      XDELETEVEC (pmap->keys);
357 +      XDELETEVEC (pmap->values);
358 +      pmap->n_slots = new_n_slots;
359 +      pmap->log_slots = new_log_slots;
360 +      pmap->keys = new_keys;
361 +      pmap->values = new_values;
362 +    }
363 +
364 +  n = insert_aux (p, pmap->keys, pmap->n_slots, pmap->log_slots);
365 +  if (!pmap->keys[n])
366 +    {
367 +      ++pmap->n_elements;
368 +      pmap->keys[n] = p;
369 +    }
370 +
371 +  return &pmap->values[n];
372 +}
373 +
374 +/* Pass each pointer in PMAP to the function in FN, together with the pointer
375 +   to the value and the fixed parameter DATA.  If FN returns false, the
376 +   iteration stops.  */
377 +
378 +void pointer_map_traverse (struct pointer_map_t *pmap,
379 +                          bool (*fn) (void *, void **, void *), void *data)
380 +{
381 +  size_t i;
382 +  for (i = 0; i < pmap->n_slots; ++i)
383 +    if (pmap->keys[i] && !fn (pmap->keys[i], &pmap->values[i], data))
384 +      break;
385 +}
386 Index: gcc/pointer-set.h
387 ===================================================================
388 --- gcc/pointer-set.h   (.../tags/gcc_4_2_0_release)    (revision 125292)
389 +++ gcc/pointer-set.h   (.../branches/gcc-4_2-branch)   (revision 125292)
390 @@ -22,11 +22,21 @@
391  #define POINTER_SET_H
392  
393  struct pointer_set_t;
394 -
395  struct pointer_set_t *pointer_set_create (void);
396  void pointer_set_destroy (struct pointer_set_t *pset);
397  
398  int pointer_set_contains (struct pointer_set_t *pset, void *p);
399  int pointer_set_insert (struct pointer_set_t *pset, void *p);
400 +void pointer_set_traverse (struct pointer_set_t *, bool (*) (void *, void *),
401 +                          void *);
402  
403 +struct pointer_map_t;
404 +struct pointer_map_t *pointer_map_create (void);
405 +void pointer_map_destroy (struct pointer_map_t *pmap);
406 +
407 +void **pointer_map_contains (struct pointer_map_t *pmap, void *p);
408 +void **pointer_map_insert (struct pointer_map_t *pmap, void *p);
409 +void pointer_map_traverse (struct pointer_map_t *,
410 +                          bool (*) (void *, void **, void *), void *);
411 +
412  #endif  /* POINTER_SET_H  */
413 Index: gcc/fold-const.c
414 ===================================================================
415 --- gcc/fold-const.c    (.../tags/gcc_4_2_0_release)    (revision 125292)
416 +++ gcc/fold-const.c    (.../branches/gcc-4_2-branch)   (revision 125292)
417 @@ -12634,9 +12634,14 @@
418        /* ... fall through ...  */
419  
420      default:
421 -      if (truth_value_p (TREE_CODE (t)))
422 -       /* Truth values evaluate to 0 or 1, which is nonnegative.  */
423 -       return 1;
424 +      {
425 +       tree type = TREE_TYPE (t);
426 +       if ((TYPE_PRECISION (type) != 1 || TYPE_UNSIGNED (type))
427 +           && truth_value_p (TREE_CODE (t)))
428 +         /* Truth values evaluate to 0 or 1, which is nonnegative unless we
429 +             have a signed:1 type (where the value is -1 and 0).  */
430 +         return true;
431 +      }
432      }
433  
434    /* We don't know sign of `t', so be conservative and return false.  */
435 Index: gcc/DEV-PHASE
436 ===================================================================
437 --- gcc/DEV-PHASE       (.../tags/gcc_4_2_0_release)    (revision 125292)
438 +++ gcc/DEV-PHASE       (.../branches/gcc-4_2-branch)   (revision 125292)
439 @@ -0,0 +1 @@
440 +prerelease
441 Index: gcc/ChangeLog
442 ===================================================================
443 --- gcc/ChangeLog       (.../tags/gcc_4_2_0_release)    (revision 125292)
444 +++ gcc/ChangeLog       (.../branches/gcc-4_2-branch)   (revision 125292)
445 @@ -1,3 +1,174 @@
446 +2007-05-31  H.J. Lu  <hongjiu.lu@intel.com>
447 +
448 +       Backport from mainline:
449 +       2007-05-25  H.J. Lu  <hongjiu.lu@intel.com>
450 +
451 +       * config/i386/i386.c (__builtin_ia32_vec_ext_v2df): Mark it
452 +       with MASK_SSE2.
453 +       (__builtin_ia32_vec_ext_v2di): Likewise.
454 +       (__builtin_ia32_vec_ext_v4si): Likewise.
455 +       (__builtin_ia32_vec_ext_v8hi): Likewise.
456 +       (__builtin_ia32_vec_set_v8hi): Likewise.
457 +
458 +2007-05-31  John David Anglin  <dave.anglin@nrc-cnrc.gc.ca>
459 +
460 +       Backport from mainline:
461 +       2007-05-05  Aurelien Jarno  <aurelien@aurel32.net>
462 +
463 +       * config/pa/pa.md: Split tgd_load, tld_load and tie_load
464 +       into pic and non-pic versions. Mark r19 as used for 
465 +       tgd_load_pic, tld_load_pic and tie_load_pic. Mark r27 as used 
466 +       for tgd_load, tld_load and tie_load .
467 +       * config/pa/pa.c (legitimize_tls_address): Emit pic or non-pic
468 +       version of tgd_load, tld_load and tie_load depending on the 
469 +       value of flag_pic.
470 +
471 +2007-05-27  Daniel Berlin <dberlin@dberlin.org>
472 +
473 +       Fix PR/30052
474 +       Backport PTA solver from mainline
475 +
476 +       * pointer-set.c: Copy from mainline
477 +       * pointer-set.h: Ditto.
478 +       * tree-ssa-structalias.c: Copy solver portions from mainline.
479 +       * Makefile.in (tree-ssa-structalias.o): Update dependencies
480 +
481 +2007-05-30  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
482 +
483 +       * tree-vrp.c (compare_names): Initialize sop.
484 +
485 +2007-05-30  Jakub Jelinek  <jakub@redhat.com>
486 +
487 +       PR tree-optimization/31769
488 +       * except.c (duplicate_eh_regions): Clear prev_try if
489 +       ERT_MUST_NOT_THROW region is inside of ERT_TRY region.
490 +
491 +2007-05-28  Andrew Pinski  <andrew_pinski@playstation.sony.com>
492 +
493 +       PR tree-opt/32100
494 +       * fold-const.c (tree_expr_nonnegative_warnv_p): Don't
495 +       return true when truth_value_p is true and the type
496 +       is of signed:1.
497 +
498 +2007-05-27  H.J. Lu  <hongjiu.lu@intel.com>
499 +
500 +       Backport from mainline:
501 +       2007-05-25  Uros Bizjak  <ubizjak@gmail.com>
502 +
503 +       * config/i386/sse.md (*vec_extractv2di_1_sse2): Do not calculate
504 +       "memory" attribute for "sseishft" type insn without operands[2].
505 +
506 +       2007-05-25  H.J. Lu  <hongjiu.lu@intel.com>
507 +
508 +       * config/i386/sse.md (*vec_extractv2di_1_sse2): Correct shift.
509 +
510 +2007-05-22  Ian Lance Taylor  <iant@google.com>
511 +
512 +       * tree-vrp.c (avoid_overflow_infinity): New static function,
513 +       broken out of set_value_range_to_value.
514 +       (set_value_range_to_value): Call avoid_overflow_infinity.
515 +       (extract_range_from_assert): Likewise.
516 +
517 +2007-05-23  Chen Liqin  <liqin@sunnorth.com.cn>
518 +
519 +       PR target/30987
520 +       * config/score/misc.md (bitclr_c, bitset_c, bittgl_c): remove.
521 +       * config/score/predicate.md (const_pow2, const_npow2): remove.
522 +       * config/score/score.h (ASM_OUTPUT_EXTERNAL): add ASM_OUTPUT_EXTERNAL undef.
523 +       PR target/30474
524 +       * config/score/score.c (score_print_operand): makes sure that only lower 
525 +       bits are used.
526 +       
527 +2007-05-21  Uros Bizjak  <ubizjak@gmail.com>
528 +
529 +       PR target/31167
530 +       Backport from mainline.
531 +       * config/i386/i386.md (*addti3_1, *addti3_1 splitter): Use
532 +       x86_64_general_operand as operand[2] predicate.  Remove "iF"
533 +       from operand constraints and use "e" constraint instead.
534 +       (*subti3_1, *subti3_1 splitter): Ditto.
535 +       (*negti2_1, *negti2_1 splitter): Use nonimmediate_operand as
536 +       operand[1] predicate.
537 +
538 +2007-05-21  Uros Bizjak  <ubizjak@gmail.com>
539 +
540 +       PR target/30041
541 +       Backport from mainline.
542 +       * config/i386/sse.md ("*sse3_movddup"): Use operands[0] and
543 +       operands[1] in insn constraint.  Correct type attribute to sselog1.
544 +
545 +2007-05-20  Kaz Kojima  <kkojima@gcc.gnu.org>
546 +
547 +       PR target/31701
548 +       Backport from mainline.
549 +       * config/sh/sh.c (output_stack_adjust): Avoid using the frame
550 +       register itself to hold the offset constant.  Tell flow the use
551 +       of r4 and r5 when they are used.
552 +
553 +2007-05-20  Kaz Kojima  <kkojima@gcc.gnu.org>
554 +
555 +       PR target/31480
556 +       Backport from mainline.
557 +       * config/sh/sh.md (length): Check if prev_nonnote_insn (insn)
558 +       is null.
559 +
560 +2007-05-20  Kaz Kojima  <kkojima@gcc.gnu.org>
561 +
562 +       PR target/31022
563 +       Backport from mainline.
564 +       * config/sh/sh.c (sh_adjust_cost): Use the result of single_set
565 +       instead of PATTERN.
566 +
567 +2007-05-20  Kaz Kojima  <kkojima@gcc.gnu.org>
568 +
569 +       PR target/27405
570 +       Backport from mainline.
571 +       * config/sh/sh.md (cmp{eq,gt,gtu}{si,di}_media): Remove.
572 +       (cmpsi{eq,gt,gtu}{si,di}_media): Rename to
573 +       cmp{eq,gt,gtu}{si,di}_media.
574 +       (*cmpne0si_media): Remove.
575 +       (*movsicc_umin): Adjust gen_cmp*_media call.
576 +       (unordered): Change the mode of unordered and operands[1] to
577 +       SImode.
578 +       (seq): Adjust gen_cmp*_media calls.  Make the mode of
579 +       a temporary result of compare SImode if needed.  If the mode
580 +       of operands[0] is DImode, extend the temporary result to DImode.
581 +       (slt, sle, sgt, sge, sgtu, sltu, sleu, sgue, sne): Likewise.
582 +       (sunorderd): Change the mode of match_operand and unorderd to
583 +       SImode.
584 +       (cmpeq{sf,df}_media): Remove.
585 +       (cmpsieq{sf,df}_media): Rename to cmpeq{sf,df}_media.
586 +       (cmp{gt,ge,un}{sf,df}_media): Change the mode of match_operand
587 +       and compare operation to SImode.
588 +
589 +2007-05-18  Joseph Myers  <joseph@codesourcery.com>
590 +
591 +       * config/soft-fp/double.h, config/soft-fp/extended.h,
592 +       config/soft-fp/floatundidf.c, config/soft-fp/floatundisf.c,
593 +       config/soft-fp/floatunsidf.c, config/soft-fp/floatunsisf.c,
594 +       config/soft-fp/op-2.h, config/soft-fp/op-4.h,
595 +       config/soft-fp/op-common.h, config/soft-fp/quad.h: Update from
596 +       glibc CVS.
597 +
598 +2007-05-17  Ian Lance Taylor  <iant@google.com>
599 +
600 +       PR tree-optimization/31953
601 +       * tree-vrp.c (set_value_range_to_value): Add equiv parameter.
602 +       Change all callers.
603 +       (set_value_range_to_null): Call set_value_range_to_value.
604 +       (extract_range_from_comparison): Likewise.
605 +
606 +2007-05-17  Eric Botcazou  <ebotcazou@libertysurf.fr>
607 +
608 +       PR rtl-optimization/31691
609 +       * combine.c (simplify_set): Build a new src pattern instead of
610 +       substituting its operands in the COMPARE case.
611 +
612 +2007-05-14  Mark Mitchell  <mark@codesourcery.com>
613 +
614 +       * BASE-VER: Set to 4.2.1.
615 +       * DEV-PHASE: Set to prerelease.
616 +
617  2007-05-13  Release Manager
618  
619         * GCC 4.2.0 released.
620 @@ -307,7 +478,8 @@
621  2007-04-03  Stuart Hastings  <stuart@apple.com>
622  
623         PR 31281
624 -       * objc/objc-act.c (next_sjlj_build_catch_list): Delete volatile from rethrow decl.
625 +       * objc/objc-act.c (next_sjlj_build_catch_list): Delete volatile
626 +       from rethrow decl.
627         * cse.c (record_jump_equiv): Bail out on CCmode comparisons.
628  
629  2007-04-03  Jakub Jelinek  <jakub@redhat.com>
630 Index: gcc/testsuite/gcc.c-torture/execute/vrp-7.c
631 ===================================================================
632 --- gcc/testsuite/gcc.c-torture/execute/vrp-7.c (.../tags/gcc_4_2_0_release)    (revision 0)
633 +++ gcc/testsuite/gcc.c-torture/execute/vrp-7.c (.../branches/gcc-4_2-branch)   (revision 125292)
634 @@ -0,0 +1,20 @@
635 +
636 +void abort (void);
637 +
638 +struct T
639 +{
640 +  int b : 1;
641 +} t;
642 +
643 +void __attribute__((noinline)) foo (int f)
644 +{
645 +  t.b = (f & 0x10) ? 1 : 0;
646 +}
647 +
648 +int main (void)
649 +{
650 +  foo (0x10);
651 +  if (!t.b)
652 +    abort ();
653 +  return 0;
654 +}
655 Index: gcc/testsuite/gcc.c-torture/execute/20070517-1.c
656 ===================================================================
657 --- gcc/testsuite/gcc.c-torture/execute/20070517-1.c    (.../tags/gcc_4_2_0_release)    (revision 0)
658 +++ gcc/testsuite/gcc.c-torture/execute/20070517-1.c    (.../branches/gcc-4_2-branch)   (revision 125292)
659 @@ -0,0 +1,41 @@
660 +/* PR rtl-optimization/31691 */
661 +/* Origin: Chi-Hua Chen <stephaniechc-gccbug@yahoo.com> */
662 +
663 +extern void abort (void);
664 +
665 +static int get_kind(int) __attribute__ ((noinline));
666 +
667 +static int get_kind(int v)
668 +{
669 +  volatile int k = v;
670 +  return k;
671 +}
672 +
673 +static int some_call(void) __attribute__ ((noinline));
674 +
675 +static int some_call(void)
676 +{
677 +  return 0;
678 +}
679 +
680 +static void example (int arg)
681 +{
682 +  int tmp, kind = get_kind (arg);
683 +
684 +  if (kind == 9 || kind == 10 || kind == 5)
685 +    {
686 +      if (some_call() == 0)
687 +        {
688 +          if (kind == 9 || kind == 10)
689 +            tmp = arg;
690 +          else
691 +            abort();
692 +        }
693 +    }
694 +} 
695 +
696 +int main(void)
697 +{
698 +  example(10);
699 +  return 0;
700 +}
701 Index: gcc/testsuite/gcc.c-torture/compile/pr31953.c
702 ===================================================================
703 --- gcc/testsuite/gcc.c-torture/compile/pr31953.c       (.../tags/gcc_4_2_0_release)    (revision 0)
704 +++ gcc/testsuite/gcc.c-torture/compile/pr31953.c       (.../branches/gcc-4_2-branch)   (revision 125292)
705 @@ -0,0 +1,14 @@
706 +struct WView
707 +{
708 +  int hexedit_mode:1;
709 +};
710 +toggle_hexedit_mode (struct WView *view)
711 +{
712 +  if (view->hexedit_mode)
713 +    {
714 +    }
715 +  else
716 +    {
717 +      view->hexedit_mode = !view->hexedit_mode;
718 +    }
719 +}
720 Index: gcc/testsuite/gcc.target/i386/sse2-vec-3.c
721 ===================================================================
722 --- gcc/testsuite/gcc.target/i386/sse2-vec-3.c  (.../tags/gcc_4_2_0_release)    (revision 0)
723 +++ gcc/testsuite/gcc.target/i386/sse2-vec-3.c  (.../branches/gcc-4_2-branch)   (revision 125292)
724 @@ -0,0 +1,37 @@
725 +/* { dg-do run { target i?86-*-* x86_64-*-* } } */
726 +/* { dg-options "-O2 -msse2" } */
727 +
728 +#include "sse2-check.h"
729 +
730 +#include <emmintrin.h>
731 +
732 +static void
733 +sse2_test (void)
734 +{
735 +  union
736 +    {
737 +      __m128i x;
738 +      char c[16];
739 +      short s[8];
740 +      int i[4];
741 +      long long ll[2];
742 +    } val1;
743 +  int res[4];
744 +  int masks[4];
745 +  int i;
746 +
747 +  for (i = 0; i < 16; i++)
748 +    val1.c[i] = i;
749 +
750 +  res[0] = __builtin_ia32_vec_ext_v4si ((__v4si)val1.x, 0);
751 +  res[1] = __builtin_ia32_vec_ext_v4si ((__v4si)val1.x, 1);
752 +  res[2] = __builtin_ia32_vec_ext_v4si ((__v4si)val1.x, 2);
753 +  res[3] = __builtin_ia32_vec_ext_v4si ((__v4si)val1.x, 3);
754 +
755 +  for (i = 0; i < 4; i++)
756 +    masks[i] = i;
757 +
758 +  for (i = 0; i < 4; i++)
759 +    if (res[i] != val1.i [masks[i]])
760 +      abort ();
761 +}
762 Index: gcc/testsuite/gcc.target/i386/pr31167.c
763 ===================================================================
764 --- gcc/testsuite/gcc.target/i386/pr31167.c     (.../tags/gcc_4_2_0_release)    (revision 0)
765 +++ gcc/testsuite/gcc.target/i386/pr31167.c     (.../branches/gcc-4_2-branch)   (revision 125292)
766 @@ -0,0 +1,20 @@
767 +/* { dg-do compile { target x86_64-*-* } } */
768 +/* { dg-options "-O" } */
769 +
770 +typedef int int32_t;
771 +
772 +int32_t round32hi (const __int128_t arg)
773 +{
774 +  const int SHIFT = 96;
775 +  const int mshift = 96;
776 +  const __int128_t M = (~(__int128_t) 0) << mshift;
777 +  const __int128_t L = (~M) + 1;
778 +  const __int128_t L1 = ((__int128_t) L) >> 1;
779 +  const __int128_t Mlo = ((__int128_t) (~M)) >> 1;
780 +  __int128_t vv = arg & M;
781 +
782 +  if ((arg & (L1)) && ((arg & Mlo) || (arg & L)))
783 +    vv += L;
784 +
785 +  return (int32_t) (vv >> SHIFT);
786 +}
787 Index: gcc/testsuite/gcc.target/i386/sse2-vec-4.c
788 ===================================================================
789 --- gcc/testsuite/gcc.target/i386/sse2-vec-4.c  (.../tags/gcc_4_2_0_release)    (revision 0)
790 +++ gcc/testsuite/gcc.target/i386/sse2-vec-4.c  (.../branches/gcc-4_2-branch)   (revision 125292)
791 @@ -0,0 +1,41 @@
792 +/* { dg-do run { target i?86-*-* x86_64-*-* } } */
793 +/* { dg-options "-O2 -msse2" } */
794 +
795 +#include "sse2-check.h"
796 +
797 +#include <emmintrin.h>
798 +
799 +static void
800 +sse2_test (void)
801 +{
802 +  union
803 +    {
804 +      __m128i x;
805 +      char c[16];
806 +      short s[8];
807 +      int i[4];
808 +      long long ll[2];
809 +    } val1;
810 +  short res[8];
811 +  int masks[8];
812 +  int i;
813 +
814 +  for (i = 0; i < 16; i++)
815 +    val1.c[i] = i;
816 +
817 +  res[0] = __builtin_ia32_vec_ext_v8hi ((__v8hi)val1.x, 0);
818 +  res[1] = __builtin_ia32_vec_ext_v8hi ((__v8hi)val1.x, 1);
819 +  res[2] = __builtin_ia32_vec_ext_v8hi ((__v8hi)val1.x, 2);
820 +  res[3] = __builtin_ia32_vec_ext_v8hi ((__v8hi)val1.x, 3);
821 +  res[4] = __builtin_ia32_vec_ext_v8hi ((__v8hi)val1.x, 4);
822 +  res[5] = __builtin_ia32_vec_ext_v8hi ((__v8hi)val1.x, 5);
823 +  res[6] = __builtin_ia32_vec_ext_v8hi ((__v8hi)val1.x, 6);
824 +  res[7] = __builtin_ia32_vec_ext_v8hi ((__v8hi)val1.x, 7);
825 +
826 +  for (i = 0; i < 8; i++)
827 +    masks[i] = i;
828 +
829 +  for (i = 0; i < 8; i++)
830 +    if (res[i] != val1.s [masks[i]])
831 +      abort ();
832 +}
833 Index: gcc/testsuite/gcc.target/i386/sse2-check.h
834 ===================================================================
835 --- gcc/testsuite/gcc.target/i386/sse2-check.h  (.../tags/gcc_4_2_0_release)    (revision 0)
836 +++ gcc/testsuite/gcc.target/i386/sse2-check.h  (.../branches/gcc-4_2-branch)   (revision 125292)
837 @@ -0,0 +1,20 @@
838 +#include <stdio.h>
839 +#include <stdlib.h>
840 +
841 +#include "../../gcc.dg/i386-cpuid.h"
842 +
843 +static void sse2_test (void);
844 +
845 +int
846 +main ()
847 +{
848 +  unsigned long cpu_facilities;
849
850 +  cpu_facilities = i386_cpuid_edx ();
851 +
852 +  /* Run SSE2 test only if host has SSE2 support.  */
853 +  if ((cpu_facilities & bit_SSE2))
854 +    sse2_test ();
855 +
856 +  exit (0);
857 +}
858 Index: gcc/testsuite/gcc.target/i386/sse2-vec-1.c
859 ===================================================================
860 --- gcc/testsuite/gcc.target/i386/sse2-vec-1.c  (.../tags/gcc_4_2_0_release)    (revision 0)
861 +++ gcc/testsuite/gcc.target/i386/sse2-vec-1.c  (.../branches/gcc-4_2-branch)   (revision 125292)
862 @@ -0,0 +1,35 @@
863 +/* { dg-do run { target i?86-*-* x86_64-*-* } } */
864 +/* { dg-options "-O2 -msse2" } */
865 +
866 +#include "sse2-check.h"
867 +
868 +#include <emmintrin.h>
869 +
870 +#define msk0   0
871 +#define msk1   1
872 +
873 +static void
874 +sse2_test (void)
875 +{
876 +  union
877 +    {
878 +      __m128d x;
879 +      double d[2];
880 +    } val1;
881 +  double res[2];
882 +  int masks[2];
883 +  int i;
884 +
885 +  val1.d[0] = 23.;
886 +  val1.d[1] = 45;
887 +
888 +  res[0] = __builtin_ia32_vec_ext_v2df ((__v2df)val1.x, msk0);
889 +  res[1] = __builtin_ia32_vec_ext_v2df ((__v2df)val1.x, msk1);
890 +
891 +  masks[0] = msk0;
892 +  masks[1] = msk1;
893 +
894 +  for (i = 0; i < 2; i++)
895 +    if (res[i] != val1.d [masks[i]])
896 +      abort ();
897 +}
898 Index: gcc/testsuite/gcc.target/i386/sse2-vec-5.c
899 ===================================================================
900 --- gcc/testsuite/gcc.target/i386/sse2-vec-5.c  (.../tags/gcc_4_2_0_release)    (revision 0)
901 +++ gcc/testsuite/gcc.target/i386/sse2-vec-5.c  (.../branches/gcc-4_2-branch)   (revision 125292)
902 @@ -0,0 +1,49 @@
903 +/* { dg-do run { target i?86-*-* x86_64-*-* } } */
904 +/* { dg-options "-O2 -msse2" } */
905 +
906 +#include "sse2-check.h"
907 +
908 +#include <emmintrin.h>
909 +
910 +static void
911 +sse2_test (void)
912 +{
913 +  union
914 +    {
915 +      __m128i x;
916 +      char c[16];
917 +      short s[8];
918 +      int i[4];
919 +      long long ll[2];
920 +    } val1;
921 +  char res[16];
922 +  int masks[16];
923 +  int i;
924 +
925 +  for (i = 0; i < 16; i++)
926 +    val1.c[i] = i;
927 +
928 +  res[0] = __builtin_ia32_vec_ext_v16qi ((__v16qi)val1.x, 0);
929 +  res[1] = __builtin_ia32_vec_ext_v16qi ((__v16qi)val1.x, 1);
930 +  res[2] = __builtin_ia32_vec_ext_v16qi ((__v16qi)val1.x, 2);
931 +  res[3] = __builtin_ia32_vec_ext_v16qi ((__v16qi)val1.x, 3);
932 +  res[4] = __builtin_ia32_vec_ext_v16qi ((__v16qi)val1.x, 4);
933 +  res[5] = __builtin_ia32_vec_ext_v16qi ((__v16qi)val1.x, 5);
934 +  res[6] = __builtin_ia32_vec_ext_v16qi ((__v16qi)val1.x, 6);
935 +  res[7] = __builtin_ia32_vec_ext_v16qi ((__v16qi)val1.x, 7);
936 +  res[8] = __builtin_ia32_vec_ext_v16qi ((__v16qi)val1.x, 8);
937 +  res[9] = __builtin_ia32_vec_ext_v16qi ((__v16qi)val1.x, 9);
938 +  res[10] = __builtin_ia32_vec_ext_v16qi ((__v16qi)val1.x, 10);
939 +  res[11] = __builtin_ia32_vec_ext_v16qi ((__v16qi)val1.x, 11);
940 +  res[12] = __builtin_ia32_vec_ext_v16qi ((__v16qi)val1.x, 12);
941 +  res[13] = __builtin_ia32_vec_ext_v16qi ((__v16qi)val1.x, 13);
942 +  res[14] = __builtin_ia32_vec_ext_v16qi ((__v16qi)val1.x, 14);
943 +  res[15] = __builtin_ia32_vec_ext_v16qi ((__v16qi)val1.x, 15);
944 +
945 +  for (i = 0; i < 16; i++)
946 +    masks[i] = i;
947 +
948 +  for (i = 0; i < 16; i++)
949 +    if (res[i] != val1.c [masks[i]])
950 +      abort ();
951 +}
952 Index: gcc/testsuite/gcc.target/i386/sse2-vec-2.c
953 ===================================================================
954 --- gcc/testsuite/gcc.target/i386/sse2-vec-2.c  (.../tags/gcc_4_2_0_release)    (revision 0)
955 +++ gcc/testsuite/gcc.target/i386/sse2-vec-2.c  (.../branches/gcc-4_2-branch)   (revision 125292)
956 @@ -0,0 +1,35 @@
957 +/* { dg-do run { target i?86-*-* x86_64-*-* } } */
958 +/* { dg-options "-O2 -msse2" } */
959 +
960 +#include "sse2-check.h"
961 +
962 +#include <emmintrin.h>
963 +
964 +static void
965 +sse2_test (void)
966 +{
967 +  union
968 +    {
969 +      __m128i x;
970 +      char c[16];
971 +      short s[8];
972 +      int i[4];
973 +      long long ll[2];
974 +    } val1;
975 +  long long res[2];
976 +  int masks[2];
977 +  int i;
978 +
979 +  for (i = 0; i < 16; i++)
980 +    val1.c[i] = i;
981 +
982 +  res[0] = __builtin_ia32_vec_ext_v2di ((__v2di)val1.x, 0);
983 +  res[1] = __builtin_ia32_vec_ext_v2di ((__v2di)val1.x, 1);
984 +
985 +  for (i = 0; i < 2; i++)
986 +    masks[i] = i;
987 +
988 +  for (i = 0; i < 2; i++)
989 +    if (res[i] != val1.ll [masks[i]])
990 +      abort ();
991 +}
992 Index: gcc/testsuite/gcc.target/i386/sse2-vec-6.c
993 ===================================================================
994 --- gcc/testsuite/gcc.target/i386/sse2-vec-6.c  (.../tags/gcc_4_2_0_release)    (revision 0)
995 +++ gcc/testsuite/gcc.target/i386/sse2-vec-6.c  (.../branches/gcc-4_2-branch)   (revision 125292)
996 @@ -0,0 +1,69 @@
997 +/* { dg-do run { target i?86-*-* x86_64-*-* } } */
998 +/* { dg-options "-O2 -msse2" } */
999 +
1000 +#include "sse2-check.h"
1001 +
1002 +#include <emmintrin.h>
1003 +#include <string.h>
1004 +
1005 +static void
1006 +sse2_test (void)
1007 +{
1008 +  union
1009 +    {
1010 +      __m128i x;
1011 +      char c[16];
1012 +      short s[8];
1013 +      int i[4];
1014 +      long long ll[2];
1015 +    } val1, res[16], tmp;
1016 +  short ins[8] = { 8, 5, 9, 4, 2, 6, 1, 20 };
1017 +  int masks[8];
1018 +  int i;
1019 +
1020 +  for (i = 0; i < 16; i++)
1021 +    val1.c[i] = i;
1022 +
1023 +  res[0].x = (__m128i) __builtin_ia32_vec_set_v8hi ((__v8hi)val1.x,
1024 +                                                   ins[0], 0);
1025 +  res[1].x = (__m128i) __builtin_ia32_vec_set_v8hi ((__v8hi)val1.x,
1026 +                                                   ins[0], 1);
1027 +  res[2].x = (__m128i) __builtin_ia32_vec_set_v8hi ((__v8hi)val1.x,
1028 +                                                   ins[0], 2);
1029 +  res[3].x = (__m128i) __builtin_ia32_vec_set_v8hi ((__v8hi)val1.x,
1030 +                                                   ins[0], 3);
1031 +  res[4].x = (__m128i) __builtin_ia32_vec_set_v8hi ((__v8hi)val1.x,
1032 +                                                   ins[0], 4);
1033 +  res[5].x = (__m128i) __builtin_ia32_vec_set_v8hi ((__v8hi)val1.x,
1034 +                                                   ins[0], 5);
1035 +  res[6].x = (__m128i) __builtin_ia32_vec_set_v8hi ((__v8hi)val1.x,
1036 +                                                   ins[0], 6);
1037 +  res[7].x = (__m128i) __builtin_ia32_vec_set_v8hi ((__v8hi)val1.x,
1038 +                                                   ins[0], 7);
1039 +
1040 +  for (i = 0; i < 8; i++)
1041 +    masks[i] = i;
1042 +
1043 +  for (i = 0; i < 8; i++)
1044 +    {
1045 +      tmp.x = val1.x;
1046 +      tmp.s[masks[i]] = ins[0];
1047 +      if (memcmp (&tmp, &res[i], sizeof (tmp)))
1048 +       abort ();
1049 +    }
1050 +
1051 +  for (i = 0; i < 8; i++)
1052 +    {
1053 +      res[i].x = (__m128i) __builtin_ia32_vec_set_v8hi ((__v8hi)val1.x,
1054 +                                                       ins[i], 0);
1055 +      masks[i] = 0;
1056 +    }
1057 +
1058 +  for (i = 0; i < 8; i++)
1059 +    {
1060 +      tmp.x = val1.x;
1061 +      tmp.s[masks[i]] = ins[i];
1062 +      if (memcmp (&tmp, &res[i], sizeof (tmp)))
1063 +       abort ();
1064 +    }
1065 +}
1066 Index: gcc/testsuite/ChangeLog
1067 ===================================================================
1068 --- gcc/testsuite/ChangeLog     (.../tags/gcc_4_2_0_release)    (revision 125292)
1069 +++ gcc/testsuite/ChangeLog     (.../branches/gcc-4_2-branch)   (revision 125292)
1070 @@ -1,3 +1,104 @@
1071 +2007-05-31  H.J. Lu  <hongjiu.lu@intel.com>
1072 +
1073 +       Backport from mainline:
1074 +       2007-05-25  H.J. Lu  <hongjiu.lu@intel.com>
1075 +
1076 +       * gcc.target/i386/sse2-check.h: New.
1077 +       * gcc.target/i386/sse2-vec-1.c: Likewise.
1078 +       * gcc.target/i386/sse2-vec-2.c: Likewise.
1079 +       * gcc.target/i386/sse2-vec-3.c: Likewise.
1080 +       * gcc.target/i386/sse2-vec-4.c: Likewise.
1081 +       * gcc.target/i386/sse2-vec-5.c: Likewise.
1082 +       * gcc.target/i386/sse2-vec-6.c: Likewise.
1083 +
1084 +2007-05-31  Paul Thomas  <pault@gcc.gnu.org>
1085 +
1086 +       PR fortran/31483
1087 +       * gfortran.dg/altreturn_5.f90: New test.
1088 +
1089 +       PR fortran/31540
1090 +       * gfortran.dg/char_result_5.f90: New test.
1091 +
1092 +       PR fortran/31867
1093 +       * gfortran.dg/char_length_5.f90: New test.
1094 +
1095 +       PR fortran/31994
1096 +       * gfortran.dg/array_reference_1.f90: New test.
1097 +
1098 +2007-05-22  Tobias Burnus  <burnus@net-b.de>
1099 +
1100 +       PR fortran/31559
1101 +       Backport from mainline.
1102 +       * primary.c (match_variable): External functions
1103 +       are no variables.
1104 +
1105 +2007-05-30  Jakub Jelinek  <jakub@redhat.com>
1106 +
1107 +       PR tree-optimization/31769
1108 +       * g++.dg/gomp/pr31769.C: New test.
1109 +
1110 +2007-05-28  Andrew Pinski  <andrew_pinski@playstation.sony.com>
1111 +
1112 +       PR tree-opt/32100
1113 +       * gcc.c-torture/execute/vrp-7.c: New test.
1114 +        
1115 +2007-05-23  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
1116 +
1117 +       PR libfortran/31964
1118 +       * gfortran.fortran-torture/execute/intrinsic_bitops.f90: Update.
1119 +
1120 +2007-05-22  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
1121 +
1122 +       PR libgfortran/31051
1123 +       * gfortran.dg/fmt_t_3.f90: New.
1124 +
1125 +2007-05-22  Dominique d'Humieres  <dominiq@lps.ens.fr>
1126 +
1127 +       * gfortran.dg/unf_io_convert_3.f90: Fix dg directive.
1128 +
1129 +2007-05-22  Tobias Burnus  <burnus@net-b.de>
1130 +
1131 +       PR fortran/31559
1132 +       Backport from mainline.
1133 +       * func_assign.f90: New test.
1134 +
1135 +2007-05-21  Uros Bizjak  <ubizjak@gmail.com>
1136 +
1137 +       PR target/31167
1138 +       Backport from mainline.
1139 +       * gcc.target/i386/pr31167.c: New test.
1140 +
1141 +2007-05-20  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
1142 +
1143 +       PR libgfortran/31395
1144 +       * gfortran.dg/fmt_colon.f90: New test.
1145 +
1146 +2007-05-20  Thomas Koenig  <tkoenig@gcc.gnu.org>
1147 +
1148 +       PR fortran/31618
1149 +       Backport from trunk.
1150 +       * gfortran.dg/backspace_8.f:  New test case.
1151 +
1152 +2007-05-20  Thomas Koenig  <tkoenig@gcc.gnu.org>
1153 +
1154 +       PR libfortran/31196
1155 +       Backport from trunk.
1156 +       * gfortran.dg/reshape_transpose_1.f90:  New test.
1157 +
1158 +2007-05-17  Ian Lance Taylor  <iant@google.com>
1159 +
1160 +       PR tree-optimization/31953
1161 +       * gcc.c-torture/compile/pr31953.c: New test.
1162 +
1163 +2007-05-17  Eric Botcazou  <ebotcazou@libertysurf.fr>
1164 +
1165 +       * gcc.c-torture/execute/20070517-1.c: New test.
1166 +
1167 +2007-05-16  Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>
1168 +
1169 +       PR fortran/31725
1170 +       * gfortran.dg/substr_4.f: New test.
1171 +
1172  2007-05-13  Release Manager
1173  
1174         * GCC 4.2.0 released.
1175 Index: gcc/testsuite/gfortran.fortran-torture/execute/intrinsic_bitops.f90
1176 ===================================================================
1177 --- gcc/testsuite/gfortran.fortran-torture/execute/intrinsic_bitops.f90 (.../tags/gcc_4_2_0_release)    (revision 125292)
1178 +++ gcc/testsuite/gfortran.fortran-torture/execute/intrinsic_bitops.f90 (.../branches/gcc-4_2-branch)   (revision 125292)
1179 @@ -8,7 +8,8 @@
1180     i = 2
1181     j = 3
1182     k = 12
1183 -
1184 +   a = 5
1185 +   
1186     if (.not. btest (i, o+1)) call abort
1187     if (btest (i, o+2)) call abort
1188     if (iand (i, j) .ne. 2) call abort
1189 @@ -26,4 +27,6 @@
1190     if (ishftc (k, o-30) .ne. 48) call abort
1191     if (ishftc (k, o+1, o+3) .ne. 9) call abort
1192     if (not (i) .ne. -3) call abort
1193 +   if (ishftc (a, 1, bit_size(a)) .ne. 10) call abort
1194 +   if (ishftc (1, 1, 32) .ne. 2) call abort
1195  end program
1196 Index: gcc/testsuite/g++.dg/gomp/pr31769.C
1197 ===================================================================
1198 --- gcc/testsuite/g++.dg/gomp/pr31769.C (.../tags/gcc_4_2_0_release)    (revision 0)
1199 +++ gcc/testsuite/g++.dg/gomp/pr31769.C (.../branches/gcc-4_2-branch)   (revision 125292)
1200 @@ -0,0 +1,61 @@
1201 +// PR tree-optimization/31769
1202 +// { dg-options "-O2 -fopenmp" }
1203 +// { dg-do compile }
1204 +
1205 +struct B
1206 +{
1207 +  B () {}
1208 +  virtual ~B () {}
1209 +};
1210 +struct C
1211 +{
1212 +  C (int x, int y) {}
1213 +};
1214 +template<typename T, int U>
1215 +struct D
1216 +{
1217 +  D () {}
1218 +  ~D () {}
1219 +};
1220 +struct E
1221 +{
1222 +  E () {}
1223 +  ~E () {}
1224 +  D<int, 1> e;
1225 +};
1226 +struct A
1227 +{
1228 +  B *b;
1229 +  A () { b = __null; }
1230 +  ~A () { if (b != __null) delete b; }
1231 +};
1232 +struct F : public A
1233 +{
1234 +  explicit F (int x) { foo (0); }
1235 +  F (const F &x) {}
1236 +  F (F &x, C y) {}
1237 +  F operator () (C x) const
1238 +  {
1239 +    return F (const_cast<F &>(*this), x);
1240 +  }
1241 +  template <typename U> F & operator+= (const U &);
1242 +  void foo (int);
1243 +  E f;
1244 +};
1245 +
1246 +int
1247 +main ()
1248 +{
1249 +  try
1250 +  {
1251 +    F f (10);
1252 +    F g (10);
1253 +    C h (0, 9);
1254 +#pragma omp parallel for
1255 +    for (int i = 0; i < 2; ++i)
1256 +      g += f (h);
1257 +  }
1258 +  catch (int &e)
1259 +  {
1260 +  }
1261 +}
1262 Index: gcc/testsuite/gfortran.dg/char_length_5.f90
1263 ===================================================================
1264 --- gcc/testsuite/gfortran.dg/char_length_5.f90 (.../tags/gcc_4_2_0_release)    (revision 0)
1265 +++ gcc/testsuite/gfortran.dg/char_length_5.f90 (.../branches/gcc-4_2-branch)   (revision 125292)
1266 @@ -0,0 +1,61 @@
1267 +! { dg-do run }
1268 +! Tests the fix for PR31867, in which the interface evaluation
1269 +! of the character length of 'join' (ie. the length available in
1270 +! the caller) was wrong.
1271 +!
1272 +! Contributed by <beliavsky@aol.com> 
1273 +!
1274 +module util_mod
1275 +  implicit none
1276 +contains
1277 +  function join (words, sep) result(str)
1278 +    character (len=*), intent(in)        :: words(:),sep
1279 +    character (len = (size (words) - 1) * len_trim (sep) + & 
1280 +               sum (len_trim (words)))   :: str
1281 +    integer                              :: i,nw
1282 +    nw  = size (words)
1283 +    str = ""
1284 +    if (nw < 1) then
1285 +      return
1286 +    else
1287 +      str = words(1)
1288 +    end if
1289 +    do i=2,nw
1290 +      str = trim (str) // trim (sep) // words(i)
1291 +    end do
1292 +  end function join
1293 +end module util_mod
1294 +!
1295 +program xjoin
1296 +  use util_mod, only: join
1297 +  implicit none
1298 +  integer yy
1299 +  character (len=5) :: words(5:8) = (/"two  ","three","four ","five "/), sep = "^#^"
1300 +  character (len=5) :: words2(4) = (/"bat  ","ball ","goal ","stump"/), sep2 = "&"
1301 +
1302 +  if (join (words, sep) .ne. "two^#^three^#^four^#^five") call abort ()
1303 +  if (len (join (words, sep)) .ne. 25) call abort ()
1304 +
1305 +  if (join (words(5:6), sep) .ne. "two^#^three") call abort ()
1306 +  if (len (join (words(5:6), sep)) .ne. 11) call abort ()
1307 +
1308 +  if (join (words(7:8), sep) .ne. "four^#^five") call abort ()
1309 +  if (len (join (words(7:8), sep)) .ne. 11) call abort ()
1310 +
1311 +  if (join (words(5:7:2), sep) .ne. "two^#^four") call abort ()
1312 +  if (len (join (words(5:7:2), sep)) .ne. 10) call abort ()
1313 +
1314 +  if (join (words(6:8:2), sep) .ne. "three^#^five") call abort ()
1315 +  if (len (join (words(6:8:2), sep)) .ne. 12) call abort ()
1316 +
1317 +  if (join (words2, sep2) .ne. "bat&ball&goal&stump") call abort ()
1318 +  if (len (join (words2, sep2)) .ne. 19) call abort ()
1319 +
1320 +  if (join (words2(1:2), sep2) .ne. "bat&ball") call abort ()
1321 +  if (len (join (words2(1:2), sep2)) .ne. 8) call abort ()
1322 +
1323 +  if (join (words2(2:4:2), sep2) .ne. "ball&stump") call abort ()
1324 +  if (len (join (words2(2:4:2), sep2)) .ne. 10) call abort ()
1325 +
1326 +end program xjoin
1327 +! { dg-final { cleanup-modules "util_mod" } }
1328 Index: gcc/testsuite/gfortran.dg/array_reference_1.f90
1329 ===================================================================
1330 --- gcc/testsuite/gfortran.dg/array_reference_1.f90     (.../tags/gcc_4_2_0_release)    (revision 0)
1331 +++ gcc/testsuite/gfortran.dg/array_reference_1.f90     (.../branches/gcc-4_2-branch)   (revision 125292)
1332 @@ -0,0 +1,35 @@
1333 +! { dg-do run }
1334 +! Tests the fix for PR31994, aka 31867, in which the offset
1335 +! of 'a' in both subroutines was being evaluated incorrectly.
1336 +! The testcase for PR31867 is char_length_5.f90
1337 +!
1338 +! Contributed by Elizabeth Yip <elizabeth.l.yip@boeing.com>
1339 +!            and Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
1340 +!
1341 +program main
1342 +  call PR31994
1343 +  call PR31994_comment6
1344 +contains
1345 +  subroutine PR31994
1346 +    implicit none
1347 +    complex (kind=4), dimension(2,2) :: a, b, c
1348 +    a(1,1) = (1.,1.)
1349 +    a(2,1) = (2.,2.)
1350 +    a(1,2) = (3.,3.)
1351 +    a(2,2) = (4.,4.)
1352 +    b=conjg (transpose (a))
1353 +    c=transpose (a)
1354 +    c=conjg (c)
1355 +    if (any (b .ne. c)) call abort ()
1356 +  end subroutine PR31994
1357 +  subroutine PR31994_comment6
1358 +    implicit none
1359 +    real ,dimension(2,2)::a
1360 +    integer ,dimension(2,2) :: b, c
1361 +    a = reshape ((/1.,2.,3.,4./), (/2,2/))
1362 +    b=int (transpose(a))
1363 +    c = int (a)
1364 +    c = transpose (c)
1365 +    if (any (b .ne. c)) call abort ()
1366 +  end subroutine PR31994_comment6
1367 +END program main
1368 Index: gcc/testsuite/gfortran.dg/reshape_transpose_1.f90
1369 ===================================================================
1370 --- gcc/testsuite/gfortran.dg/reshape_transpose_1.f90   (.../tags/gcc_4_2_0_release)    (revision 0)
1371 +++ gcc/testsuite/gfortran.dg/reshape_transpose_1.f90   (.../branches/gcc-4_2-branch)   (revision 125292)
1372 @@ -0,0 +1,18 @@
1373 +! { dg-do run }
1374 +! PR 31196 - reshape of transposed derived types generated
1375 +!            wront results.
1376 +program main
1377 +  implicit none
1378 +  TYPE datatype
1379 +     INTEGER :: I
1380 +  END TYPE datatype
1381 +  character (len=20) line1, line2
1382 +  TYPE(datatype), dimension(2,2) :: data, result
1383 +  data(1,1)%i = 1
1384 +  data(2,1)%i = 2
1385 +  data(1,2)%i = 3
1386 +  data(2,2)%i = 4
1387 +  write (unit=line1, fmt="(4I4)") reshape(transpose(data),shape(data))
1388 +  write (unit=line2, fmt="(4I4)") (/ 1, 3, 2, 4 /)
1389 +  if (line1 /= line2) call abort
1390 +END program main
1391 Index: gcc/testsuite/gfortran.dg/fmt_colon.f90
1392 ===================================================================
1393 --- gcc/testsuite/gfortran.dg/fmt_colon.f90     (.../tags/gcc_4_2_0_release)    (revision 0)
1394 +++ gcc/testsuite/gfortran.dg/fmt_colon.f90     (.../branches/gcc-4_2-branch)   (revision 125292)
1395 @@ -0,0 +1,14 @@
1396 +! { dg-do run }
1397 +! PR31395 Colon edit descriptor is ignored.
1398 +! Test case derived from PR. Prepared by Jerry DeLisle
1399 +! <jvdelisle@gcc.gnu.org>
1400 +PROGRAM test
1401 +    INTEGER :: i = 1
1402 +    character(30) :: astring
1403 +    WRITE(astring, 10) i
1404 + 10 FORMAT('i =',I2:' this should not print')
1405 +    if (astring.ne."i = 1") call abort
1406 +    write(astring, 20) i, i
1407 + 20 format('i =',I2:' this should print',I2)
1408 +    if (astring.ne."i = 1 this should print 1") call abort
1409 +END PROGRAM test
1410 \ No newline at end of file
1411 Index: gcc/testsuite/gfortran.dg/char_result_13.f90
1412 ===================================================================
1413 --- gcc/testsuite/gfortran.dg/char_result_13.f90        (.../tags/gcc_4_2_0_release)    (revision 0)
1414 +++ gcc/testsuite/gfortran.dg/char_result_13.f90        (.../branches/gcc-4_2-branch)   (revision 125292)
1415 @@ -0,0 +1,13 @@
1416 +! { dg-do compile }
1417 +! tests the fix for PR31540, in which the character lengths in
1418 +! parentheses were not resolved.
1419 +!
1420 +! Contributed by Tobias Burnus <burnus@gcc.gnu.org>
1421 +!
1422 +        subroutine pfb()
1423 +        implicit none
1424 +        external pfname1, pfname2
1425 +        character ((136)) pfname1
1426 +        character ((129+7)) pfname2
1427 +        return
1428 +        end
1429 Index: gcc/testsuite/gfortran.dg/altreturn_5.f90
1430 ===================================================================
1431 --- gcc/testsuite/gfortran.dg/altreturn_5.f90   (.../tags/gcc_4_2_0_release)    (revision 0)
1432 +++ gcc/testsuite/gfortran.dg/altreturn_5.f90   (.../branches/gcc-4_2-branch)   (revision 125292)
1433 @@ -0,0 +1,30 @@
1434 +! { dg-do run }
1435 +! Tests the fix for PR31483, in which dummy argument procedures
1436 +! produced an ICE if they had an alternate return.
1437 +!
1438 +! Contributed by Mathias Fröhlich <M.Froehlich@science-computing.de>
1439 +
1440 +      SUBROUTINE R (i, *, *)
1441 +      INTEGER i
1442 +      RETURN i
1443 +      END
1444 +
1445 +      SUBROUTINE PHLOAD (READER, i, res)
1446 +      IMPLICIT NONE
1447 +      EXTERNAL         READER
1448 +      integer i
1449 +      character(3) res
1450 +      CALL READER (i, *1, *2)
1451 + 1    res = "one"
1452 +      return
1453 + 2    res = "two"
1454 +      return
1455 +      END
1456 +
1457 +      EXTERNAL R
1458 +      character(3) res
1459 +      call PHLOAD (R, 1, res)
1460 +      if (res .ne. "one") call abort ()
1461 +      CALL PHLOAD (R, 2, res)
1462 +      if (res .ne. "two") call abort ()
1463 +      END
1464 \ No newline at end of file
1465 Index: gcc/testsuite/gfortran.dg/substr_4.f
1466 ===================================================================
1467 --- gcc/testsuite/gfortran.dg/substr_4.f        (.../tags/gcc_4_2_0_release)    (revision 0)
1468 +++ gcc/testsuite/gfortran.dg/substr_4.f        (.../branches/gcc-4_2-branch)   (revision 125292)
1469 @@ -0,0 +1,69 @@
1470 +! { dg-do run }
1471 +      subroutine test_lower
1472 +      implicit none
1473 +      character(3), dimension(3) :: zsymel,zsymelr
1474 +      common /xx/ zsymel, zsymelr
1475 +      integer :: znsymelr
1476 +      zsymel = (/ 'X', 'Y', ' ' /)
1477 +      zsymelr= (/ 'X', 'Y', ' ' /)
1478 +      znsymelr=2
1479 +      call check_zsymel(zsymel,zsymelr,znsymelr)
1480 +
1481 +      contains
1482 +
1483 +      subroutine check_zsymel(zsymel,zsymelr,znsymelr)
1484 +        implicit none
1485 +        integer znsymelr, isym
1486 +        character(*) zsymel(*),zsymelr(*)
1487 +        character(len=80) buf
1488 +        zsymel(3)(lenstr(zsymel(3))+1:)='X'
1489 +        write (buf,10) (trim(zsymelr(isym)),isym=1,znsymelr)
1490 +10      format(3(a,:,','))
1491 +        if (trim(buf) /= 'X,Y') call abort
1492 +      end subroutine check_zsymel
1493 +
1494 +      function lenstr(s)
1495 +        character(len=*),intent(in) :: s
1496 +        integer :: lenstr
1497 +        if (len_trim(s) /= 0) call abort
1498 +        lenstr = len_trim(s)
1499 +      end function lenstr
1500 +
1501 +      end subroutine test_lower
1502 +
1503 +      subroutine test_upper
1504 +      implicit none
1505 +      character(3), dimension(3) :: zsymel,zsymelr
1506 +      common /xx/ zsymel, zsymelr
1507 +      integer :: znsymelr
1508 +      zsymel = (/ 'X', 'Y', ' ' /)
1509 +      zsymelr= (/ 'X', 'Y', ' ' /)
1510 +      znsymelr=2
1511 +      call check_zsymel(zsymel,zsymelr,znsymelr)
1512 +
1513 +      contains
1514 +
1515 +      subroutine check_zsymel(zsymel,zsymelr,znsymelr)
1516 +        implicit none
1517 +        integer znsymelr, isym
1518 +        character(*) zsymel(*),zsymelr(*)
1519 +        character(len=80) buf
1520 +        zsymel(3)(:lenstr(zsymel(3))+1)='X'
1521 +        write (buf,20) (trim(zsymelr(isym)),isym=1,znsymelr)
1522 +20      format(3(a,:,','))
1523 +        if (trim(buf) /= 'X,Y') call abort
1524 +      end subroutine check_zsymel
1525 +
1526 +      function lenstr(s)
1527 +        character(len=*),intent(in) :: s
1528 +        integer :: lenstr
1529 +        if (len_trim(s) /= 0) call abort
1530 +        lenstr = len_trim(s)
1531 +      end function lenstr
1532 +
1533 +      end subroutine test_upper
1534 +
1535 +      program test
1536 +        call test_lower
1537 +        call test_upper
1538 +      end program test
1539 Index: gcc/testsuite/gfortran.dg/fmt_t_3.f90
1540 ===================================================================
1541 --- gcc/testsuite/gfortran.dg/fmt_t_3.f90       (.../tags/gcc_4_2_0_release)    (revision 0)
1542 +++ gcc/testsuite/gfortran.dg/fmt_t_3.f90       (.../branches/gcc-4_2-branch)   (revision 125292)
1543 @@ -0,0 +1,15 @@
1544 +! { dg-do run }
1545 +! PR31051 bug with x and t format descriptors.
1546 +! Test case prepared by Jerry DeLisle  <jvdelisle@gcc.gnu.org> from PR.
1547 +program t
1548 +   integer, parameter :: n = 9
1549 +   character(len=40) :: fmt
1550 +   character(len=2), dimension(n) :: y
1551 +   open(unit=10, status="scratch")
1552 +   y = 'a '
1553 +   fmt = '(a,1x,(t7, 3a))'
1554 +   write(10, fmt) 'xxxx', (y(i), i = 1,n)
1555 +   rewind(10)
1556 +   read(10, '(a)') fmt
1557 +   if (fmt.ne."xxxx  a a a") call abort()
1558 +end program t
1559 Index: gcc/testsuite/gfortran.dg/backspace_8.f
1560 ===================================================================
1561 --- gcc/testsuite/gfortran.dg/backspace_8.f     (.../tags/gcc_4_2_0_release)    (revision 0)
1562 +++ gcc/testsuite/gfortran.dg/backspace_8.f     (.../branches/gcc-4_2-branch)   (revision 125292)
1563 @@ -0,0 +1,18 @@
1564 +C { dg-do run }
1565 +C PR libfortran/31618 - backspace after an error didn't work.
1566 +      program main
1567 +      character*78 msg
1568 +      open (21, file="backspace_7.dat", form="unformatted")
1569 +      write (21) 42, 43
1570 +      write (21) 4711, 4712
1571 +      write (21) -1, -4
1572 +      rewind (21)
1573 +      read (21) i,j
1574 +      read (21,err=100,end=100) i,j,k
1575 +      call abort
1576 + 100  continue
1577 +      backspace 21
1578 +      read (21) i,j
1579 +      if (i .ne. 4711 .or. j .ne. 4712) call abort
1580 +      close (21,status="delete")
1581 +      end
1582 Index: gcc/testsuite/gfortran.dg/func_assign.f90
1583 ===================================================================
1584 --- gcc/testsuite/gfortran.dg/func_assign.f90   (.../tags/gcc_4_2_0_release)    (revision 0)
1585 +++ gcc/testsuite/gfortran.dg/func_assign.f90   (.../branches/gcc-4_2-branch)   (revision 125292)
1586 @@ -0,0 +1,33 @@
1587 +! { dg-do compile }
1588 +!
1589 +! PR fortran/31559
1590 +! Do not allow assigning to external functions
1591 +!
1592 +! Contributed by Steve Kargl <sgk@troutmask.apl.washington.edu>
1593 +!
1594 +module mod
1595 +  implicit none
1596 +contains
1597 +  integer function bar()
1598 +    bar = 4
1599 +  end function bar
1600 +
1601 +  subroutine a() 
1602 +   implicit none
1603 +   real :: fun
1604 +   external fun
1605 +   interface
1606 +     function funget(a)
1607 +       integer :: a
1608 +     end function
1609 +     subroutine sub()
1610 +     end subroutine sub
1611 +   end interface
1612 +   sub = 'a'  ! { dg-error "Expected VARIABLE" }
1613 +   fun = 4.4  ! { dg-error "Expected VARIABLE" }
1614 +   funget = 4 ! { dg-error "is not a VALUE" }
1615 +   bar = 5    ! { dg-error "is not a VALUE" }
1616 +  end subroutine a
1617 +end module mod
1618 +
1619 +end
1620 Index: gcc/testsuite/gfortran.dg/unf_io_convert_3.f90
1621 ===================================================================
1622 --- gcc/testsuite/gfortran.dg/unf_io_convert_3.f90      (.../tags/gcc_4_2_0_release)    (revision 125292)
1623 +++ gcc/testsuite/gfortran.dg/unf_io_convert_3.f90      (.../branches/gcc-4_2-branch)   (revision 125292)
1624 @@ -1,4 +1,4 @@
1625 -! { dg-do run}
1626 +! { dg-do run }
1627  ! { dg-require-effective-target fortran_large_real }
1628  program main
1629    integer,parameter :: k = selected_real_kind (precision (0.0_8) + 1)
1630 Index: gcc/fortran/trans-expr.c
1631 ===================================================================
1632 --- gcc/fortran/trans-expr.c    (.../tags/gcc_4_2_0_release)    (revision 125292)
1633 +++ gcc/fortran/trans-expr.c    (.../branches/gcc-4_2-branch)   (revision 125292)
1634 @@ -255,6 +255,10 @@
1635      gfc_conv_string_parameter (se);
1636    else
1637      {
1638 +      /* Avoid multiple evaluation of substring start.  */
1639 +      if (!CONSTANT_CLASS_P (start.expr) && !DECL_P (start.expr))
1640 +       start.expr = gfc_evaluate_now (start.expr, &se->pre);
1641 +
1642        /* Change the start of the string.  */
1643        if (TYPE_STRING_FLAG (TREE_TYPE (se->expr)))
1644         tmp = se->expr;
1645 @@ -273,6 +277,10 @@
1646        gfc_conv_expr_type (&end, ref->u.ss.end, gfc_charlen_type_node);
1647        gfc_add_block_to_block (&se->pre, &end.pre);
1648      }
1649 +
1650 +  if (!CONSTANT_CLASS_P (end.expr) && !DECL_P (end.expr))
1651 +    end.expr = gfc_evaluate_now (end.expr, &se->pre);
1652 +
1653    tmp = fold_build2 (MINUS_EXPR, gfc_charlen_type_node,
1654                      build_int_cst (gfc_charlen_type_node, 1),
1655                      start.expr);
1656 @@ -2340,17 +2348,23 @@
1657  
1658    /* Generate the actual call.  */
1659    gfc_conv_function_val (se, sym);
1660 +
1661    /* If there are alternate return labels, function type should be
1662       integer.  Can't modify the type in place though, since it can be shared
1663 -     with other functions.  */
1664 +     with other functions.  For dummy arguments, the typing is done to
1665 +     to this result, even if it has to be repeated for each call.  */
1666    if (has_alternate_specifier
1667        && TREE_TYPE (TREE_TYPE (TREE_TYPE (se->expr))) != integer_type_node)
1668      {
1669 -      gcc_assert (! sym->attr.dummy);
1670 -      TREE_TYPE (sym->backend_decl)
1671 -        = build_function_type (integer_type_node,
1672 -                               TYPE_ARG_TYPES (TREE_TYPE (sym->backend_decl)));
1673 -      se->expr = build_fold_addr_expr (sym->backend_decl);
1674 +      if (!sym->attr.dummy)
1675 +       {
1676 +         TREE_TYPE (sym->backend_decl)
1677 +               = build_function_type (integer_type_node,
1678 +                     TYPE_ARG_TYPES (TREE_TYPE (sym->backend_decl)));
1679 +         se->expr = build_fold_addr_expr (sym->backend_decl);
1680 +       }
1681 +      else
1682 +       TREE_TYPE (TREE_TYPE (TREE_TYPE (se->expr))) = integer_type_node;
1683      }
1684  
1685    fntype = TREE_TYPE (TREE_TYPE (se->expr));
1686 Index: gcc/fortran/trans-array.c
1687 ===================================================================
1688 --- gcc/fortran/trans-array.c   (.../tags/gcc_4_2_0_release)    (revision 125292)
1689 +++ gcc/fortran/trans-array.c   (.../branches/gcc-4_2-branch)   (revision 125292)
1690 @@ -4422,6 +4422,8 @@
1691  
1692        if (se->direct_byref)
1693         base = gfc_index_zero_node;
1694 +      else if (GFC_ARRAY_TYPE_P (TREE_TYPE (desc)))
1695 +       base = gfc_evaluate_now (gfc_conv_array_offset (desc), &loop.pre);
1696        else
1697         base = NULL_TREE;
1698  
1699 @@ -4489,8 +4491,20 @@
1700                                 stride, info->stride[dim]);
1701  
1702           if (se->direct_byref)
1703 -           base = fold_build2 (MINUS_EXPR, TREE_TYPE (base),
1704 -                               base, stride);
1705 +           {
1706 +             base = fold_build2 (MINUS_EXPR, TREE_TYPE (base),
1707 +                                 base, stride);
1708 +           }
1709 +         else if (GFC_ARRAY_TYPE_P (TREE_TYPE (desc)))
1710 +           {
1711 +             tmp = gfc_conv_array_lbound (desc, n);
1712 +             tmp = fold_build2 (MINUS_EXPR, TREE_TYPE (base),
1713 +                                tmp, loop.from[dim]);
1714 +             tmp = fold_build2 (MULT_EXPR, TREE_TYPE (base),
1715 +                                tmp, gfc_conv_array_stride (desc, n));
1716 +             base = fold_build2 (PLUS_EXPR, TREE_TYPE (base),
1717 +                                 tmp, base);
1718 +           }
1719  
1720           /* Store the new stride.  */
1721           tmp = gfc_conv_descriptor_stride (parm, gfc_rank_cst[dim]);
1722 @@ -4511,7 +4525,8 @@
1723           gfc_conv_descriptor_data_set (&loop.pre, parm, offset);
1724         }
1725  
1726 -      if (se->direct_byref && !se->data_not_needed)
1727 +      if ((se->direct_byref || GFC_ARRAY_TYPE_P (TREE_TYPE (desc)))
1728 +            && !se->data_not_needed)
1729         {
1730           /* Set the offset.  */
1731           tmp = gfc_conv_descriptor_offset (parm);
1732 Index: gcc/fortran/gfortran.texi
1733 ===================================================================
1734 --- gcc/fortran/gfortran.texi   (.../tags/gcc_4_2_0_release)    (revision 125292)
1735 +++ gcc/fortran/gfortran.texi   (.../branches/gcc-4_2-branch)   (revision 125292)
1736 @@ -611,7 +611,7 @@
1737  to change the representation of data for unformatted files.
1738  The syntax for the @env{GFORTRAN_CONVERT_UNIT} variable is:
1739  @smallexample
1740 -GFORTRAN_CONVERT_UNIT: mode | mode ';' exception ;
1741 +GFORTRAN_CONVERT_UNIT: mode | mode ';' exception | exception ;
1742  mode: 'native' | 'swap' | 'big_endian' | 'little_endian' ;
1743  exception: mode ':' unit_list | unit_list ;
1744  unit_list: unit_spec | unit_list unit_spec ;
1745 @@ -668,7 +668,12 @@
1746  setting a default data representation for the whole program.  The
1747  @code{CONVERT} specifier overrides the @option{-fconvert} compile options.
1748  
1749 +@emph{Note that the values specified via the GFORTRAN_CONVERT_UNIT
1750 +environment variable will override the CONVERT specifier in the
1751 +open statement}.  This is to give control over data formats to
1752 +users who do not have the source code of their program available.
1753  
1754 +
1755  @c =====================================================================
1756  @c PART II: LANGUAGE REFERENCE
1757  @c =====================================================================
1758 Index: gcc/fortran/ChangeLog
1759 ===================================================================
1760 --- gcc/fortran/ChangeLog       (.../tags/gcc_4_2_0_release)    (revision 125292)
1761 +++ gcc/fortran/ChangeLog       (.../branches/gcc-4_2-branch)   (revision 125292)
1762 @@ -1,3 +1,30 @@
1763 +2007-05-31  Paul Thomas  <pault@gcc.gnu.org>
1764 +
1765 +       PR fortran/31483
1766 +       * trans-expr.c (gfc_conv_function_call): Give a dummy
1767 +       procedure the correct type if it has alternate returns.
1768 +       
1769 +
1770 +       PR fortran/31540
1771 +       * resolve.c (resolve_fl_procedure): Resolve constant character
1772 +       lengths.
1773 +
1774 +       PR fortran/31867
1775 +       PR fortran/31994
1776 +       * trans-array.c (gfc_conv_expr_descriptor): Obtain the stored
1777 +       offset for non-descriptor, source arrays and correct for stride
1778 +       not equal to one before writing to field of output descriptor.
1779 +
1780 +2007-05-17  Tobias Burnus  <burnus@net-b.de>
1781 +
1782 +       * gfortran.texi (GFORTRAN_CONVERT_UNIT): Improve documentation.
1783 +
1784 +2007-05-16  Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>
1785 +
1786 +       PR fortran/31725
1787 +       * trans-expr.c (gfc_conv_substring): Evaluate substring bounds
1788 +       only once.
1789 +
1790  2007-05-13  Release Manager
1791  
1792         * GCC 4.2.0 released.
1793 Index: gcc/fortran/resolve.c
1794 ===================================================================
1795 --- gcc/fortran/resolve.c       (.../tags/gcc_4_2_0_release)    (revision 125292)
1796 +++ gcc/fortran/resolve.c       (.../branches/gcc-4_2-branch)   (revision 125292)
1797 @@ -5742,6 +5742,11 @@
1798    if (sym->ts.type == BT_CHARACTER)
1799      {
1800        gfc_charlen *cl = sym->ts.cl;
1801 +
1802 +      if (cl && cl->length && gfc_is_constant_expr (cl->length)
1803 +            && resolve_charlen (cl) == FAILURE)
1804 +       return FAILURE;
1805 +
1806        if (!cl || !cl->length || cl->length->expr_type != EXPR_CONSTANT)
1807         {
1808           if (sym->attr.proc == PROC_ST_FUNCTION)
1809 Index: gcc/fortran/primary.c
1810 ===================================================================
1811 --- gcc/fortran/primary.c       (.../tags/gcc_4_2_0_release)    (revision 125292)
1812 +++ gcc/fortran/primary.c       (.../branches/gcc-4_2-branch)   (revision 125292)
1813 @@ -2415,7 +2415,8 @@
1814  
1815      case FL_PROCEDURE:
1816        /* Check for a nonrecursive function result */
1817 -      if (sym->attr.function && (sym->result == sym || sym->attr.entry))
1818 +      if (sym->attr.function && (sym->result == sym || sym->attr.entry)
1819 +         && !sym->attr.external)
1820         {
1821           /* If a function result is a derived type, then the derived
1822              type may still have to be resolved.  */
1823 Index: gcc/BASE-VER
1824 ===================================================================
1825 --- gcc/BASE-VER        (.../tags/gcc_4_2_0_release)    (revision 125292)
1826 +++ gcc/BASE-VER        (.../branches/gcc-4_2-branch)   (revision 125292)
1827 @@ -1 +1 @@
1828 -4.2.0
1829 +4.2.1
1830 Index: gcc/except.c
1831 ===================================================================
1832 --- gcc/except.c        (.../tags/gcc_4_2_0_release)    (revision 125292)
1833 +++ gcc/except.c        (.../branches/gcc-4_2-branch)   (revision 125292)
1834 @@ -1005,7 +1005,11 @@
1835      for (prev_try = VEC_index (eh_region, cfun->eh->region_array, outer_region);
1836           prev_try && prev_try->type != ERT_TRY;
1837          prev_try = prev_try->outer)
1838 -      ;
1839 +      if (prev_try->type == ERT_MUST_NOT_THROW)
1840 +       {
1841 +         prev_try = NULL;
1842 +         break;
1843 +       }
1844  
1845    /* Remap all of the internal catch and cleanup linkages.  Since we 
1846       duplicate entire subtrees, all of the referenced regions will have
1847 Index: gcc/combine.c
1848 ===================================================================
1849 --- gcc/combine.c       (.../tags/gcc_4_2_0_release)    (revision 125292)
1850 +++ gcc/combine.c       (.../branches/gcc-4_2-branch)   (revision 125292)
1851 @@ -5341,14 +5341,14 @@
1852         }
1853        else if (GET_MODE (op0) == compare_mode && op1 == const0_rtx)
1854         {
1855 -         SUBST(SET_SRC (x), op0);
1856 +         SUBST (SET_SRC (x), op0);
1857           src = SET_SRC (x);
1858         }
1859 -      else
1860 +      /* Otherwise, update the COMPARE if needed.  */
1861 +      else if (XEXP (src, 0) != op0 || XEXP (src, 1) != op1)
1862         {
1863 -         /* Otherwise, update the COMPARE if needed.  */
1864 -         SUBST (XEXP (src, 0), op0);
1865 -         SUBST (XEXP (src, 1), op1);
1866 +         SUBST (SET_SRC (x), gen_rtx_COMPARE (compare_mode, op0, op1));
1867 +         src = SET_SRC (x);
1868         }
1869      }
1870    else
1871 Index: gcc/Makefile.in
1872 ===================================================================
1873 --- gcc/Makefile.in     (.../tags/gcc_4_2_0_release)    (revision 125292)
1874 +++ gcc/Makefile.in     (.../branches/gcc-4_2-branch)   (revision 125292)
1875 @@ -1839,7 +1839,7 @@
1876  tree-ssa-structalias.o: tree-ssa-structalias.c tree-ssa-structalias.h \
1877     $(SYSTEM_H) $(CONFIG_H) $(GGC_H) $(TREE_H) $(TREE_FLOW_H) \
1878     $(TM_H) coretypes.h $(CGRAPH_H) tree-pass.h $(TIMEVAR_H) \
1879 -   gt-tree-ssa-structalias.h $(PARAMS_H)
1880 +   gt-tree-ssa-structalias.h $(PARAMS_H) pointer-set.h
1881  tree-ssa.o : tree-ssa.c $(TREE_FLOW_H) $(CONFIG_H) $(SYSTEM_H) \
1882     $(RTL_H) $(TREE_H) $(TM_P_H) $(EXPR_H) output.h $(DIAGNOSTIC_H) \
1883     toplev.h $(FUNCTION_H) $(TIMEVAR_H) $(TM_H) coretypes.h \
1884 Index: gcc/tree-ssa-structalias.c
1885 ===================================================================
1886 --- gcc/tree-ssa-structalias.c  (.../tags/gcc_4_2_0_release)    (revision 125292)
1887 +++ gcc/tree-ssa-structalias.c  (.../branches/gcc-4_2-branch)   (revision 125292)
1888 @@ -51,10 +51,11 @@
1889  #include "params.h"
1890  #include "tree-ssa-structalias.h"
1891  #include "cgraph.h"
1892 +#include "pointer-set.h"
1893  
1894  /* The idea behind this analyzer is to generate set constraints from the
1895     program, then solve the resulting constraints in order to generate the
1896 -   points-to sets. 
1897 +   points-to sets.
1898  
1899     Set constraints are a way of modeling program analysis problems that
1900     involve sets.  They consist of an inclusion constraint language,
1901 @@ -70,33 +71,33 @@
1902  
1903     Also see "Ultra-fast Aliasing Analysis using CLA: A Million Lines
1904     of C Code in a Second" by ""Nevin Heintze and Olivier Tardieu" at
1905 -   http://citeseer.ist.psu.edu/heintze01ultrafast.html 
1906 +   http://citeseer.ist.psu.edu/heintze01ultrafast.html
1907  
1908 -   There are three types of constraint expressions, DEREF, ADDRESSOF, and
1909 -   SCALAR.  Each constraint expression consists of a constraint type,
1910 -   a variable, and an offset.  
1911 -   
1912 +   There are three types of real constraint expressions, DEREF,
1913 +   ADDRESSOF, and SCALAR.  Each constraint expression consists
1914 +   of a constraint type, a variable, and an offset.
1915 +
1916     SCALAR is a constraint expression type used to represent x, whether
1917     it appears on the LHS or the RHS of a statement.
1918     DEREF is a constraint expression type used to represent *x, whether
1919 -   it appears on the LHS or the RHS of a statement. 
1920 +   it appears on the LHS or the RHS of a statement.
1921     ADDRESSOF is a constraint expression used to represent &x, whether
1922     it appears on the LHS or the RHS of a statement.
1923 -   
1924 +
1925     Each pointer variable in the program is assigned an integer id, and
1926     each field of a structure variable is assigned an integer id as well.
1927 -   
1928 +
1929     Structure variables are linked to their list of fields through a "next
1930     field" in each variable that points to the next field in offset
1931 -   order.  
1932 -   Each variable for a structure field has 
1933 +   order.
1934 +   Each variable for a structure field has
1935  
1936     1. "size", that tells the size in bits of that field.
1937     2. "fullsize, that tells the size in bits of the entire structure.
1938     3. "offset", that tells the offset in bits from the beginning of the
1939     structure to this field.
1940  
1941 -   Thus, 
1942 +   Thus,
1943     struct f
1944     {
1945       int a;
1946 @@ -110,50 +111,51 @@
1947     foo.b -> id 2, size 32, offset 32, fullsize 64, next NULL
1948     bar -> id 3, size 32, offset 0, fullsize 32, next NULL
1949  
1950 -   
1951 +
1952    In order to solve the system of set constraints, the following is
1953    done:
1954  
1955    1. Each constraint variable x has a solution set associated with it,
1956    Sol(x).
1957 -  
1958 +
1959    2. Constraints are separated into direct, copy, and complex.
1960    Direct constraints are ADDRESSOF constraints that require no extra
1961    processing, such as P = &Q
1962    Copy constraints are those of the form P = Q.
1963 -  Complex constraints are all the constraints involving dereferences.
1964 -  
1965 +  Complex constraints are all the constraints involving dereferences
1966 +  and offsets (including offsetted copies).
1967 +
1968    3. All direct constraints of the form P = &Q are processed, such
1969 -  that Q is added to Sol(P) 
1970 +  that Q is added to Sol(P)
1971  
1972    4. All complex constraints for a given constraint variable are stored in a
1973 -  linked list attached to that variable's node.  
1974 +  linked list attached to that variable's node.
1975  
1976    5. A directed graph is built out of the copy constraints. Each
1977 -  constraint variable is a node in the graph, and an edge from 
1978 +  constraint variable is a node in the graph, and an edge from
1979    Q to P is added for each copy constraint of the form P = Q
1980 -  
1981 +
1982    6. The graph is then walked, and solution sets are
1983    propagated along the copy edges, such that an edge from Q to P
1984    causes Sol(P) <- Sol(P) union Sol(Q).
1985 -  
1986 +
1987    7.  As we visit each node, all complex constraints associated with
1988    that node are processed by adding appropriate copy edges to the graph, or the
1989 -  appropriate variables to the solution set.  
1990 +  appropriate variables to the solution set.
1991  
1992    8. The process of walking the graph is iterated until no solution
1993    sets change.
1994  
1995    Prior to walking the graph in steps 6 and 7, We perform static
1996 -  cycle elimination on the constraint graph, as well 
1997 +  cycle elimination on the constraint graph, as well
1998    as off-line variable substitution.
1999 -  
2000 +
2001    TODO: Adding offsets to pointer-to-structures can be handled (IE not punted
2002    on and turned into anything), but isn't.  You can just see what offset
2003    inside the pointed-to struct it's going to access.
2004 -  
2005 +
2006    TODO: Constant bounded arrays can be handled as if they were structs of the
2007 -  same number of elements. 
2008 +  same number of elements.
2009  
2010    TODO: Modeling heap and incoming pointers becomes much better if we
2011    add fields to them as we discover them, which we could do.
2012 @@ -161,20 +163,29 @@
2013    TODO: We could handle unions, but to be honest, it's probably not
2014    worth the pain or slowdown.  */
2015  
2016 -static GTY ((if_marked ("tree_map_marked_p"), param_is (struct tree_map))) 
2017 -htab_t heapvar_for_stmt;
2018 +static GTY ((if_marked ("tree_map_marked_p"), param_is (struct tree_map))) htab_t heapvar_for_stmt;
2019  
2020  /* One variable to represent all non-local accesses.  */
2021  tree nonlocal_all;
2022  
2023  static bool use_field_sensitive = true;
2024  static int in_ipa_mode = 0;
2025 +
2026 +/* Used for predecessor bitmaps. */
2027  static bitmap_obstack predbitmap_obstack;
2028 -static bitmap_obstack ptabitmap_obstack;
2029 +
2030 +/* Used for points-to sets.  */
2031 +static bitmap_obstack pta_obstack;
2032 +
2033 +/* Used for oldsolution members of variables. */
2034 +static bitmap_obstack oldpta_obstack;
2035 +
2036 +/* Used for per-solver-iteration bitmaps.  */
2037  static bitmap_obstack iteration_obstack;
2038  
2039  static unsigned int create_variable_info_for (tree, const char *);
2040 -static void build_constraint_graph (void);
2041 +typedef struct constraint_graph *constraint_graph_t;
2042 +static void unify_nodes (constraint_graph_t, unsigned int, unsigned int, bool);
2043  
2044  DEF_VEC_P(constraint_t);
2045  DEF_VEC_ALLOC_P(constraint_t,heap);
2046 @@ -186,11 +197,13 @@
2047  static struct constraint_stats
2048  {
2049    unsigned int total_vars;
2050 -  unsigned int collapsed_vars;
2051 +  unsigned int nonpointer_vars;
2052    unsigned int unified_vars_static;
2053    unsigned int unified_vars_dynamic;
2054    unsigned int iterations;
2055    unsigned int num_edges;
2056 +  unsigned int num_implicit_edges;
2057 +  unsigned int points_to_sets_created;
2058  } stats;
2059  
2060  struct variable_info
2061 @@ -205,7 +218,7 @@
2062    tree decl;
2063  
2064    /* Offset of this variable, in bits, from the base variable  */
2065 -  unsigned HOST_WIDE_INT offset;  
2066 +  unsigned HOST_WIDE_INT offset;
2067  
2068    /* Size of the variable, in bits.  */
2069    unsigned HOST_WIDE_INT size;
2070 @@ -216,34 +229,21 @@
2071    /* A link to the variable for the next field in this structure.  */
2072    struct variable_info *next;
2073  
2074 -  /* Node in the graph that represents the constraints and points-to
2075 -     solution for the variable.  */
2076 -  unsigned int node;
2077 -
2078 -  /* True if the address of this variable is taken.  Needed for
2079 -     variable substitution.  */
2080 -  unsigned int address_taken:1;
2081 -
2082 -  /* True if this variable is the target of a dereference.  Needed for
2083 -     variable substitution.  */
2084 -  unsigned int indirect_target:1;
2085 -  
2086    /* True if the variable is directly the target of a dereference.
2087       This is used to track which variables are *actually* dereferenced
2088 -     so we can prune their points to listed. This is equivalent to the
2089 -     indirect_target flag when no merging of variables happens.  */
2090 +     so we can prune their points to listed. */
2091    unsigned int directly_dereferenced:1;
2092  
2093    /* True if this is a variable created by the constraint analysis, such as
2094       heap variables and constraints we had to break up.  */
2095    unsigned int is_artificial_var:1;
2096 -  
2097 +
2098    /* True if this is a special variable whose solution set should not be
2099       changed.  */
2100    unsigned int is_special_var:1;
2101  
2102    /* True for variables whose size is not known or variable.  */
2103 -  unsigned int is_unknown_size_var:1;  
2104 +  unsigned int is_unknown_size_var:1;
2105  
2106    /* True for variables that have unions somewhere in them.  */
2107    unsigned int has_union:1;
2108 @@ -254,16 +254,15 @@
2109    /* Points-to set for this variable.  */
2110    bitmap solution;
2111  
2112 +  /* Old points-to set for this variable.  */
2113 +  bitmap oldsolution;
2114 +
2115    /* Variable ids represented by this node.  */
2116    bitmap variables;
2117  
2118 -  /* Vector of complex constraints for this node.  Complex
2119 -     constraints are those involving dereferences.  */
2120 -  VEC(constraint_t,heap) *complex;
2121 -  
2122 -  /* Variable id this was collapsed to due to type unsafety.
2123 -     This should be unused completely after build_constraint_graph, or
2124 -     something is broken.  */
2125 +  /* Variable id this was collapsed to due to type unsafety.  This
2126 +     should be unused completely after build_succ_graph, or something
2127 +     is broken.  */
2128    struct variable_info *collapsed_to;
2129  };
2130  typedef struct variable_info *varinfo_t;
2131 @@ -277,8 +276,8 @@
2132  
2133  DEF_VEC_ALLOC_P(varinfo_t, heap);
2134  
2135 -/* Table of variable info structures for constraint variables.  Indexed directly
2136 -   by variable info id.  */
2137 +/* Table of variable info structures for constraint variables.
2138 +   Indexed directly by variable info id.  */
2139  static VEC(varinfo_t,heap) *varmap;
2140  
2141  /* Return the varmap element N */
2142 @@ -286,7 +285,7 @@
2143  static inline varinfo_t
2144  get_varinfo (unsigned int n)
2145  {
2146 -  return VEC_index(varinfo_t, varmap, n);
2147 +  return VEC_index (varinfo_t, varmap, n);
2148  }
2149  
2150  /* Return the varmap element N, following the collapsed_to link.  */
2151 @@ -294,7 +293,7 @@
2152  static inline varinfo_t
2153  get_varinfo_fc (unsigned int n)
2154  {
2155 -  varinfo_t v = VEC_index(varinfo_t, varmap, n);
2156 +  varinfo_t v = VEC_index (varinfo_t, varmap, n);
2157  
2158    if (v->collapsed_to)
2159      return v->collapsed_to;
2160 @@ -331,10 +330,9 @@
2161  /* Variable that represents non-local variables before we expand it to
2162     one for each type.  */
2163  static unsigned int nonlocal_vars_id;
2164 -
2165  /* Lookup a heap var for FROM, and return it if we find one.  */
2166  
2167 -static tree 
2168 +static tree
2169  heapvar_lookup (tree from)
2170  {
2171    struct tree_map *h, in;
2172 @@ -367,25 +365,21 @@
2173     named NAME, and using constraint graph node NODE.  */
2174  
2175  static varinfo_t
2176 -new_var_info (tree t, unsigned int id, const char *name, unsigned int node)
2177 +new_var_info (tree t, unsigned int id, const char *name)
2178  {
2179    varinfo_t ret = pool_alloc (variable_info_pool);
2180  
2181    ret->id = id;
2182    ret->name = name;
2183    ret->decl = t;
2184 -  ret->node = node;
2185 -  ret->address_taken = false;
2186 -  ret->indirect_target = false;
2187    ret->directly_dereferenced = false;
2188    ret->is_artificial_var = false;
2189    ret->is_heap_var = false;
2190    ret->is_special_var = false;
2191    ret->is_unknown_size_var = false;
2192    ret->has_union = false;
2193 -  ret->solution = BITMAP_ALLOC (&ptabitmap_obstack);
2194 -  ret->variables = BITMAP_ALLOC (&ptabitmap_obstack);
2195 -  ret->complex = NULL;
2196 +  ret->solution = BITMAP_ALLOC (&pta_obstack);
2197 +  ret->oldsolution = BITMAP_ALLOC (&oldpta_obstack);
2198    ret->next = NULL;
2199    ret->collapsed_to = NULL;
2200    return ret;
2201 @@ -395,7 +389,7 @@
2202  
2203  /* An expression that appears in a constraint.  */
2204  
2205 -struct constraint_expr 
2206 +struct constraint_expr
2207  {
2208    /* Constraint type.  */
2209    constraint_expr_type type;
2210 @@ -418,7 +412,7 @@
2211  static void do_deref (VEC (ce_s, heap) **);
2212  
2213  /* Our set constraints are made up of two constraint expressions, one
2214 -   LHS, and one RHS.  
2215 +   LHS, and one RHS.
2216  
2217     As described in the introduction, our set constraints each represent an
2218     operation between set valued variables.
2219 @@ -434,63 +428,98 @@
2220  static VEC(constraint_t,heap) *constraints;
2221  static alloc_pool constraint_pool;
2222  
2223 -/* An edge in the weighted constraint graph.   The edges are weighted,
2224 -   with a bit set in weights meaning their is an edge with that
2225 -   weight. 
2226 -   We don't keep the src in the edge, because we always know what it
2227 -   is. */
2228  
2229 -struct constraint_edge
2230 +DEF_VEC_I(int);
2231 +DEF_VEC_ALLOC_I(int, heap);
2232 +
2233 +/* The constraint graph is represented as an array of bitmaps
2234 +   containing successor nodes.  */
2235 +
2236 +struct constraint_graph
2237  {
2238 -  unsigned int dest;
2239 -  bitmap weights;
2240 -};
2241 +  /* Size of this graph, which may be different than the number of
2242 +     nodes in the variable map.  */
2243 +  unsigned int size;
2244  
2245 -typedef struct constraint_edge *constraint_edge_t;
2246 -static alloc_pool constraint_edge_pool;
2247 +  /* Explicit successors of each node. */
2248 +  bitmap *succs;
2249  
2250 -/* Return a new constraint edge from SRC to DEST.  */
2251 +  /* Implicit predecessors of each node (Used for variable
2252 +     substitution). */
2253 +  bitmap *implicit_preds;
2254  
2255 -static constraint_edge_t
2256 -new_constraint_edge (unsigned int dest)
2257 -{
2258 -  constraint_edge_t ret = pool_alloc (constraint_edge_pool);
2259 -  ret->dest = dest;
2260 -  ret->weights = NULL;
2261 -  return ret;
2262 -}
2263 +  /* Explicit predecessors of each node (Used for variable substitution).  */
2264 +  bitmap *preds;
2265  
2266 -DEF_VEC_P(constraint_edge_t);
2267 -DEF_VEC_ALLOC_P(constraint_edge_t,heap);
2268 +  /* Indirect cycle representatives, or -1 if the node has no indirect
2269 +     cycles.  */
2270 +  int *indirect_cycles;
2271  
2272 +  /* Representative node for a node.  rep[a] == a unless the node has
2273 +     been unified. */
2274 +  unsigned int *rep;
2275  
2276 -/* The constraint graph is represented internally in two different
2277 -   ways.  The overwhelming majority of edges in the constraint graph
2278 -   are zero weigh edges, and thus, using a vector of contrainst_edge_t
2279 -   is a waste of time and memory, since they have no weights.  We
2280 -   simply use a bitmap to store the preds and succs for each node.
2281 -   The weighted edges are stored as a set of adjacency vectors, one
2282 -   per variable. succs[x] is the vector of successors for variable x,
2283 -   and preds[x] is the vector of predecessors for variable x.  IOW,
2284 -   all edges are "forward" edges, which is not like our CFG.  So
2285 -   remember that preds[x]->src == x, and succs[x]->src == x.  */
2286 +  /* Equivalence class representative for a node.  This is used for
2287 +     variable substitution.  */
2288 +  int *eq_rep;
2289  
2290 -struct constraint_graph
2291 -{
2292 -  bitmap *zero_weight_succs;
2293 -  bitmap *zero_weight_preds;
2294 -  VEC(constraint_edge_t,heap) **succs;
2295 -  VEC(constraint_edge_t,heap) **preds;
2296 +  /* Label for each node, used during variable substitution.  */
2297 +  unsigned int *label;
2298 +
2299 +  /* Bitmap of nodes where the bit is set if the node is a direct
2300 +     node.  Used for variable substitution.  */
2301 +  sbitmap direct_nodes;
2302 +
2303 +  /* Vector of complex constraints for each graph node.  Complex
2304 +     constraints are those involving dereferences or offsets that are
2305 +     not 0.  */
2306 +  VEC(constraint_t,heap) **complex;
2307  };
2308  
2309 -typedef struct constraint_graph *constraint_graph_t;
2310 -
2311  static constraint_graph_t graph;
2312 -static int graph_size;
2313  
2314 +/* During variable substitution and the offline version of indirect
2315 +   cycle finding, we create nodes to represent dereferences and
2316 +   address taken constraints.  These represent where these start and
2317 +   end.  */
2318 +#define FIRST_REF_NODE (VEC_length (varinfo_t, varmap))
2319 +#define LAST_REF_NODE (FIRST_REF_NODE + (FIRST_REF_NODE - 1))
2320 +#define FIRST_ADDR_NODE (LAST_REF_NODE + 1)
2321 +
2322 +/* Return the representative node for NODE, if NODE has been unioned
2323 +   with another NODE.
2324 +   This function performs path compression along the way to finding
2325 +   the representative.  */
2326 +
2327 +static unsigned int
2328 +find (unsigned int node)
2329 +{
2330 +  gcc_assert (node < graph->size);
2331 +  if (graph->rep[node] != node)
2332 +    return graph->rep[node] = find (graph->rep[node]);
2333 +  return node;
2334 +}
2335 +
2336 +/* Union the TO and FROM nodes to the TO nodes.
2337 +   Note that at some point in the future, we may want to do
2338 +   union-by-rank, in which case we are going to have to return the
2339 +   node we unified to.  */
2340 +
2341 +static bool
2342 +unite (unsigned int to, unsigned int from)
2343 +{
2344 +  gcc_assert (to < graph->size && from < graph->size);
2345 +  if (to != from && graph->rep[from] != to)
2346 +    {
2347 +      graph->rep[from] = to;
2348 +      return true;
2349 +    }
2350 +  return false;
2351 +}
2352 +
2353  /* Create a new constraint consisting of LHS and RHS expressions.  */
2354  
2355 -static constraint_t 
2356 +static constraint_t
2357  new_constraint (const struct constraint_expr lhs,
2358                 const struct constraint_expr rhs)
2359  {
2360 @@ -508,7 +537,7 @@
2361    if (c->lhs.type == ADDRESSOF)
2362      fprintf (file, "&");
2363    else if (c->lhs.type == DEREF)
2364 -    fprintf (file, "*");  
2365 +    fprintf (file, "*");
2366    fprintf (file, "%s", get_varinfo_fc (c->lhs.var)->name);
2367    if (c->lhs.offset != 0)
2368      fprintf (file, " + " HOST_WIDE_INT_PRINT_DEC, c->lhs.offset);
2369 @@ -550,23 +579,24 @@
2370    dump_constraints (stderr);
2371  }
2372  
2373 -/* SOLVER FUNCTIONS 
2374 +/* SOLVER FUNCTIONS
2375  
2376     The solver is a simple worklist solver, that works on the following
2377     algorithm:
2378 -   
2379 -   sbitmap changed_nodes = all ones;
2380 -   changed_count = number of nodes;
2381 -   For each node that was already collapsed:
2382 -       changed_count--;
2383  
2384 +   sbitmap changed_nodes = all zeroes;
2385 +   changed_count = 0;
2386 +   For each node that is not already collapsed:
2387 +       changed_count++;
2388 +       set bit in changed nodes
2389 +
2390     while (changed_count > 0)
2391     {
2392       compute topological ordering for constraint graph
2393 -  
2394 +
2395       find and collapse cycles in the constraint graph (updating
2396       changed if necessary)
2397 -     
2398 +
2399       for each node (n) in the graph in topological order:
2400         changed_count--;
2401  
2402 @@ -619,11 +649,11 @@
2403  }
2404  
2405  /* Return true if two constraints A and B are equal.  */
2406 -  
2407 +
2408  static bool
2409  constraint_equal (struct constraint a, struct constraint b)
2410  {
2411 -  return constraint_expr_equal (a.lhs, b.lhs) 
2412 +  return constraint_expr_equal (a.lhs, b.lhs)
2413      && constraint_expr_equal (a.rhs, b.rhs);
2414  }
2415  
2416 @@ -634,7 +664,7 @@
2417  constraint_vec_find (VEC(constraint_t,heap) *vec,
2418                      struct constraint lookfor)
2419  {
2420 -  unsigned int place;  
2421 +  unsigned int place;
2422    constraint_t found;
2423  
2424    if (vec == NULL)
2425 @@ -684,7 +714,7 @@
2426        /* If this is a properly sized variable, only add offset if it's
2427          less than end.  Otherwise, it is globbed to a single
2428          variable.  */
2429 -      
2430 +
2431        if ((get_varinfo (i)->offset + offset) < get_varinfo (i)->fullsize)
2432         {
2433           unsigned HOST_WIDE_INT fieldoffset = get_varinfo (i)->offset + offset;
2434 @@ -693,15 +723,15 @@
2435             continue;
2436           bitmap_set_bit (result, v->id);
2437         }
2438 -      else if (get_varinfo (i)->is_artificial_var 
2439 +      else if (get_varinfo (i)->is_artificial_var
2440                || get_varinfo (i)->has_union
2441                || get_varinfo (i)->is_unknown_size_var)
2442         {
2443           bitmap_set_bit (result, i);
2444         }
2445      }
2446 -  
2447 -  bitmap_copy (set, result);  
2448 +
2449 +  bitmap_copy (set, result);
2450    BITMAP_FREE (result);
2451  }
2452  
2453 @@ -727,397 +757,149 @@
2454      }
2455  }
2456  
2457 -/* Insert constraint C into the list of complex constraints for VAR.  */
2458 +/* Insert constraint C into the list of complex constraints for graph
2459 +   node VAR.  */
2460  
2461  static void
2462 -insert_into_complex (unsigned int var, constraint_t c)
2463 +insert_into_complex (constraint_graph_t graph,
2464 +                    unsigned int var, constraint_t c)
2465  {
2466 -  varinfo_t vi = get_varinfo (var);
2467 -  unsigned int place = VEC_lower_bound (constraint_t, vi->complex, c,
2468 +  VEC (constraint_t, heap) *complex = graph->complex[var];
2469 +  unsigned int place = VEC_lower_bound (constraint_t, complex, c,
2470                                         constraint_less);
2471 -  VEC_safe_insert (constraint_t, heap, vi->complex, place, c);
2472 -}
2473  
2474 -
2475 -/* Compare two constraint edges A and B, return true if they are equal.  */
2476 -
2477 -static bool
2478 -constraint_edge_equal (struct constraint_edge a, struct constraint_edge b)
2479 -{
2480 -  return a.dest == b.dest;
2481 +  /* Only insert constraints that do not already exist.  */
2482 +  if (place >= VEC_length (constraint_t, complex)
2483 +      || !constraint_equal (*c, *VEC_index (constraint_t, complex, place)))
2484 +    VEC_safe_insert (constraint_t, heap, graph->complex[var], place, c);
2485  }
2486  
2487 -/* Compare two constraint edges, return true if A is less than B */
2488  
2489 -static bool
2490 -constraint_edge_less (const constraint_edge_t a, const constraint_edge_t b)
2491 -{
2492 -  if (a->dest < b->dest)
2493 -    return true;
2494 -  return false;
2495 -}
2496 -
2497 -/* Find the constraint edge that matches LOOKFOR, in VEC.
2498 -   Return the edge, if found, NULL otherwise.  */
2499 -
2500 -static constraint_edge_t 
2501 -constraint_edge_vec_find (VEC(constraint_edge_t,heap) *vec, 
2502 -                         struct constraint_edge lookfor)
2503 -{
2504 -  unsigned int place;  
2505 -  constraint_edge_t edge = NULL;
2506 -
2507 -  place = VEC_lower_bound (constraint_edge_t, vec, &lookfor, 
2508 -                          constraint_edge_less);
2509 -  if (place >= VEC_length (constraint_edge_t, vec))
2510 -    return NULL;
2511 -  edge = VEC_index (constraint_edge_t, vec, place);
2512 -  if (!constraint_edge_equal (*edge, lookfor))
2513 -    return NULL;
2514 -  return edge;
2515 -}
2516 -
2517  /* Condense two variable nodes into a single variable node, by moving
2518     all associated info from SRC to TO.  */
2519  
2520 -static void 
2521 -condense_varmap_nodes (unsigned int to, unsigned int src)
2522 +static void
2523 +merge_node_constraints (constraint_graph_t graph, unsigned int to,
2524 +                       unsigned int from)
2525  {
2526 -  varinfo_t tovi = get_varinfo (to);
2527 -  varinfo_t srcvi = get_varinfo (src);
2528    unsigned int i;
2529    constraint_t c;
2530 -  bitmap_iterator bi;
2531 -  
2532 -  /* the src node, and all its variables, are now the to node.  */
2533 -  srcvi->node = to;
2534 -  EXECUTE_IF_SET_IN_BITMAP (srcvi->variables, 0, i, bi)
2535 -    get_varinfo (i)->node = to;
2536 -  
2537 -  /* Merge the src node variables and the to node variables.  */
2538 -  bitmap_set_bit (tovi->variables, src);
2539 -  bitmap_ior_into (tovi->variables, srcvi->variables);
2540 -  bitmap_clear (srcvi->variables);
2541 -  
2542 +
2543 +  gcc_assert (find (from) == to);
2544 +
2545    /* Move all complex constraints from src node into to node  */
2546 -  for (i = 0; VEC_iterate (constraint_t, srcvi->complex, i, c); i++)
2547 +  for (i = 0; VEC_iterate (constraint_t, graph->complex[from], i, c); i++)
2548      {
2549        /* In complex constraints for node src, we may have either
2550 -        a = *src, and *src = a.  */
2551 -      
2552 +        a = *src, and *src = a, or an offseted constraint which are
2553 +        always added to the rhs node's constraints.  */
2554 +
2555        if (c->rhs.type == DEREF)
2556         c->rhs.var = to;
2557 +      else if (c->lhs.type == DEREF)
2558 +       c->lhs.var = to;
2559        else
2560 -       c->lhs.var = to;
2561 +       c->rhs.var = to;
2562      }
2563 -  constraint_set_union (&tovi->complex, &srcvi->complex);
2564 -  VEC_free (constraint_t, heap, srcvi->complex);
2565 -  srcvi->complex = NULL;
2566 +  constraint_set_union (&graph->complex[to], &graph->complex[from]);
2567 +  VEC_free (constraint_t, heap, graph->complex[from]);
2568 +  graph->complex[from] = NULL;
2569  }
2570  
2571 -/* Erase an edge from SRC to SRC from GRAPH.  This routine only
2572 -   handles self-edges (e.g. an edge from a to a).  */
2573  
2574 -static void
2575 -erase_graph_self_edge (constraint_graph_t graph, unsigned int src)
2576 -{
2577 -  VEC(constraint_edge_t,heap) *predvec = graph->preds[src];
2578 -  VEC(constraint_edge_t,heap) *succvec = graph->succs[src];
2579 -  struct constraint_edge edge;
2580 -  unsigned int place;
2581 -
2582 -  edge.dest = src;
2583 -
2584 -  /* Remove from the successors.  */
2585 -  place = VEC_lower_bound (constraint_edge_t, succvec, &edge, 
2586 -                          constraint_edge_less);
2587 -  
2588 -  /* Make sure we found the edge.  */
2589 -#ifdef ENABLE_CHECKING
2590 -  {
2591 -    constraint_edge_t tmp = VEC_index (constraint_edge_t, succvec, place);
2592 -    gcc_assert (constraint_edge_equal (*tmp, edge));
2593 -  }
2594 -#endif
2595 -  VEC_ordered_remove (constraint_edge_t, succvec, place);
2596 -
2597 -  /* Remove from the predecessors.  */
2598 -  place = VEC_lower_bound (constraint_edge_t, predvec, &edge,
2599 -                          constraint_edge_less);
2600 -
2601 -  /* Make sure we found the edge.  */
2602 -#ifdef ENABLE_CHECKING
2603 -  {
2604 -    constraint_edge_t tmp = VEC_index (constraint_edge_t, predvec, place);
2605 -    gcc_assert (constraint_edge_equal (*tmp, edge));
2606 -  }
2607 -#endif
2608 -  VEC_ordered_remove (constraint_edge_t, predvec, place);
2609 -}
2610 -
2611  /* Remove edges involving NODE from GRAPH.  */
2612  
2613  static void
2614  clear_edges_for_node (constraint_graph_t graph, unsigned int node)
2615  {
2616 -  VEC(constraint_edge_t,heap) *succvec = graph->succs[node];
2617 -  VEC(constraint_edge_t,heap) *predvec = graph->preds[node];
2618 -  bitmap_iterator bi;
2619 -  unsigned int j;
2620 -  constraint_edge_t c = NULL;
2621 -  int i;
2622 -
2623 -  /* Walk the successors, erase the associated preds.  */
2624 -  
2625 -  EXECUTE_IF_IN_NONNULL_BITMAP (graph->zero_weight_succs[node], 0, j, bi)
2626 -    if (j != node)
2627 -      bitmap_clear_bit (graph->zero_weight_preds[j], node);
2628 -  
2629 -  for (i = 0; VEC_iterate (constraint_edge_t, succvec, i, c); i++)
2630 -    if (c->dest != node)
2631 -      {
2632 -       unsigned int place;
2633 -       struct constraint_edge lookfor;
2634 -       constraint_edge_t result;
2635 -
2636 -       lookfor.dest = node;
2637 -       place = VEC_lower_bound (constraint_edge_t, graph->preds[c->dest], 
2638 -                                &lookfor, constraint_edge_less);
2639 -       result = VEC_ordered_remove (constraint_edge_t, 
2640 -                                    graph->preds[c->dest], place);
2641 -       pool_free (constraint_edge_pool, result);
2642 -      }
2643 -
2644 -  /* Walk the preds, erase the associated succs.  */
2645 -
2646 -  EXECUTE_IF_IN_NONNULL_BITMAP (graph->zero_weight_preds[node], 0, j, bi)
2647 -    if (j != node)
2648 -      bitmap_clear_bit (graph->zero_weight_succs[j], node);
2649 -  
2650 -  for (i =0; VEC_iterate (constraint_edge_t, predvec, i, c); i++)
2651 -    if (c->dest != node)
2652 -      {
2653 -       unsigned int place;
2654 -       struct constraint_edge lookfor;
2655 -       constraint_edge_t result;
2656 -
2657 -       lookfor.dest = node;
2658 -       place = VEC_lower_bound (constraint_edge_t, graph->succs[c->dest],
2659 -                                &lookfor, constraint_edge_less);
2660 -       result = VEC_ordered_remove (constraint_edge_t, 
2661 -                                    graph->succs[c->dest], place);
2662 -       pool_free (constraint_edge_pool, result);
2663 -
2664 -      }    
2665 -
2666 -  if (graph->zero_weight_preds[node])
2667 -    {
2668 -      BITMAP_FREE (graph->zero_weight_preds[node]);
2669 -      graph->zero_weight_preds[node] = NULL;
2670 -    } 
2671 -
2672 -  if (graph->zero_weight_succs[node])
2673 -    {
2674 -      BITMAP_FREE (graph->zero_weight_succs[node]);
2675 -      graph->zero_weight_succs[node] = NULL;
2676 -    } 
2677 -
2678 -  VEC_free (constraint_edge_t, heap, graph->preds[node]);
2679 -  VEC_free (constraint_edge_t, heap, graph->succs[node]);
2680 -  graph->preds[node] = NULL;
2681 -  graph->succs[node] = NULL;
2682 +  if (graph->succs[node])
2683 +    BITMAP_FREE (graph->succs[node]);
2684  }
2685  
2686 -static bool edge_added = false;
2687 -  
2688 -/* Add edge (src, dest) to the graph.  */
2689 -
2690 -static bool
2691 -add_graph_edge (constraint_graph_t graph, unsigned int src, unsigned int dest)
2692 -{
2693 -  unsigned int place;
2694 -  VEC(constraint_edge_t,heap) *vec;
2695 -  struct constraint_edge newe;
2696 -  newe.dest = dest;
2697 -
2698 -  vec = graph->preds[src];
2699 -  place = VEC_lower_bound (constraint_edge_t, vec, &newe, 
2700 -                          constraint_edge_less);
2701 -  if (place == VEC_length (constraint_edge_t, vec)
2702 -      || VEC_index (constraint_edge_t, vec, place)->dest != dest)
2703 -    {
2704 -      constraint_edge_t edge = new_constraint_edge (dest);
2705 -
2706 -      VEC_safe_insert (constraint_edge_t, heap, graph->preds[src], 
2707 -                      place, edge);
2708 -      edge = new_constraint_edge (src);
2709 -
2710 -      place = VEC_lower_bound (constraint_edge_t, graph->succs[dest],
2711 -                              edge, constraint_edge_less);
2712 -      VEC_safe_insert (constraint_edge_t, heap, graph->succs[dest], 
2713 -                      place, edge);
2714 -      edge_added = true;
2715 -      stats.num_edges++;
2716 -      return true;
2717 -    }
2718 -  else
2719 -    return false;
2720 -}
2721 -
2722 -
2723 -/* Return the bitmap representing the weights of edge (SRC, DEST).  */
2724 -
2725 -static bitmap *
2726 -get_graph_weights (constraint_graph_t graph, unsigned int src,
2727 -                  unsigned int dest)
2728 -{
2729 -  constraint_edge_t edge;
2730 -  VEC(constraint_edge_t,heap) *vec;
2731 -  struct constraint_edge lookfor;
2732 -
2733 -  lookfor.dest = dest;
2734 -
2735 -  vec = graph->preds[src];
2736 -  edge = constraint_edge_vec_find (vec, lookfor);
2737 -  gcc_assert (edge != NULL);
2738 -  return &edge->weights;
2739 -}
2740 -
2741 -/* Allocate graph weight bitmap for the edges associated with SRC and
2742 -   DEST in GRAPH.  Both the pred and the succ edges share a single
2743 -   bitmap, so we need to set both edges to that bitmap.  */
2744 -
2745 -static bitmap
2746 -allocate_graph_weights (constraint_graph_t graph, unsigned int src, 
2747 -                       unsigned int dest)
2748 -{
2749 -  bitmap result;
2750 -  constraint_edge_t edge;
2751 -  VEC(constraint_edge_t,heap) *vec;
2752 -  struct constraint_edge lookfor;
2753 -  
2754 -  result = BITMAP_ALLOC (&ptabitmap_obstack);
2755 -
2756 -  /* Set the pred weight.  */
2757 -  lookfor.dest = dest;
2758 -  vec = graph->preds[src];
2759 -  edge = constraint_edge_vec_find (vec, lookfor);
2760 -  gcc_assert (edge != NULL);
2761 -  edge->weights = result;
2762 -
2763 -  /* Set the succ weight.  */  
2764 -  lookfor.dest = src;
2765 -  vec = graph->succs[dest];
2766 -  edge = constraint_edge_vec_find (vec, lookfor);
2767 -  gcc_assert (edge != NULL);
2768 -  edge->weights = result;
2769 -  
2770 -  return result;  
2771 -}
2772 -
2773 -
2774  /* Merge GRAPH nodes FROM and TO into node TO.  */
2775  
2776  static void
2777 -merge_graph_nodes (constraint_graph_t graph, unsigned int to, 
2778 +merge_graph_nodes (constraint_graph_t graph, unsigned int to,
2779                    unsigned int from)
2780  {
2781 -  VEC(constraint_edge_t,heap) *succvec = graph->succs[from];
2782 -  VEC(constraint_edge_t,heap) *predvec = graph->preds[from];
2783 -  int i;
2784 -  constraint_edge_t c;
2785 -  unsigned int j;
2786 -  bitmap_iterator bi;
2787 -
2788 -  /* Merge all the zero weighted predecessor edges.  */
2789 -  if (graph->zero_weight_preds[from])
2790 +  if (graph->indirect_cycles[from] != -1)
2791      {
2792 -      if (!graph->zero_weight_preds[to])
2793 -       graph->zero_weight_preds[to] = BITMAP_ALLOC (&predbitmap_obstack);
2794 -      
2795 -      EXECUTE_IF_SET_IN_BITMAP (graph->zero_weight_preds[from], 0, j, bi)
2796 +      /* If we have indirect cycles with the from node, and we have
2797 +        none on the to node, the to node has indirect cycles from the
2798 +        from node now that they are unified.
2799 +        If indirect cycles exist on both, unify the nodes that they
2800 +        are in a cycle with, since we know they are in a cycle with
2801 +        each other.  */
2802 +      if (graph->indirect_cycles[to] == -1)
2803         {
2804 -         if (j != to)
2805 -           {
2806 -             bitmap_clear_bit (graph->zero_weight_succs[j], from);
2807 -             bitmap_set_bit (graph->zero_weight_succs[j], to);
2808 -           }
2809 +         graph->indirect_cycles[to] = graph->indirect_cycles[from];
2810         }
2811 -      bitmap_ior_into (graph->zero_weight_preds[to], 
2812 -                      graph->zero_weight_preds[from]);
2813 -    }
2814 +      else
2815 +       {
2816 +         unsigned int tonode = find (graph->indirect_cycles[to]);
2817 +         unsigned int fromnode = find (graph->indirect_cycles[from]);
2818  
2819 -  /* Merge all the zero weighted successor edges.  */
2820 -  if (graph->zero_weight_succs[from])
2821 -    {
2822 -      if (!graph->zero_weight_succs[to])
2823 -       graph->zero_weight_succs[to] = BITMAP_ALLOC (&ptabitmap_obstack);
2824 -      EXECUTE_IF_SET_IN_BITMAP (graph->zero_weight_succs[from], 0, j, bi)
2825 -       {
2826 -         bitmap_clear_bit (graph->zero_weight_preds[j], from);
2827 -         bitmap_set_bit (graph->zero_weight_preds[j], to);
2828 +         if (unite (tonode, fromnode))
2829 +           unify_nodes (graph, tonode, fromnode, true);
2830         }
2831 -      bitmap_ior_into (graph->zero_weight_succs[to], 
2832 -                      graph->zero_weight_succs[from]);
2833      }
2834  
2835 -  /* Merge all the nonzero weighted predecessor edges.  */
2836 -  for (i = 0; VEC_iterate (constraint_edge_t, predvec, i, c); i++)
2837 +  /* Merge all the successor edges.  */
2838 +  if (graph->succs[from])
2839      {
2840 -      unsigned int d = c->dest;
2841 -      bitmap temp;
2842 -      bitmap *weights;
2843 +      if (!graph->succs[to])
2844 +       graph->succs[to] = BITMAP_ALLOC (&pta_obstack);
2845 +      bitmap_ior_into (graph->succs[to],
2846 +                      graph->succs[from]);
2847 +    }
2848  
2849 -      if (c->dest == from)
2850 -       d = to;
2851 +  clear_edges_for_node (graph, from);
2852 +}
2853  
2854 -      add_graph_edge (graph, to, d);
2855  
2856 -      temp = *(get_graph_weights (graph, from, c->dest));      
2857 -      if (temp)
2858 -       {
2859 -         weights = get_graph_weights (graph, to, d);
2860 -         if (!*weights)
2861 -           *weights = allocate_graph_weights (graph, to, d);
2862 -         
2863 -         bitmap_ior_into (*weights, temp);
2864 -       }
2865 -      
2866 -    }
2867 -  
2868 -  /* Merge all the nonzero weighted successor edges.  */
2869 -  for (i = 0; VEC_iterate (constraint_edge_t, succvec, i, c); i++)
2870 -    {
2871 -      unsigned int d = c->dest;
2872 -      bitmap temp;
2873 -      bitmap *weights;
2874 +/* Add an indirect graph edge to GRAPH, going from TO to FROM if
2875 +   it doesn't exist in the graph already.  */
2876  
2877 -      if (c->dest == from)
2878 -       d = to;
2879 +static void
2880 +add_implicit_graph_edge (constraint_graph_t graph, unsigned int to,
2881 +                        unsigned int from)
2882 +{
2883 +  if (to == from)
2884 +    return;
2885  
2886 -      add_graph_edge (graph, d, to);
2887 +  if (!graph->implicit_preds[to])
2888 +    graph->implicit_preds[to] = BITMAP_ALLOC (&predbitmap_obstack);
2889  
2890 -      temp = *(get_graph_weights (graph, c->dest, from));
2891 -      if (temp)
2892 -       {
2893 -         weights = get_graph_weights (graph, d, to);
2894 -         if (!*weights)
2895 -           *weights = allocate_graph_weights (graph, d, to);
2896 -         bitmap_ior_into (*weights, temp);
2897 -       }
2898 +  if (!bitmap_bit_p (graph->implicit_preds[to], from))
2899 +    {
2900 +      stats.num_implicit_edges++;
2901 +      bitmap_set_bit (graph->implicit_preds[to], from);
2902      }
2903 -  clear_edges_for_node (graph, from);
2904  }
2905  
2906 -/* Add a graph edge to GRAPH, going from TO to FROM, with WEIGHT, if
2907 +/* Add a predecessor graph edge to GRAPH, going from TO to FROM if
2908     it doesn't exist in the graph already.
2909     Return false if the edge already existed, true otherwise.  */
2910  
2911 +static void
2912 +add_pred_graph_edge (constraint_graph_t graph, unsigned int to,
2913 +                    unsigned int from)
2914 +{
2915 +  if (!graph->preds[to])
2916 +    graph->preds[to] = BITMAP_ALLOC (&predbitmap_obstack);
2917 +  if (!bitmap_bit_p (graph->preds[to], from))
2918 +    bitmap_set_bit (graph->preds[to], from);
2919 +}
2920 +
2921 +/* Add a graph edge to GRAPH, going from FROM to TO if
2922 +   it doesn't exist in the graph already.
2923 +   Return false if the edge already existed, true otherwise.  */
2924 +
2925  static bool
2926 -int_add_graph_edge (constraint_graph_t graph, unsigned int to, 
2927 -                   unsigned int from, unsigned HOST_WIDE_INT weight)
2928 +add_graph_edge (constraint_graph_t graph, unsigned int to,
2929 +               unsigned int from)
2930  {
2931 -  if (to == from && weight == 0)
2932 +  if (to == from)
2933      {
2934        return false;
2935      }
2936 @@ -1125,41 +907,15 @@
2937      {
2938        bool r = false;
2939  
2940 -      if (weight == 0)
2941 +      if (!graph->succs[from])
2942 +       graph->succs[from] = BITMAP_ALLOC (&pta_obstack);
2943 +      if (!bitmap_bit_p (graph->succs[from], to))
2944         {
2945 -          if (!graph->zero_weight_preds[to])
2946 -           graph->zero_weight_preds[to] = BITMAP_ALLOC (&predbitmap_obstack);
2947 -          if (!graph->zero_weight_succs[from])
2948 -           graph->zero_weight_succs[from] = BITMAP_ALLOC (&ptabitmap_obstack);
2949 -         if (!bitmap_bit_p (graph->zero_weight_succs[from], to))
2950 -           {
2951 -             edge_added = true;
2952 -             r = true;
2953 -             stats.num_edges++;
2954 -             bitmap_set_bit (graph->zero_weight_preds[to], from);
2955 -             bitmap_set_bit (graph->zero_weight_succs[from], to);
2956 -           }
2957 +         r = true;
2958 +         if (to < FIRST_REF_NODE && from < FIRST_REF_NODE)
2959 +           stats.num_edges++;
2960 +         bitmap_set_bit (graph->succs[from], to);
2961         }
2962 -      else
2963 -       {
2964 -         bitmap *weights;
2965 -
2966 -         r = add_graph_edge (graph, to, from);
2967 -         weights = get_graph_weights (graph, to, from);
2968 -
2969 -         if (!*weights)
2970 -           {
2971 -             r = true;
2972 -             *weights = allocate_graph_weights (graph, to, from);
2973 -             bitmap_set_bit (*weights, weight);
2974 -           }
2975 -         else
2976 -           {
2977 -             r |= !bitmap_bit_p (*weights, weight);
2978 -             bitmap_set_bit (*weights, weight);
2979 -           }
2980 -       }
2981 -      
2982        return r;
2983      }
2984  }
2985 @@ -1168,46 +924,51 @@
2986  /* Return true if {DEST.SRC} is an existing graph edge in GRAPH.  */
2987  
2988  static bool
2989 -valid_graph_edge (constraint_graph_t graph, unsigned int src, 
2990 +valid_graph_edge (constraint_graph_t graph, unsigned int src,
2991                   unsigned int dest)
2992  {
2993 -  struct constraint_edge lookfor;
2994 -  lookfor.dest = src;
2995 -  
2996 -  return (graph->zero_weight_succs[dest] 
2997 -      && bitmap_bit_p (graph->zero_weight_succs[dest], src)) 
2998 -    || constraint_edge_vec_find (graph->succs[dest], lookfor) != NULL;
2999 +  return (graph->succs[dest]
3000 +         && bitmap_bit_p (graph->succs[dest], src));
3001  }
3002  
3003 -/* Return true if {DEST, SRC} is an existing weighted graph edge (IE has
3004 -   a weight other than 0) in GRAPH.  */
3005 -static bool
3006 -valid_weighted_graph_edge (constraint_graph_t graph, unsigned int src, 
3007 -                          unsigned int dest)
3008 -{
3009 -  struct constraint_edge lookfor;
3010 -  lookfor.dest = src;
3011 -  
3012 -  return graph->preds[src] 
3013 -    && constraint_edge_vec_find (graph->succs[dest], lookfor) != NULL;
3014 -}
3015 +/* Build the constraint graph, adding only predecessor edges right now.  */
3016  
3017 -
3018 -/* Build the constraint graph.  */
3019 -
3020  static void
3021 -build_constraint_graph (void)
3022 +build_pred_graph (void)
3023  {
3024 -  int i = 0;
3025 +  int i;
3026    constraint_t c;
3027 +  unsigned int j;
3028  
3029    graph = XNEW (struct constraint_graph);
3030 -  graph_size = VEC_length (varinfo_t, varmap) + 1;
3031 -  graph->succs = XCNEWVEC (VEC(constraint_edge_t,heap) *, graph_size);
3032 -  graph->preds = XCNEWVEC (VEC(constraint_edge_t,heap) *, graph_size);
3033 -  graph->zero_weight_succs = XCNEWVEC (bitmap, graph_size);
3034 -  graph->zero_weight_preds = XCNEWVEC (bitmap, graph_size);
3035 +  graph->size = (VEC_length (varinfo_t, varmap)) * 3;
3036 +  graph->succs = XCNEWVEC (bitmap, graph->size);
3037 +  graph->implicit_preds = XCNEWVEC (bitmap, graph->size);
3038 +  graph->preds = XCNEWVEC (bitmap, graph->size);
3039 +  graph->indirect_cycles = XNEWVEC (int, VEC_length (varinfo_t, varmap));
3040 +  graph->label = XCNEWVEC (unsigned int, graph->size);
3041 +  graph->rep = XNEWVEC (unsigned int, graph->size);
3042 +  graph->eq_rep = XNEWVEC (int, graph->size);
3043 +  graph->complex = XCNEWVEC (VEC(constraint_t, heap) *,
3044 +                            VEC_length (varinfo_t, varmap));
3045 +  graph->direct_nodes = sbitmap_alloc (graph->size);
3046 +  sbitmap_zero (graph->direct_nodes);
3047  
3048 +  for (j = 0; j < FIRST_REF_NODE; j++)
3049 +    {
3050 +      if (!get_varinfo (j)->is_special_var)
3051 +       SET_BIT (graph->direct_nodes, j);
3052 +    }
3053 +
3054 +  for (j = 0; j < graph->size; j++)
3055 +    {
3056 +      graph->rep[j] = j;
3057 +      graph->eq_rep[j] = -1;
3058 +    }
3059 +
3060 +  for (j = 0; j < VEC_length (varinfo_t, varmap); j++)
3061 +    graph->indirect_cycles[j] = -1;
3062 +
3063    for (i = 0; VEC_iterate (constraint_t, constraints, i, c); i++)
3064      {
3065        struct constraint_expr lhs = c->lhs;
3066 @@ -1217,31 +978,92 @@
3067  
3068        if (lhs.type == DEREF)
3069         {
3070 -         /* *x = y or *x = &y (complex) */
3071 -         if (rhs.type == ADDRESSOF || rhsvar > anything_id)
3072 -           insert_into_complex (lhsvar, c);
3073 +         /* *x = y.  */
3074 +         if (rhs.offset == 0 && lhs.offset == 0 && rhs.type == SCALAR)
3075 +           add_pred_graph_edge (graph, FIRST_REF_NODE + lhsvar, rhsvar);
3076 +         if (rhs.type == ADDRESSOF)
3077 +           RESET_BIT (graph->direct_nodes, rhsvar);
3078         }
3079        else if (rhs.type == DEREF)
3080         {
3081 -         /* !special var= *y */
3082 -         if (!(get_varinfo (lhsvar)->is_special_var))
3083 -           insert_into_complex (rhsvar, c);
3084 +         /* x = *y */
3085 +         if (rhs.offset == 0 && lhs.offset == 0 && lhs.type == SCALAR)
3086 +           add_pred_graph_edge (graph, lhsvar, FIRST_REF_NODE + rhsvar);
3087 +         else
3088 +           RESET_BIT (graph->direct_nodes, lhsvar);
3089         }
3090        else if (rhs.type == ADDRESSOF)
3091         {
3092           /* x = &y */
3093 +         add_pred_graph_edge (graph, lhsvar, FIRST_ADDR_NODE + rhsvar);
3094 +         /* Implicitly, *x = y */
3095 +         add_implicit_graph_edge (graph, FIRST_REF_NODE + lhsvar, rhsvar);
3096 +
3097 +         RESET_BIT (graph->direct_nodes, rhsvar);
3098 +       }
3099 +      else if (lhsvar > anything_id
3100 +              && lhsvar != rhsvar && lhs.offset == 0 && rhs.offset == 0)
3101 +       {
3102 +         /* x = y */
3103 +         add_pred_graph_edge (graph, lhsvar, rhsvar);
3104 +         /* Implicitly, *x = *y */
3105 +         add_implicit_graph_edge (graph, FIRST_REF_NODE + lhsvar,
3106 +                                  FIRST_REF_NODE + rhsvar);
3107 +       }
3108 +      else if (lhs.offset != 0 || rhs.offset != 0)
3109 +       {
3110 +         if (rhs.offset != 0)
3111 +           RESET_BIT (graph->direct_nodes, lhs.var);
3112 +         if (lhs.offset != 0)
3113 +           RESET_BIT (graph->direct_nodes, rhs.var);
3114 +       }
3115 +    }
3116 +}
3117 +
3118 +/* Build the constraint graph, adding successor edges.  */
3119 +
3120 +static void
3121 +build_succ_graph (void)
3122 +{
3123 +  int i;
3124 +  constraint_t c;
3125 +
3126 +  for (i = 0; VEC_iterate (constraint_t, constraints, i, c); i++)
3127 +    {
3128 +      struct constraint_expr lhs;
3129 +      struct constraint_expr rhs;
3130 +      unsigned int lhsvar;
3131 +      unsigned int rhsvar;
3132 +
3133 +      if (!c)
3134 +       continue;
3135 +
3136 +      lhs = c->lhs;
3137 +      rhs = c->rhs;
3138 +      lhsvar = find (get_varinfo_fc (lhs.var)->id);
3139 +      rhsvar = find (get_varinfo_fc (rhs.var)->id);
3140 +
3141 +      if (lhs.type == DEREF)
3142 +       {
3143 +         if (rhs.offset == 0 && lhs.offset == 0 && rhs.type == SCALAR)
3144 +           add_graph_edge (graph, FIRST_REF_NODE + lhsvar, rhsvar);
3145 +       }
3146 +      else if (rhs.type == DEREF)
3147 +       {
3148 +         if (rhs.offset == 0 && lhs.offset == 0 && lhs.type == SCALAR)
3149 +           add_graph_edge (graph, lhsvar, FIRST_REF_NODE + rhsvar);
3150 +       }
3151 +      else if (rhs.type == ADDRESSOF)
3152 +       {
3153 +         /* x = &y */
3154 +         gcc_assert (find (get_varinfo_fc (rhs.var)->id)
3155 +                     == get_varinfo_fc (rhs.var)->id);
3156           bitmap_set_bit (get_varinfo (lhsvar)->solution, rhsvar);
3157         }
3158 -      else if (lhsvar > anything_id)
3159 +      else if (lhsvar > anything_id
3160 +              && lhsvar != rhsvar && lhs.offset == 0 && rhs.offset == 0)
3161         {
3162 -         /* Ignore 0 weighted self edges, as they can't possibly contribute
3163 -            anything */
3164 -         if (lhsvar != rhsvar || rhs.offset != 0 || lhs.offset != 0)
3165 -           {
3166 -             /* x = y (simple) */
3167 -             int_add_graph_edge (graph, lhs.var, rhs.var, rhs.offset);
3168 -           }
3169 -         
3170 +         add_graph_edge (graph, lhsvar, rhsvar);
3171         }
3172      }
3173  }
3174 @@ -1260,20 +1082,20 @@
3175  struct scc_info
3176  {
3177    sbitmap visited;
3178 -  sbitmap in_component;
3179 +  sbitmap roots;
3180 +  unsigned int *dfs;
3181 +  unsigned int *node_mapping;
3182    int current_index;
3183 -  unsigned int *visited_index;
3184    VEC(unsigned,heap) *scc_stack;
3185 -  VEC(unsigned,heap) *unification_queue;
3186  };
3187  
3188  
3189  /* Recursive routine to find strongly connected components in GRAPH.
3190     SI is the SCC info to store the information in, and N is the id of current
3191     graph node we are processing.
3192 -   
3193 +
3194     This is Tarjan's strongly connected component finding algorithm, as
3195 -   modified by Nuutila to keep only non-root nodes on the stack.  
3196 +   modified by Nuutila to keep only non-root nodes on the stack.
3197     The algorithm can be found in "On finding the strongly connected
3198     connected components in a directed graph" by Esko Nuutila and Eljas
3199     Soisalon-Soininen, in Information Processing Letters volume 49,
3200 @@ -1284,188 +1106,144 @@
3201  {
3202    unsigned int i;
3203    bitmap_iterator bi;
3204 +  unsigned int my_dfs;
3205  
3206 -  gcc_assert (get_varinfo (n)->node == n);
3207    SET_BIT (si->visited, n);
3208 -  RESET_BIT (si->in_component, n);
3209 -  si->visited_index[n] = si->current_index ++;
3210 -  
3211 +  si->dfs[n] = si->current_index ++;
3212 +  my_dfs = si->dfs[n];
3213 +
3214    /* Visit all the successors.  */
3215 -  EXECUTE_IF_IN_NONNULL_BITMAP (graph->zero_weight_succs[n], 0, i, bi)
3216 +  EXECUTE_IF_IN_NONNULL_BITMAP (graph->succs[n], 0, i, bi)
3217      {
3218 -      unsigned int w = i;
3219 +      unsigned int w;
3220 +
3221 +      if (i > LAST_REF_NODE)
3222 +       break;
3223 +
3224 +      w = find (i);
3225 +      if (TEST_BIT (si->roots, w))
3226 +       continue;
3227 +
3228        if (!TEST_BIT (si->visited, w))
3229         scc_visit (graph, si, w);
3230 -      if (!TEST_BIT (si->in_component, w))
3231 -       {
3232 -         unsigned int t = get_varinfo (w)->node;
3233 -         unsigned int nnode = get_varinfo (n)->node;
3234 -         if (si->visited_index[t] < si->visited_index[nnode])
3235 -           get_varinfo (n)->node = t;
3236 -       }
3237 +      {
3238 +       unsigned int t = find (w);
3239 +       unsigned int nnode = find (n);
3240 +       gcc_assert (nnode == n);
3241 +
3242 +       if (si->dfs[t] < si->dfs[nnode])
3243 +         si->dfs[n] = si->dfs[t];
3244 +      }
3245      }
3246 -  
3247 +
3248    /* See if any components have been identified.  */
3249 -  if (get_varinfo (n)->node == n)
3250 +  if (si->dfs[n] == my_dfs)
3251      {
3252 -      unsigned int t = si->visited_index[n];
3253 -      SET_BIT (si->in_component, n);
3254 -      while (VEC_length (unsigned, si->scc_stack) != 0 
3255 -            && t < si->visited_index[VEC_last (unsigned, si->scc_stack)])
3256 +      if (VEC_length (unsigned, si->scc_stack) > 0
3257 +         && si->dfs[VEC_last (unsigned, si->scc_stack)] >= my_dfs)
3258         {
3259 -         unsigned int w = VEC_pop (unsigned, si->scc_stack);
3260 -         get_varinfo (w)->node = n;
3261 -         SET_BIT (si->in_component, w);
3262 -         /* Mark this node for collapsing.  */
3263 -         VEC_safe_push (unsigned, heap, si->unification_queue, w);
3264 -       } 
3265 -    }
3266 -  else
3267 -    VEC_safe_push (unsigned, heap, si->scc_stack, n);
3268 -}
3269 +         bitmap scc = BITMAP_ALLOC (NULL);
3270 +         bool have_ref_node = n >= FIRST_REF_NODE;
3271 +         unsigned int lowest_node;
3272 +         bitmap_iterator bi;
3273  
3274 +         bitmap_set_bit (scc, n);
3275  
3276 -/* Collapse two variables into one variable.  */
3277 +         while (VEC_length (unsigned, si->scc_stack) != 0
3278 +                && si->dfs[VEC_last (unsigned, si->scc_stack)] >= my_dfs)
3279 +           {
3280 +             unsigned int w = VEC_pop (unsigned, si->scc_stack);
3281  
3282 -static void
3283 -collapse_nodes (constraint_graph_t graph, unsigned int to, unsigned int from)
3284 -{
3285 -  bitmap tosol, fromsol;
3286 +             bitmap_set_bit (scc, w);
3287 +             if (w >= FIRST_REF_NODE)
3288 +               have_ref_node = true;
3289 +           }
3290  
3291 -  condense_varmap_nodes (to, from);
3292 -  tosol = get_varinfo (to)->solution;
3293 -  fromsol = get_varinfo (from)->solution;
3294 -  bitmap_ior_into (tosol, fromsol);
3295 -  merge_graph_nodes (graph, to, from);
3296 -
3297 -  if (valid_graph_edge (graph, to, to))
3298 -    {
3299 -      if (graph->zero_weight_preds[to])
3300 -       {
3301 -         bitmap_clear_bit (graph->zero_weight_preds[to], to);
3302 -         bitmap_clear_bit (graph->zero_weight_succs[to], to);
3303 +         lowest_node = bitmap_first_set_bit (scc);
3304 +         gcc_assert (lowest_node < FIRST_REF_NODE);
3305 +         EXECUTE_IF_SET_IN_BITMAP (scc, 0, i, bi)
3306 +           {
3307 +             if (i < FIRST_REF_NODE)
3308 +               {
3309 +                 /* Mark this node for collapsing.  */
3310 +                 if (unite (lowest_node, i))
3311 +                   unify_nodes (graph, lowest_node, i, false);
3312 +               }
3313 +             else
3314 +               {
3315 +                 unite (lowest_node, i);
3316 +                 graph->indirect_cycles[i - FIRST_REF_NODE] = lowest_node;
3317 +               }
3318 +           }
3319         }
3320 -      if (valid_weighted_graph_edge (graph, to, to))
3321 -       {
3322 -         bitmap weights = *(get_graph_weights (graph, to, to));
3323 -         if (!weights || bitmap_empty_p (weights))
3324 -           erase_graph_self_edge (graph, to);
3325 -       }
3326 +      SET_BIT (si->roots, n);
3327      }
3328 -  BITMAP_FREE (fromsol);
3329 -  get_varinfo (to)->address_taken |= get_varinfo (from)->address_taken;
3330 -  get_varinfo (to)->indirect_target |= get_varinfo (from)->indirect_target;
3331 +  else
3332 +    VEC_safe_push (unsigned, heap, si->scc_stack, n);
3333  }
3334  
3335 +/* Unify node FROM into node TO, updating the changed count if
3336 +   necessary when UPDATE_CHANGED is true.  */
3337  
3338 -/* Unify nodes in GRAPH that we have found to be part of a cycle.
3339 -   SI is the Strongly Connected Components information structure that tells us
3340 -   what components to unify.
3341 -   UPDATE_CHANGED should be set to true if the changed sbitmap and changed
3342 -   count should be updated to reflect the unification.  */
3343 -
3344  static void
3345 -process_unification_queue (constraint_graph_t graph, struct scc_info *si,
3346 -                          bool update_changed)
3347 +unify_nodes (constraint_graph_t graph, unsigned int to, unsigned int from,
3348 +            bool update_changed)
3349  {
3350 -  size_t i = 0;
3351 -  bitmap tmp = BITMAP_ALLOC (update_changed ? &iteration_obstack : NULL);
3352 -  bitmap_clear (tmp);
3353  
3354 -  /* We proceed as follows:
3355 +  gcc_assert (to != from && find (to) == to);
3356 +  if (dump_file && (dump_flags & TDF_DETAILS))
3357 +    fprintf (dump_file, "Unifying %s to %s\n",
3358 +            get_varinfo (from)->name,
3359 +            get_varinfo (to)->name);
3360  
3361 -     For each component in the queue (components are delineated by
3362 -     when current_queue_element->node != next_queue_element->node):
3363 +  if (update_changed)
3364 +    stats.unified_vars_dynamic++;
3365 +  else
3366 +    stats.unified_vars_static++;
3367  
3368 -        rep = representative node for component
3369 +  merge_graph_nodes (graph, to, from);
3370 +  merge_node_constraints (graph, to, from);
3371  
3372 -        For each node (tounify) to be unified in the component,
3373 -           merge the solution for tounify into tmp bitmap
3374 -
3375 -           clear solution for tounify
3376 -
3377 -           merge edges from tounify into rep
3378 -
3379 -          merge complex constraints from tounify into rep
3380 -
3381 -          update changed count to note that tounify will never change
3382 -          again
3383 -
3384 -       Merge tmp into solution for rep, marking rep changed if this
3385 -       changed rep's solution.
3386 -       
3387 -       Delete any 0 weighted self-edges we now have for rep.  */
3388 -  while (i != VEC_length (unsigned, si->unification_queue))
3389 +  if (update_changed && TEST_BIT (changed, from))
3390      {
3391 -      unsigned int tounify = VEC_index (unsigned, si->unification_queue, i);
3392 -      unsigned int n = get_varinfo (tounify)->node;
3393 -
3394 -      if (dump_file && (dump_flags & TDF_DETAILS))
3395 -       fprintf (dump_file, "Unifying %s to %s\n", 
3396 -                get_varinfo (tounify)->name,
3397 -                get_varinfo (n)->name);
3398 -      if (update_changed)
3399 -       stats.unified_vars_dynamic++;
3400 +      RESET_BIT (changed, from);
3401 +      if (!TEST_BIT (changed, to))
3402 +       SET_BIT (changed, to);
3403        else
3404 -       stats.unified_vars_static++;
3405 -      bitmap_ior_into (tmp, get_varinfo (tounify)->solution);
3406 -      merge_graph_nodes (graph, n, tounify);
3407 -      condense_varmap_nodes (n, tounify);
3408 -      
3409 -      if (update_changed && TEST_BIT (changed, tounify))
3410         {
3411 -         RESET_BIT (changed, tounify);
3412 -         if (!TEST_BIT (changed, n))
3413 -           SET_BIT (changed, n);
3414 -         else
3415 -           {
3416 -             gcc_assert (changed_count > 0);
3417 -             changed_count--;
3418 -           }
3419 +         gcc_assert (changed_count > 0);
3420 +         changed_count--;
3421         }
3422 +    }
3423  
3424 -      bitmap_clear (get_varinfo (tounify)->solution);
3425 -      ++i;
3426 -
3427 -      /* If we've either finished processing the entire queue, or
3428 -        finished processing all nodes for component n, update the solution for
3429 -        n.  */
3430 -      if (i == VEC_length (unsigned, si->unification_queue)
3431 -         || get_varinfo (VEC_index (unsigned, si->unification_queue, i))->node != n)
3432 +  /* If the solution changes because of the merging, we need to mark
3433 +     the variable as changed.  */
3434 +  if (bitmap_ior_into (get_varinfo (to)->solution,
3435 +                      get_varinfo (from)->solution))
3436 +    {
3437 +      if (update_changed && !TEST_BIT (changed, to))
3438         {
3439 -         /* If the solution changes because of the merging, we need to mark
3440 -            the variable as changed.  */
3441 -         if (bitmap_ior_into (get_varinfo (n)->solution, tmp))
3442 -           {
3443 -             if (update_changed && !TEST_BIT (changed, n))
3444 -               {
3445 -                 SET_BIT (changed, n);
3446 -                 changed_count++;
3447 -               }
3448 -           }
3449 -         bitmap_clear (tmp);
3450 -
3451 -         if (valid_graph_edge (graph, n, n))
3452 -           {
3453 -             if (graph->zero_weight_succs[n])
3454 -               {
3455 -                 if (graph->zero_weight_preds[n])
3456 -                   bitmap_clear_bit (graph->zero_weight_preds[n], n);
3457 -                 bitmap_clear_bit (graph->zero_weight_succs[n], n);
3458 -               }
3459 -             if (valid_weighted_graph_edge (graph, n, n))
3460 -               {
3461 -                 bitmap weights = *(get_graph_weights (graph, n, n));
3462 -                 if (!weights || bitmap_empty_p (weights))
3463 -                   erase_graph_self_edge (graph, n);
3464 -               }
3465 -           }
3466 +         SET_BIT (changed, to);
3467 +         changed_count++;
3468         }
3469      }
3470 -  BITMAP_FREE (tmp);
3471 +
3472 +  BITMAP_FREE (get_varinfo (from)->solution);
3473 +  BITMAP_FREE (get_varinfo (from)->oldsolution);
3474 +
3475 +  if (stats.iterations > 0)
3476 +    {
3477 +      BITMAP_FREE (get_varinfo (to)->oldsolution);
3478 +      get_varinfo (to)->oldsolution = BITMAP_ALLOC (&oldpta_obstack);
3479 +    }
3480 +
3481 +  if (valid_graph_edge (graph, to, to))
3482 +    {
3483 +      if (graph->succs[to])
3484 +       bitmap_clear_bit (graph->succs[to], to);
3485 +    }
3486  }
3487  
3488 -
3489  /* Information needed to compute the topological ordering of a graph.  */
3490  
3491  struct topo_info
3492 @@ -1509,37 +1287,24 @@
3493  topo_visit (constraint_graph_t graph, struct topo_info *ti,
3494             unsigned int n)
3495  {
3496 -  VEC(constraint_edge_t,heap) *succs = graph->succs[n];
3497 -  bitmap temp;
3498    bitmap_iterator bi;
3499 -  constraint_edge_t c;
3500 -  int i;
3501    unsigned int j;
3502  
3503    SET_BIT (ti->visited, n);
3504 -  if (VEC_length (constraint_edge_t, succs) != 0)
3505 -    {
3506 -      temp = BITMAP_ALLOC (&iteration_obstack);
3507 -      if (graph->zero_weight_succs[n])
3508 -       bitmap_ior_into (temp, graph->zero_weight_succs[n]);
3509 -      for (i = 0; VEC_iterate (constraint_edge_t, succs, i, c); i++)
3510 -       bitmap_set_bit (temp, c->dest);
3511 -    }
3512 -  else 
3513 -    temp = graph->zero_weight_succs[n];
3514  
3515 -  if (temp) 
3516 -    EXECUTE_IF_SET_IN_BITMAP (temp, 0, j, bi)
3517 +  if (graph->succs[n])
3518 +    EXECUTE_IF_SET_IN_BITMAP (graph->succs[n], 0, j, bi)
3519        {
3520         if (!TEST_BIT (ti->visited, j))
3521           topo_visit (graph, ti, j);
3522        }
3523 +
3524    VEC_safe_push (unsigned, heap, ti->topo_order, n);
3525  }
3526  
3527  /* Return true if variable N + OFFSET is a legal field of N.  */
3528  
3529 -static bool 
3530 +static bool
3531  type_safe (unsigned int n, unsigned HOST_WIDE_INT *offset)
3532  {
3533    varinfo_t ninfo = get_varinfo (n);
3534 @@ -1582,10 +1347,10 @@
3535           v = first_vi_for_offset (get_varinfo (j), fieldoffset);
3536           if (!v)
3537             continue;
3538 -         t = v->node;
3539 +         t = find (v->id);
3540           sol = get_varinfo (t)->solution;
3541           if (!bitmap_bit_p (sol, rhs))
3542 -           {             
3543 +           {
3544               bitmap_set_bit (sol, rhs);
3545               if (!TEST_BIT (changed, t))
3546                 {
3547 @@ -1596,7 +1361,7 @@
3548         }
3549        else if (0 && dump_file && !(get_varinfo (j)->is_special_var))
3550         fprintf (dump_file, "Untypesafe usage in do_da_constraint.\n");
3551 -      
3552 +
3553      }
3554  }
3555  
3556 @@ -1607,7 +1372,7 @@
3557  do_sd_constraint (constraint_graph_t graph, constraint_t c,
3558                   bitmap delta)
3559  {
3560 -  unsigned int lhs = get_varinfo (c->lhs.var)->node;
3561 +  unsigned int lhs = find (c->lhs.var);
3562    bool flag = false;
3563    bitmap sol = get_varinfo (lhs)->solution;
3564    unsigned int j;
3565 @@ -1620,7 +1385,7 @@
3566         bitmap_set_bit (sol, anything_id);
3567       goto done;
3568     }
3569 -  /* For each variable j in delta (Sol(y)), add    
3570 +  /* For each variable j in delta (Sol(y)), add
3571       an edge in the graph from j to x, and union Sol(j) into Sol(x).  */
3572    EXECUTE_IF_SET_IN_BITMAP (delta, 0, j, bi)
3573      {
3574 @@ -1634,18 +1399,18 @@
3575           v = first_vi_for_offset (get_varinfo (j), fieldoffset);
3576           if (!v)
3577             continue;
3578 -         t = v->node;
3579 +         t = find (v->id);
3580  
3581           /* Adding edges from the special vars is pointless.
3582              They don't have sets that can change.  */
3583           if (get_varinfo (t) ->is_special_var)
3584             flag |= bitmap_ior_into (sol, get_varinfo (t)->solution);
3585 -         else if (int_add_graph_edge (graph, lhs, t, 0))
3586 +         else if (add_graph_edge (graph, lhs, t))
3587             flag |= bitmap_ior_into (sol, get_varinfo (t)->solution);
3588         }
3589        else if (0 && dump_file && !(get_varinfo (j)->is_special_var))
3590         fprintf (dump_file, "Untypesafe usage in do_sd_constraint\n");
3591 -      
3592 +
3593      }
3594  
3595  done:
3596 @@ -1658,15 +1423,15 @@
3597           SET_BIT (changed, lhs);
3598           changed_count++;
3599         }
3600 -    }    
3601 +    }
3602  }
3603  
3604  /* Process a constraint C that represents *x = y.  */
3605  
3606  static void
3607 -do_ds_constraint (constraint_graph_t graph, constraint_t c, bitmap delta)
3608 +do_ds_constraint (constraint_t c, bitmap delta)
3609  {
3610 -  unsigned int rhs = get_varinfo (c->rhs.var)->node;
3611 +  unsigned int rhs = find (c->rhs.var);
3612    unsigned HOST_WIDE_INT roff = c->rhs.offset;
3613    bitmap sol = get_varinfo (rhs)->solution;
3614    unsigned int j;
3615 @@ -1685,8 +1450,8 @@
3616          v = first_vi_for_offset (get_varinfo (j), fieldoffset);
3617          if (!v)
3618            continue;
3619 -        t = v->node;
3620 -        
3621 +        t = find (v->id);
3622 +
3623          if (!bitmap_bit_p (get_varinfo (t)->solution, anything_id))
3624            {
3625              bitmap_set_bit (get_varinfo (t)->solution, anything_id);
3626 @@ -1705,40 +1470,39 @@
3627    EXECUTE_IF_SET_IN_BITMAP (delta, 0, j, bi)
3628      {
3629        unsigned HOST_WIDE_INT loff = c->lhs.offset;
3630 -      if (type_safe (j, &loff) && !(get_varinfo(j)->is_special_var))
3631 +      if (type_safe (j, &loff) && !(get_varinfo (j)->is_special_var))
3632         {
3633           varinfo_t v;
3634           unsigned int t;
3635           unsigned HOST_WIDE_INT fieldoffset = get_varinfo (j)->offset + loff;
3636 +         bitmap tmp;
3637  
3638           v = first_vi_for_offset (get_varinfo (j), fieldoffset);
3639           if (!v)
3640             continue;
3641 -         t = v->node;
3642 -         if (int_add_graph_edge (graph, t, rhs, roff))
3643 +         t = find (v->id);
3644 +         tmp = get_varinfo (t)->solution;
3645 +
3646 +         if (set_union_with_increment (tmp, sol, roff))
3647             {
3648 -             bitmap tmp = get_varinfo (t)->solution;
3649 -             if (set_union_with_increment (tmp, sol, roff))
3650 +             get_varinfo (t)->solution = tmp;
3651 +             if (t == rhs)
3652 +               sol = get_varinfo (rhs)->solution;
3653 +             if (!TEST_BIT (changed, t))
3654                 {
3655 -                 get_varinfo (t)->solution = tmp;
3656 -                 if (t == rhs)
3657 -                   sol = get_varinfo (rhs)->solution;
3658 -                 if (!TEST_BIT (changed, t))
3659 -                   {
3660 -                     SET_BIT (changed, t);
3661 -                     changed_count++;
3662 -                   }
3663 +                 SET_BIT (changed, t);
3664 +                 changed_count++;
3665                 }
3666             }
3667 -       }    
3668 +       }
3669        else if (0 && dump_file && !(get_varinfo (j)->is_special_var))
3670         fprintf (dump_file, "Untypesafe usage in do_ds_constraint\n");
3671      }
3672  }
3673  
3674 -/* Handle a non-simple (simple meaning requires no iteration), non-copy
3675 -   constraint (IE *x = &y, x = *y, and *x = y).  */
3676 -   
3677 +/* Handle a non-simple (simple meaning requires no iteration),
3678 +   constraint (IE *x = &y, x = *y, *x = y, and x = y with offsets involved).  */
3679 +
3680  static void
3681  do_complex_constraint (constraint_graph_t graph, constraint_t c, bitmap delta)
3682  {
3683 @@ -1752,33 +1516,62 @@
3684        else
3685         {
3686           /* *x = y */
3687 -         do_ds_constraint (graph, c, delta);
3688 +         do_ds_constraint (c, delta);
3689         }
3690      }
3691 -  else
3692 +  else if (c->rhs.type == DEREF)
3693      {
3694        /* x = *y */
3695        if (!(get_varinfo (c->lhs.var)->is_special_var))
3696         do_sd_constraint (graph, c, delta);
3697      }
3698 +  else
3699 +    {
3700 +      bitmap tmp;
3701 +      bitmap solution;
3702 +      bool flag = false;
3703 +      unsigned int t;
3704 +
3705 +      gcc_assert (c->rhs.type == SCALAR && c->lhs.type == SCALAR);
3706 +      t = find (c->rhs.var);
3707 +      solution = get_varinfo (t)->solution;
3708 +      t = find (c->lhs.var);
3709 +      tmp = get_varinfo (t)->solution;
3710 +
3711 +      flag = set_union_with_increment (tmp, solution, c->rhs.offset);
3712 +
3713 +      if (flag)
3714 +       {
3715 +         get_varinfo (t)->solution = tmp;
3716 +         if (!TEST_BIT (changed, t))
3717 +           {
3718 +             SET_BIT (changed, t);
3719 +             changed_count++;
3720 +           }
3721 +       }
3722 +    }
3723  }
3724  
3725  /* Initialize and return a new SCC info structure.  */
3726  
3727  static struct scc_info *
3728 -init_scc_info (void)
3729 +init_scc_info (size_t size)
3730  {
3731    struct scc_info *si = XNEW (struct scc_info);
3732 -  size_t size = VEC_length (varinfo_t, varmap);
3733 +  size_t i;
3734  
3735    si->current_index = 0;
3736    si->visited = sbitmap_alloc (size);
3737    sbitmap_zero (si->visited);
3738 -  si->in_component = sbitmap_alloc (size);
3739 -  sbitmap_ones (si->in_component);
3740 -  si->visited_index = XCNEWVEC (unsigned int, size + 1);
3741 +  si->roots = sbitmap_alloc (size);
3742 +  sbitmap_zero (si->roots);
3743 +  si->node_mapping = XNEWVEC (unsigned int, size);
3744 +  si->dfs = XCNEWVEC (unsigned int, size);
3745 +
3746 +  for (i = 0; i < size; i++)
3747 +    si->node_mapping[i] = i;
3748 +
3749    si->scc_stack = VEC_alloc (unsigned, heap, 1);
3750 -  si->unification_queue = VEC_alloc (unsigned, heap, 1);
3751    return si;
3752  }
3753  
3754 @@ -1786,209 +1579,430 @@
3755  
3756  static void
3757  free_scc_info (struct scc_info *si)
3758 -{  
3759 +{
3760    sbitmap_free (si->visited);
3761 -  sbitmap_free (si->in_component);
3762 -  free (si->visited_index);
3763 +  sbitmap_free (si->roots);
3764 +  free (si->node_mapping);
3765 +  free (si->dfs);
3766    VEC_free (unsigned, heap, si->scc_stack);
3767 -  VEC_free (unsigned, heap, si->unification_queue);
3768 -  free(si); 
3769 +  free (si);
3770  }
3771  
3772  
3773 -/* Find cycles in GRAPH that occur, using strongly connected components, and
3774 -   collapse the cycles into a single representative node.  if UPDATE_CHANGED
3775 -   is true, then update the changed sbitmap to note those nodes whose
3776 -   solutions have changed as a result of collapsing.  */
3777 +/* Find indirect cycles in GRAPH that occur, using strongly connected
3778 +   components, and note them in the indirect cycles map.
3779  
3780 +   This technique comes from Ben Hardekopf and Calvin Lin,
3781 +   "It Pays to be Lazy: Fast and Accurate Pointer Analysis for Millions of
3782 +   Lines of Code", submitted to PLDI 2007.  */
3783 +
3784  static void
3785 -find_and_collapse_graph_cycles (constraint_graph_t graph, bool update_changed)
3786 +find_indirect_cycles (constraint_graph_t graph)
3787  {
3788    unsigned int i;
3789 -  unsigned int size = VEC_length (varinfo_t, varmap);
3790 -  struct scc_info *si = init_scc_info ();
3791 +  unsigned int size = graph->size;
3792 +  struct scc_info *si = init_scc_info (size);
3793  
3794 -  for (i = 0; i != size; ++i)
3795 -    if (!TEST_BIT (si->visited, i) && get_varinfo (i)->node == i)
3796 +  for (i = 0; i < MIN (LAST_REF_NODE, size); i ++ )
3797 +    if (!TEST_BIT (si->visited, i) && find (i) == i)
3798        scc_visit (graph, si, i);
3799 -  
3800 -  process_unification_queue (graph, si, update_changed);
3801 +
3802    free_scc_info (si);
3803  }
3804  
3805  /* Compute a topological ordering for GRAPH, and store the result in the
3806     topo_info structure TI.  */
3807  
3808 -static void 
3809 +static void
3810  compute_topo_order (constraint_graph_t graph,
3811                     struct topo_info *ti)
3812  {
3813    unsigned int i;
3814    unsigned int size = VEC_length (varinfo_t, varmap);
3815 -  
3816 +
3817    for (i = 0; i != size; ++i)
3818 -    if (!TEST_BIT (ti->visited, i) && get_varinfo (i)->node == i)
3819 +    if (!TEST_BIT (ti->visited, i) && find (i) == i)
3820        topo_visit (graph, ti, i);
3821  }
3822  
3823 -/* Return true if bitmap B is empty, or a bitmap other than bit 0 is set. */
3824 +/* Perform offline variable substitution.
3825  
3826 -static bool
3827 -bitmap_other_than_zero_bit_set (bitmap b)
3828 -{
3829 -  unsigned int i;
3830 -  bitmap_iterator bi;
3831 -
3832 -  if (bitmap_empty_p (b))
3833 -    return false;
3834 -  EXECUTE_IF_SET_IN_BITMAP (b, 1, i, bi)
3835 -    return true;
3836 -  return false;
3837 -}
3838 -
3839 -/* Perform offline variable substitution.
3840 -   
3841     This is a linear time way of identifying variables that must have
3842     equivalent points-to sets, including those caused by static cycles,
3843     and single entry subgraphs, in the constraint graph.
3844  
3845     The technique is described in "Off-line variable substitution for
3846     scaling points-to analysis" by Atanas Rountev and Satish Chandra,
3847 -   in "ACM SIGPLAN Notices" volume 35, number 5, pages 47-56.  */
3848 +   in "ACM SIGPLAN Notices" volume 35, number 5, pages 47-56.
3849  
3850 +   There is an optimal way to do this involving hash based value
3851 +   numbering, once the technique is published i will implement it
3852 +   here.  
3853 +
3854 +   The general method of finding equivalence classes is as follows:
3855 +   Add fake nodes (REF nodes) and edges for *a = b and a = *b constraints.
3856 +   Add fake nodes (ADDRESS nodes) and edges for a = &b constraints.
3857 +   Initialize all non-REF/ADDRESS nodes to be direct nodes
3858 +   For each SCC in the predecessor graph:
3859 +      for each member (x) of the SCC
3860 +         if x is not a direct node:
3861 +          set rootnode(SCC) to be not a direct node
3862 +        collapse node x into rootnode(SCC).
3863 +      if rootnode(SCC) is not a direct node:
3864 +        label rootnode(SCC) with a new equivalence class
3865 +      else:
3866 +        if all labeled predecessors of rootnode(SCC) have the same
3867 +       label:
3868 +         label rootnode(SCC) with this label
3869 +       else:
3870 +         label rootnode(SCC) with a new equivalence class
3871 +
3872 +   All direct nodes with the same equivalence class can be replaced
3873 +   with a single representative node.
3874 +   All unlabeled nodes (label == 0) are not pointers and all edges
3875 +   involving them can be eliminated.
3876 +   We perform these optimizations during move_complex_constraints.
3877 +*/
3878 +
3879 +static int equivalence_class;
3880 +
3881 +/* Recursive routine to find strongly connected components in GRAPH,
3882 +   and label it's nodes with equivalence classes.
3883 +   This is used during variable substitution to find cycles involving
3884 +   the regular or implicit predecessors, and label them as equivalent.
3885 +   The SCC finding algorithm used is the same as that for scc_visit.  */
3886 +
3887  static void
3888 -perform_var_substitution (constraint_graph_t graph)
3889 +label_visit (constraint_graph_t graph, struct scc_info *si, unsigned int n)
3890  {
3891 -  struct topo_info *ti = init_topo_info ();
3892
3893 -  bitmap_obstack_initialize (&iteration_obstack);
3894 -  /* Compute the topological ordering of the graph, then visit each
3895 -     node in topological order.  */
3896 -  compute_topo_order (graph, ti);
3897
3898 -  while (VEC_length (unsigned, ti->topo_order) != 0)
3899 +  unsigned int i;
3900 +  bitmap_iterator bi;
3901 +  unsigned int my_dfs;
3902 +
3903 +  gcc_assert (si->node_mapping[n] == n);
3904 +  SET_BIT (si->visited, n);
3905 +  si->dfs[n] = si->current_index ++;
3906 +  my_dfs = si->dfs[n];
3907 +
3908 +  /* Visit all the successors.  */
3909 +  EXECUTE_IF_IN_NONNULL_BITMAP (graph->preds[n], 0, i, bi)
3910      {
3911 -      unsigned int i = VEC_pop (unsigned, ti->topo_order);
3912 -      unsigned int pred;
3913 -      varinfo_t vi = get_varinfo (i);
3914 -      bool okay_to_elim = false;
3915 -      unsigned int root = VEC_length (varinfo_t, varmap);
3916 -      VEC(constraint_edge_t,heap) *predvec = graph->preds[i];
3917 -      constraint_edge_t ce = NULL;
3918 -      bitmap tmp;
3919 -      unsigned int k;
3920 -      bitmap_iterator bi;
3921 +      unsigned int w = si->node_mapping[i];
3922  
3923 -      /* We can't eliminate things whose address is taken, or which is
3924 -        the target of a dereference.  */
3925 -      if (vi->address_taken || vi->indirect_target)
3926 +      if (TEST_BIT (si->roots, w))
3927         continue;
3928  
3929 -      /* See if all predecessors of I are ripe for elimination */
3930 -      EXECUTE_IF_IN_NONNULL_BITMAP (graph->zero_weight_preds[i], 0, k, bi)
3931 -         {
3932 -           unsigned int w;
3933 -           w = get_varinfo (k)->node;
3934 +      if (!TEST_BIT (si->visited, w))
3935 +       label_visit (graph, si, w);
3936 +      {
3937 +       unsigned int t = si->node_mapping[w];
3938 +       unsigned int nnode = si->node_mapping[n];
3939 +       gcc_assert (nnode == n);
3940  
3941 -           /* We can't eliminate the node if one of the predecessors is
3942 -              part of a different strongly connected component.  */
3943 -           if (!okay_to_elim)
3944 -             {
3945 -               root = w;
3946 -               okay_to_elim = true;
3947 -             }
3948 -           else if (w != root)
3949 -             {
3950 -               okay_to_elim = false;
3951 -               break;
3952 -             }
3953 +       if (si->dfs[t] < si->dfs[nnode])
3954 +         si->dfs[n] = si->dfs[t];
3955 +      }
3956 +    }
3957  
3958 -           /* Theorem 4 in Rountev and Chandra: If i is a direct node,
3959 -              then Solution(i) is a subset of Solution (w), where w is a
3960 -              predecessor in the graph.  
3961 -              Corollary: If all predecessors of i have the same
3962 -              points-to set, then i has that same points-to set as
3963 -              those predecessors.  */
3964 -           tmp = BITMAP_ALLOC (NULL);
3965 -           bitmap_and_compl (tmp, get_varinfo (i)->solution,
3966 -                             get_varinfo (w)->solution);
3967 -           if (!bitmap_empty_p (tmp))
3968 -             {
3969 -               okay_to_elim = false;
3970 -               BITMAP_FREE (tmp);
3971 -               break;
3972 -             }
3973 -           BITMAP_FREE (tmp);
3974 -         }
3975 +  /* Visit all the implicit predecessors.  */
3976 +  EXECUTE_IF_IN_NONNULL_BITMAP (graph->implicit_preds[n], 0, i, bi)
3977 +    {
3978 +      unsigned int w = si->node_mapping[i];
3979  
3980 -      if (okay_to_elim)
3981 -       for (pred = 0; 
3982 -            VEC_iterate (constraint_edge_t, predvec, pred, ce); 
3983 -            pred++)
3984 -         {
3985 -           bitmap weight;
3986 -           unsigned int w;
3987 -           weight = *(get_graph_weights (graph, i, ce->dest));
3988 +      if (TEST_BIT (si->roots, w))
3989 +       continue;
3990  
3991 -           /* We can't eliminate variables that have nonzero weighted
3992 -              edges between them.  */
3993 -           if (weight && bitmap_other_than_zero_bit_set (weight))
3994 -             {
3995 -               okay_to_elim = false;
3996 -               break;
3997 -             }
3998 -           w = get_varinfo (ce->dest)->node;
3999 +      if (!TEST_BIT (si->visited, w))
4000 +       label_visit (graph, si, w);
4001 +      {
4002 +       unsigned int t = si->node_mapping[w];
4003 +       unsigned int nnode = si->node_mapping[n];
4004 +       gcc_assert (nnode == n);
4005  
4006 -           /* We can't eliminate the node if one of the predecessors is
4007 -              part of a different strongly connected component.  */
4008 -           if (!okay_to_elim)
4009 -             {
4010 -               root = w;
4011 -               okay_to_elim = true;
4012 -             }
4013 -           else if (w != root)
4014 -             {
4015 -               okay_to_elim = false;
4016 -               break;
4017 -             }
4018 +       if (si->dfs[t] < si->dfs[nnode])
4019 +         si->dfs[n] = si->dfs[t];
4020 +      }
4021 +    }
4022  
4023 -           /* Theorem 4 in Rountev and Chandra: If i is a direct node,
4024 -              then Solution(i) is a subset of Solution (w), where w is a
4025 -              predecessor in the graph.  
4026 -              Corollary: If all predecessors of i have the same
4027 -              points-to set, then i has that same points-to set as
4028 -              those predecessors.  */
4029 -           tmp = BITMAP_ALLOC (NULL);
4030 -           bitmap_and_compl (tmp, get_varinfo (i)->solution,
4031 -                             get_varinfo (w)->solution);
4032 -           if (!bitmap_empty_p (tmp))
4033 -             {
4034 -               okay_to_elim = false;
4035 -               BITMAP_FREE (tmp);
4036 -               break;
4037 -             }
4038 -           BITMAP_FREE (tmp);
4039 -         }
4040 +  /* See if any components have been identified.  */
4041 +  if (si->dfs[n] == my_dfs)
4042 +    {
4043 +      while (VEC_length (unsigned, si->scc_stack) != 0
4044 +            && si->dfs[VEC_last (unsigned, si->scc_stack)] >= my_dfs)
4045 +       {
4046 +         unsigned int w = VEC_pop (unsigned, si->scc_stack);
4047 +         si->node_mapping[w] = n;
4048  
4049 -      /* See if the root is different than the original node. 
4050 -        If so, we've found an equivalence.  */
4051 -      if (root != get_varinfo (i)->node && okay_to_elim)
4052 +         if (!TEST_BIT (graph->direct_nodes, w))
4053 +           RESET_BIT (graph->direct_nodes, n);
4054 +       }
4055 +      SET_BIT (si->roots, n);
4056 +
4057 +      if (!TEST_BIT (graph->direct_nodes, n))
4058         {
4059 -         /* Found an equivalence */
4060 -         get_varinfo (i)->node = root;
4061 -         collapse_nodes (graph, root, i);
4062 +         graph->label[n] = equivalence_class++;
4063 +       }
4064 +      else
4065 +       {
4066 +         unsigned int size = 0;
4067 +         unsigned int firstlabel = ~0;
4068 +
4069 +         EXECUTE_IF_IN_NONNULL_BITMAP (graph->preds[n], 0, i, bi)
4070 +           {
4071 +             unsigned int j = si->node_mapping[i];
4072 +
4073 +             if (j == n || graph->label[j] == 0)
4074 +               continue;
4075 +
4076 +             if (firstlabel == (unsigned int)~0)
4077 +               {
4078 +                 firstlabel = graph->label[j];
4079 +                 size++;
4080 +               }
4081 +             else if (graph->label[j] != firstlabel)
4082 +               size++;
4083 +           }
4084 +
4085 +         if (size == 0)
4086 +           graph->label[n] = 0;
4087 +         else if (size == 1)
4088 +           graph->label[n] = firstlabel;
4089 +         else
4090 +           graph->label[n] = equivalence_class++;
4091 +       }
4092 +    }
4093 +  else
4094 +    VEC_safe_push (unsigned, heap, si->scc_stack, n);
4095 +}
4096 +
4097 +/* Perform offline variable substitution, discovering equivalence
4098 +   classes, and eliminating non-pointer variables.  */
4099 +
4100 +static struct scc_info *
4101 +perform_var_substitution (constraint_graph_t graph)
4102 +{
4103 +  unsigned int i;
4104 +  unsigned int size = graph->size;
4105 +  struct scc_info *si = init_scc_info (size);
4106 +
4107 +  bitmap_obstack_initialize (&iteration_obstack);
4108 +  equivalence_class = 0;
4109 +
4110 +  /* We only need to visit the non-address nodes for labeling
4111 +     purposes, as the address nodes will never have any predecessors,
4112 +     because &x never appears on the LHS of a constraint.  */
4113 +  for (i = 0; i < LAST_REF_NODE; i++)
4114 +    if (!TEST_BIT (si->visited, si->node_mapping[i]))
4115 +      label_visit (graph, si, si->node_mapping[i]);
4116 +
4117 +  if (dump_file && (dump_flags & TDF_DETAILS))
4118 +    for (i = 0; i < FIRST_REF_NODE; i++)
4119 +      {
4120 +       bool direct_node = TEST_BIT (graph->direct_nodes, i);
4121 +       fprintf (dump_file,
4122 +                "Equivalence class for %s node id %d:%s is %d\n",
4123 +                direct_node ? "Direct node" : "Indirect node", i,
4124 +                get_varinfo (i)->name,
4125 +                graph->label[si->node_mapping[i]]);
4126 +      }
4127 +
4128 +  /* Quickly eliminate our non-pointer variables.  */
4129 +
4130 +  for (i = 0; i < FIRST_REF_NODE; i++)
4131 +    {
4132 +      unsigned int node = si->node_mapping[i];
4133 +
4134 +      if (graph->label[node] == 0 && TEST_BIT (graph->direct_nodes, node))
4135 +       {
4136           if (dump_file && (dump_flags & TDF_DETAILS))
4137 -           fprintf (dump_file, "Collapsing %s into %s\n",
4138 -                    get_varinfo (i)->name,
4139 -                    get_varinfo (root)->name);
4140 -         stats.collapsed_vars++;
4141 +           fprintf (dump_file,
4142 +                    "%s is a non-pointer variable, eliminating edges.\n",
4143 +                    get_varinfo (node)->name);
4144 +         stats.nonpointer_vars++;
4145 +         clear_edges_for_node (graph, node);
4146         }
4147      }
4148 +  return si;
4149 +}
4150  
4151 +/* Free information that was only necessary for variable
4152 +   substitution.  */
4153 +
4154 +static void
4155 +free_var_substitution_info (struct scc_info *si)
4156 +{
4157 +  free_scc_info (si);
4158 +  free (graph->label);
4159 +  free (graph->eq_rep);
4160 +  sbitmap_free (graph->direct_nodes);
4161    bitmap_obstack_release (&iteration_obstack);
4162 -  free_topo_info (ti);
4163  }
4164  
4165 +/* Return an existing node that is equivalent to NODE, which has
4166 +   equivalence class LABEL, if one exists.  Return NODE otherwise.  */
4167 +
4168 +static unsigned int
4169 +find_equivalent_node (constraint_graph_t graph,
4170 +                     unsigned int node, unsigned int label)
4171 +{
4172 +  /* If the address version of this variable is unused, we can
4173 +     substitute it for anything else with the same label.
4174 +     Otherwise, we know the pointers are equivalent, but not the
4175 +     locations.  */
4176 +
4177 +  if (graph->label[FIRST_ADDR_NODE + node] == 0)
4178 +    {
4179 +      gcc_assert (label < graph->size);
4180 +
4181 +      if (graph->eq_rep[label] != -1)
4182 +       {
4183 +         /* Unify the two variables since we know they are equivalent.  */
4184 +         if (unite (graph->eq_rep[label], node))
4185 +           unify_nodes (graph, graph->eq_rep[label], node, false);
4186 +         return graph->eq_rep[label];
4187 +       }
4188 +      else
4189 +       {
4190 +         graph->eq_rep[label] = node;
4191 +       }
4192 +    }
4193 +  return node;
4194 +}
4195 +
4196 +/* Move complex constraints to the appropriate nodes, and collapse
4197 +   variables we've discovered are equivalent during variable
4198 +   substitution.  SI is the SCC_INFO that is the result of
4199 +   perform_variable_substitution.  */
4200 +
4201 +static void
4202 +move_complex_constraints (constraint_graph_t graph,
4203 +                         struct scc_info *si)
4204 +{
4205 +  int i;
4206 +  unsigned int j;
4207 +  constraint_t c;
4208 +
4209 +  for (j = 0; j < graph->size; j++)
4210 +    gcc_assert (find (j) == j);
4211 +
4212 +  for (i = 0; VEC_iterate (constraint_t, constraints, i, c); i++)
4213 +    {
4214 +      struct constraint_expr lhs = c->lhs;
4215 +      struct constraint_expr rhs = c->rhs;
4216 +      unsigned int lhsvar = find (get_varinfo_fc (lhs.var)->id);
4217 +      unsigned int rhsvar = find (get_varinfo_fc (rhs.var)->id);
4218 +      unsigned int lhsnode, rhsnode;
4219 +      unsigned int lhslabel, rhslabel;
4220 +
4221 +      lhsnode = si->node_mapping[lhsvar];
4222 +      rhsnode = si->node_mapping[rhsvar];
4223 +      lhslabel = graph->label[lhsnode];
4224 +      rhslabel = graph->label[rhsnode];
4225 +
4226 +      /* See if it is really a non-pointer variable, and if so, ignore
4227 +        the constraint.  */
4228 +      if (lhslabel == 0)
4229 +       {
4230 +         if (!TEST_BIT (graph->direct_nodes, lhsnode))
4231 +           lhslabel = graph->label[lhsnode] = equivalence_class++;
4232 +         else
4233 +           {
4234 +             if (dump_file && (dump_flags & TDF_DETAILS))
4235 +               {
4236 +
4237 +                 fprintf (dump_file, "%s is a non-pointer variable,"
4238 +                          "ignoring constraint:",
4239 +                          get_varinfo (lhs.var)->name);
4240 +                 dump_constraint (dump_file, c);
4241 +               }
4242 +             VEC_replace (constraint_t, constraints, i, NULL);
4243 +             continue;
4244 +           }
4245 +       }
4246 +
4247 +      if (rhslabel == 0)
4248 +       {
4249 +         if (!TEST_BIT (graph->direct_nodes, rhsnode))
4250 +           rhslabel = graph->label[rhsnode] = equivalence_class++;
4251 +         else
4252 +           {
4253 +             if (dump_file && (dump_flags & TDF_DETAILS))
4254 +               {
4255 +
4256 +                 fprintf (dump_file, "%s is a non-pointer variable,"
4257 +                          "ignoring constraint:",
4258 +                          get_varinfo (rhs.var)->name);
4259 +                 dump_constraint (dump_file, c);
4260 +               }
4261 +             VEC_replace (constraint_t, constraints, i, NULL);
4262 +             continue;
4263 +           }
4264 +       }
4265 +
4266 +      lhsvar = find_equivalent_node (graph, lhsvar, lhslabel);
4267 +      rhsvar = find_equivalent_node (graph, rhsvar, rhslabel);
4268 +      c->lhs.var = lhsvar;
4269 +      c->rhs.var = rhsvar;
4270 +
4271 +      if (lhs.type == DEREF)
4272 +       {
4273 +         if (rhs.type == ADDRESSOF || rhsvar > anything_id)
4274 +           insert_into_complex (graph, lhsvar, c);
4275 +       }
4276 +      else if (rhs.type == DEREF)
4277 +       {
4278 +         if (!(get_varinfo (lhsvar)->is_special_var))
4279 +           insert_into_complex (graph, rhsvar, c);
4280 +       }
4281 +      else if (rhs.type != ADDRESSOF && lhsvar > anything_id
4282 +              && (lhs.offset != 0 || rhs.offset != 0))
4283 +       {
4284 +         insert_into_complex (graph, rhsvar, c);
4285 +       }
4286 +
4287 +    }
4288 +}
4289 +
4290 +/* Eliminate indirect cycles involving NODE.  Return true if NODE was
4291 +   part of an SCC, false otherwise.  */
4292 +
4293 +static bool
4294 +eliminate_indirect_cycles (unsigned int node)
4295 +{
4296 +  if (graph->indirect_cycles[node] != -1
4297 +      && !bitmap_empty_p (get_varinfo (node)->solution))
4298 +    {
4299 +      unsigned int i;
4300 +      VEC(unsigned,heap) *queue = NULL;
4301 +      int queuepos;
4302 +      unsigned int to = find (graph->indirect_cycles[node]);
4303 +      bitmap_iterator bi;
4304 +
4305 +      /* We can't touch the solution set and call unify_nodes
4306 +        at the same time, because unify_nodes is going to do
4307 +        bitmap unions into it. */
4308 +
4309 +      EXECUTE_IF_SET_IN_BITMAP (get_varinfo (node)->solution, 0, i, bi)
4310 +       {
4311 +         if (find (i) == i && i != to)
4312 +           {
4313 +             if (unite (to, i))
4314 +               VEC_safe_push (unsigned, heap, queue, i);
4315 +           }
4316 +       }
4317 +
4318 +      for (queuepos = 0;
4319 +          VEC_iterate (unsigned, queue, queuepos, i);
4320 +          queuepos++)
4321 +       {
4322 +         unify_nodes (graph, to, i, true);
4323 +       }
4324 +      VEC_free (unsigned, heap, queue);
4325 +      return true;
4326 +    }
4327 +  return false;
4328 +}
4329 +
4330  /* Solve the constraint graph GRAPH using our worklist solver.
4331     This is based on the PW* family of solvers from the "Efficient Field
4332     Sensitive Pointer Analysis for C" paper.
4333 @@ -2001,17 +2015,28 @@
4334  {
4335    unsigned int size = VEC_length (varinfo_t, varmap);
4336    unsigned int i;
4337 +  bitmap pts;
4338  
4339 -  changed_count = size;
4340 +  changed_count = 0;
4341    changed = sbitmap_alloc (size);
4342 -  sbitmap_ones (changed);
4343 -  
4344 -  /* The already collapsed/unreachable nodes will never change, so we
4345 -     need to  account for them in changed_count.  */
4346 +  sbitmap_zero (changed);
4347 +
4348 +  /* Mark all initial non-collapsed nodes as changed.  */
4349    for (i = 0; i < size; i++)
4350 -    if (get_varinfo (i)->node != i)
4351 -      changed_count--;
4352 -  
4353 +    {
4354 +      varinfo_t ivi = get_varinfo (i);
4355 +      if (find (i) == i && !bitmap_empty_p (ivi->solution)
4356 +         && ((graph->succs[i] && !bitmap_empty_p (graph->succs[i]))
4357 +             || VEC_length (constraint_t, graph->complex[i]) > 0))
4358 +       {
4359 +         SET_BIT (changed, i);
4360 +         changed_count++;
4361 +       }
4362 +    }
4363 +
4364 +  /* Allocate a bitmap to be used to store the changed bits.  */
4365 +  pts = BITMAP_ALLOC (&pta_obstack);
4366 +
4367    while (changed_count > 0)
4368      {
4369        unsigned int i;
4370 @@ -2019,41 +2044,45 @@
4371        stats.iterations++;
4372  
4373        bitmap_obstack_initialize (&iteration_obstack);
4374 -      
4375 -      if (edge_added)
4376 -       {
4377 -         /* We already did cycle elimination once, when we did
4378 -            variable substitution, so we don't need it again for the
4379 -            first iteration.  */
4380 -         if (stats.iterations > 1)
4381 -           find_and_collapse_graph_cycles (graph, true);
4382  
4383 -         edge_added = false;
4384 -       }
4385 -
4386        compute_topo_order (graph, ti);
4387  
4388        while (VEC_length (unsigned, ti->topo_order) != 0)
4389         {
4390 +
4391           i = VEC_pop (unsigned, ti->topo_order);
4392 -         gcc_assert (get_varinfo (i)->node == i);
4393  
4394 +         /* If this variable is not a representative, skip it.  */
4395 +         if (find (i) != i)
4396 +           continue;
4397 +
4398 +         /* In certain indirect cycle cases, we may merge this
4399 +            variable to another.  */
4400 +         if (eliminate_indirect_cycles (i) && find (i) != i)
4401 +           continue;
4402 +
4403           /* If the node has changed, we need to process the
4404              complex constraints and outgoing edges again.  */
4405           if (TEST_BIT (changed, i))
4406             {
4407               unsigned int j;
4408               constraint_t c;
4409 -             constraint_edge_t e = NULL;
4410               bitmap solution;
4411 -             bitmap_iterator bi;
4412 -             VEC(constraint_t,heap) *complex = get_varinfo (i)->complex;
4413 -             VEC(constraint_edge_t,heap) *succs;
4414 +             VEC(constraint_t,heap) *complex = graph->complex[i];
4415               bool solution_empty;
4416  
4417               RESET_BIT (changed, i);
4418               changed_count--;
4419  
4420 +             /* Compute the changed set of solution bits.  */
4421 +             bitmap_and_compl (pts, get_varinfo (i)->solution,
4422 +                               get_varinfo (i)->oldsolution);
4423 +
4424 +             if (bitmap_empty_p (pts))
4425 +               continue;
4426 +
4427 +             bitmap_ior_into (get_varinfo (i)->oldsolution, pts);
4428 +
4429               solution = get_varinfo (i)->solution;
4430               solution_empty = bitmap_empty_p (solution);
4431  
4432 @@ -2065,52 +2094,38 @@
4433                      is a constraint where the lhs side is receiving
4434                      some set from elsewhere.  */
4435                   if (!solution_empty || c->lhs.type != DEREF)
4436 -                   do_complex_constraint (graph, c, solution);
4437 +                   do_complex_constraint (graph, c, pts);
4438                 }
4439  
4440               solution_empty = bitmap_empty_p (solution);
4441  
4442               if (!solution_empty)
4443                 {
4444 +                 bitmap_iterator bi;
4445 +
4446                   /* Propagate solution to all successors.  */
4447 -                 succs = graph->succs[i];
4448 -                 
4449 -                 EXECUTE_IF_IN_NONNULL_BITMAP (graph->zero_weight_succs[i], 
4450 +                 EXECUTE_IF_IN_NONNULL_BITMAP (graph->succs[i],
4451                                                 0, j, bi)
4452                     {
4453 -                     bitmap tmp = get_varinfo (j)->solution;
4454 -                     bool flag = false;
4455 -                 
4456 -                     flag = set_union_with_increment (tmp, solution, 0);
4457 -                 
4458 -                     if (flag)
4459 -                       {
4460 -                         get_varinfo (j)->solution = tmp;
4461 -                         if (!TEST_BIT (changed, j))
4462 -                           {
4463 -                             SET_BIT (changed, j);
4464 -                             changed_count++;
4465 -                           }
4466 -                       }
4467 -                   }
4468 -                 for (j = 0; VEC_iterate (constraint_edge_t, succs, j, e); j++)
4469 -                   {
4470 -                     bitmap tmp = get_varinfo (e->dest)->solution;
4471 -                     bool flag = false;
4472 -                     unsigned int k;
4473 -                     bitmap weights = e->weights;
4474 -                     bitmap_iterator bi;
4475 +                     bitmap tmp;
4476 +                     bool flag;
4477  
4478 -                     gcc_assert (weights && !bitmap_empty_p (weights));
4479 -                     EXECUTE_IF_SET_IN_BITMAP (weights, 0, k, bi)
4480 -                       flag |= set_union_with_increment (tmp, solution, k);
4481 +                     unsigned int to = find (j);
4482 +                     tmp = get_varinfo (to)->solution;
4483 +                     flag = false;
4484  
4485 +                     /* Don't try to propagate to ourselves.  */
4486 +                     if (to == i)
4487 +                       continue;
4488 +
4489 +                     flag = set_union_with_increment (tmp, pts, 0);
4490 +
4491                       if (flag)
4492                         {
4493 -                         get_varinfo (e->dest)->solution = tmp;
4494 -                         if (!TEST_BIT (changed, e->dest))
4495 +                         get_varinfo (to)->solution = tmp;
4496 +                         if (!TEST_BIT (changed, to))
4497                             {
4498 -                             SET_BIT (changed, e->dest);
4499 +                             SET_BIT (changed, to);
4500                               changed_count++;
4501                             }
4502                         }
4503 @@ -2122,74 +2137,37 @@
4504        bitmap_obstack_release (&iteration_obstack);
4505      }
4506  
4507 +  BITMAP_FREE (pts);
4508    sbitmap_free (changed);
4509 +  bitmap_obstack_release (&oldpta_obstack);
4510  }
4511  
4512 +/* Map from trees to variable infos.  */
4513 +static struct pointer_map_t *vi_for_tree;
4514  
4515 -/* CONSTRAINT AND VARIABLE GENERATION FUNCTIONS */
4516  
4517 -/* Map from trees to variable ids.  */    
4518 -static htab_t id_for_tree;
4519 +/* Insert ID as the variable id for tree T in the vi_for_tree map.  */
4520  
4521 -typedef struct tree_id
4522 +static void
4523 +insert_vi_for_tree (tree t, varinfo_t vi)
4524  {
4525 -  tree t;
4526 -  unsigned int id;
4527 -} *tree_id_t;
4528 -
4529 -/* Hash a tree id structure.  */
4530 -
4531 -static hashval_t 
4532 -tree_id_hash (const void *p)
4533 -{
4534 -  const tree_id_t ta = (tree_id_t) p;
4535 -  return htab_hash_pointer (ta->t);
4536 -}
4537 -
4538 -/* Return true if the tree in P1 and the tree in P2 are the same.  */
4539 -
4540 -static int
4541 -tree_id_eq (const void *p1, const void *p2)
4542 -{
4543 -  const tree_id_t ta1 = (tree_id_t) p1;
4544 -  const tree_id_t ta2 = (tree_id_t) p2;
4545 -  return ta1->t == ta2->t;
4546 -}
4547 -
4548 -/* Insert ID as the variable id for tree T in the hashtable.  */
4549 -
4550 -static void 
4551 -insert_id_for_tree (tree t, int id)
4552 -{
4553 -  void **slot;
4554 -  struct tree_id finder;
4555 -  tree_id_t new_pair;
4556 -  
4557 -  finder.t = t;
4558 -  slot = htab_find_slot (id_for_tree, &finder, INSERT);
4559 +  void **slot = pointer_map_insert (vi_for_tree, t);
4560 +  gcc_assert (vi);
4561    gcc_assert (*slot == NULL);
4562 -  new_pair = XNEW (struct tree_id);
4563 -  new_pair->t = t;
4564 -  new_pair->id = id;
4565 -  *slot = (void *)new_pair;
4566 +  *slot = vi;
4567  }
4568  
4569 -/* Find the variable id for tree T in ID_FOR_TREE.  If T does not
4570 -   exist in the hash table, return false, otherwise, return true and
4571 -   set *ID to the id we found.  */
4572 +/* Find the variable info for tree T in VI_FOR_TREE.  If T does not
4573 +   exist in the map, return NULL, otherwise, return the varinfo we found.  */
4574  
4575 -static bool
4576 -lookup_id_for_tree (tree t, unsigned int *id)
4577 +static varinfo_t
4578 +lookup_vi_for_tree (tree t)
4579  {
4580 -  tree_id_t pair;
4581 -  struct tree_id finder;
4582 +  void **slot = pointer_map_contains (vi_for_tree, t);
4583 +  if (slot == NULL)
4584 +    return NULL;
4585  
4586 -  finder.t = t;
4587 -  pair = htab_find (id_for_tree,  &finder);
4588 -  if (pair == NULL)
4589 -    return false;
4590 -  *id = pair->id;
4591 -  return true;
4592 +  return (varinfo_t) *slot;
4593  }
4594  
4595  /* Return a printable name for DECL  */
4596 @@ -2210,7 +2188,7 @@
4597  
4598    if (TREE_CODE (decl) == SSA_NAME)
4599      {
4600 -      num_printed = asprintf (&temp, "%s_%u", 
4601 +      num_printed = asprintf (&temp, "%s_%u",
4602                               alias_get_name (SSA_NAME_VAR (decl)),
4603                               SSA_NAME_VERSION (decl));
4604      }
4605 @@ -2226,21 +2204,17 @@
4606    return res;
4607  }
4608  
4609 -/* Find the variable id for tree T in the hashtable.
4610 -   If T doesn't exist in the hash table, create an entry for it.  */
4611 +/* Find the variable id for tree T in the map.
4612 +   If T doesn't exist in the map, create an entry for it and return it.  */
4613  
4614 -static unsigned int
4615 -get_id_for_tree (tree t)
4616 +static varinfo_t
4617 +get_vi_for_tree (tree t)
4618  {
4619 -  tree_id_t pair;
4620 -  struct tree_id finder;
4621 +  void **slot = pointer_map_contains (vi_for_tree, t);
4622 +  if (slot == NULL)
4623 +    return get_varinfo (create_variable_info_for (t, alias_get_name (t)));
4624  
4625 -  finder.t = t;
4626 -  pair = htab_find (id_for_tree,  &finder);
4627 -  if (pair == NULL)
4628 -    return create_variable_info_for (t, alias_get_name (t));
4629 -  
4630 -  return pair->id;
4631 +  return (varinfo_t) *slot;
4632  }
4633  
4634  /* Get a constraint expression from an SSA_VAR_P node.  */
4635 @@ -2254,14 +2228,14 @@
4636  
4637    /* For parameters, get at the points-to set for the actual parm
4638       decl.  */
4639 -  if (TREE_CODE (t) == SSA_NAME 
4640 -      && TREE_CODE (SSA_NAME_VAR (t)) == PARM_DECL 
4641 +  if (TREE_CODE (t) == SSA_NAME
4642 +      && TREE_CODE (SSA_NAME_VAR (t)) == PARM_DECL
4643        && default_def (SSA_NAME_VAR (t)) == t)
4644      return get_constraint_exp_from_ssa_var (SSA_NAME_VAR (t));
4645  
4646    cexpr.type = SCALAR;
4647 -  
4648 -  cexpr.var = get_id_for_tree (t);
4649 +
4650 +  cexpr.var = get_vi_for_tree (t)->id;
4651    /* If we determine the result is "anything", and we know this is readonly,
4652       say it points to readonly memory instead.  */
4653    if (cexpr.var == anything_id && TREE_READONLY (t))
4654 @@ -2269,7 +2243,7 @@
4655        cexpr.type = ADDRESSOF;
4656        cexpr.var = readonly_id;
4657      }
4658 -    
4659 +
4660    cexpr.offset = 0;
4661    return cexpr;
4662  }
4663 @@ -2290,7 +2264,13 @@
4664      get_varinfo (lhs.var)->directly_dereferenced = true;
4665    if (rhs.type == DEREF)
4666      get_varinfo (rhs.var)->directly_dereferenced = true;
4667 -  
4668 +
4669 +  if (!use_field_sensitive)
4670 +    {
4671 +      t->rhs.offset = 0;
4672 +      t->lhs.offset = 0;
4673 +    }
4674 +
4675    /* ANYTHING == ANYTHING is pointless.  */
4676    if (lhs.var == anything_id && rhs.var == anything_id)
4677      return;
4678 @@ -2302,7 +2282,7 @@
4679        t->lhs = t->rhs;
4680        t->rhs = rhs;
4681        process_constraint (t);
4682 -    }   
4683 +    }
4684    /* This can happen in our IR with things like n->a = *p */
4685    else if (rhs.type == DEREF && lhs.type == DEREF && rhs.var != anything_id)
4686      {
4687 @@ -2312,33 +2292,19 @@
4688        tree pointedtotype = TREE_TYPE (pointertype);
4689        tree tmpvar = create_tmp_var_raw (pointedtotype, "doubledereftmp");
4690        struct constraint_expr tmplhs = get_constraint_exp_from_ssa_var (tmpvar);
4691 -      
4692 +
4693        /* If this is an aggregate of known size, we should have passed
4694          this off to do_structure_copy, and it should have broken it
4695          up.  */
4696 -      gcc_assert (!AGGREGATE_TYPE_P (pointedtotype) 
4697 +      gcc_assert (!AGGREGATE_TYPE_P (pointedtotype)
4698                   || get_varinfo (rhs.var)->is_unknown_size_var);
4699 -      
4700 +
4701        process_constraint (new_constraint (tmplhs, rhs));
4702        process_constraint (new_constraint (lhs, tmplhs));
4703      }
4704 -  else if (rhs.type == ADDRESSOF)
4705 -    {
4706 -      varinfo_t vi;
4707 -      gcc_assert (rhs.offset == 0);
4708 -      
4709 -      /* No need to mark address taken simply because of escaped vars
4710 -        constraints.  */
4711 -      if (lhs.var != escaped_vars_id)
4712 -       for (vi = get_varinfo (rhs.var); vi != NULL; vi = vi->next)
4713 -         vi->address_taken = true;
4714 -
4715 -      VEC_safe_push (constraint_t, heap, constraints, t);
4716 -    }
4717    else
4718      {
4719 -      if (lhs.type != DEREF && rhs.type == DEREF)
4720 -       get_varinfo (lhs.var)->indirect_target = true;
4721 +      gcc_assert (rhs.type != ADDRESSOF || rhs.offset == 0);
4722        VEC_safe_push (constraint_t, heap, constraints, t);
4723      }
4724  }
4725 @@ -2350,10 +2316,12 @@
4726  could_have_pointers (tree t)
4727  {
4728    tree type = TREE_TYPE (t);
4729 -  
4730 -  if (POINTER_TYPE_P (type) || AGGREGATE_TYPE_P (type)
4731 +
4732 +  if (POINTER_TYPE_P (type)
4733 +      || AGGREGATE_TYPE_P (type)
4734        || TREE_CODE (type) == COMPLEX_TYPE)
4735      return true;
4736 +
4737    return false;
4738  }
4739  
4740 @@ -2367,9 +2335,9 @@
4741    if (TREE_CODE (DECL_FIELD_OFFSET (fdecl)) != INTEGER_CST
4742        || TREE_CODE (DECL_FIELD_BIT_OFFSET (fdecl)) != INTEGER_CST)
4743      return -1;
4744 -  
4745 -  return (tree_low_cst (DECL_FIELD_OFFSET (fdecl), 1) * 8) 
4746 -         + tree_low_cst (DECL_FIELD_BIT_OFFSET (fdecl), 1);
4747 +
4748 +  return (tree_low_cst (DECL_FIELD_OFFSET (fdecl), 1) * 8)
4749 +        + tree_low_cst (DECL_FIELD_BIT_OFFSET (fdecl), 1);
4750  }
4751  
4752  
4753 @@ -2388,7 +2356,7 @@
4754      return true;
4755    if (accesspos < fieldpos && (accesspos + accesssize > fieldpos))
4756      return true;
4757 -  
4758 +
4759    return false;
4760  }
4761  
4762 @@ -2411,20 +2379,20 @@
4763    while (!SSA_VAR_P (forzero) && !CONSTANT_CLASS_P (forzero))
4764      forzero = TREE_OPERAND (forzero, 0);
4765  
4766 -  if (CONSTANT_CLASS_P (forzero) && integer_zerop (forzero)) 
4767 +  if (CONSTANT_CLASS_P (forzero) && integer_zerop (forzero))
4768      {
4769        struct constraint_expr temp;
4770 -      
4771 +
4772        temp.offset = 0;
4773        temp.var = integer_id;
4774        temp.type = SCALAR;
4775        VEC_safe_push (ce_s, heap, *results, &temp);
4776        return;
4777      }
4778
4779 +
4780    t = get_ref_base_and_extent (t, &bitpos, &bitsize, &bitmaxsize);
4781  
4782 -  /* String constants's are readonly, so there is nothing to really do
4783 +  /* String constants are readonly, so there is nothing to really do
4784       here.  */
4785    if (TREE_CODE (t) == STRING_CST)
4786      return;
4787 @@ -2438,21 +2406,21 @@
4788    /* This can also happen due to weird offsetof type macros.  */
4789    if (TREE_CODE (t) != ADDR_EXPR && result->type == ADDRESSOF)
4790      result->type = SCALAR;
4791
4792 +
4793    if (result->type == SCALAR)
4794      {
4795        /* In languages like C, you can access one past the end of an
4796          array.  You aren't allowed to dereference it, so we can
4797          ignore this constraint. When we handle pointer subtraction,
4798          we may have to do something cute here.  */
4799 -      
4800 +
4801        if (result->offset < get_varinfo (result->var)->fullsize
4802           && bitmaxsize != 0)
4803         {
4804           /* It's also not true that the constraint will actually start at the
4805              right offset, it may start in some padding.  We only care about
4806              setting the constraint to the first actual field it touches, so
4807 -            walk to find it.  */ 
4808 +            walk to find it.  */
4809           varinfo_t curr;
4810           for (curr = get_varinfo (result->var); curr; curr = curr->next)
4811             {
4812 @@ -2495,6 +2463,7 @@
4813  {
4814    struct constraint_expr *c;
4815    unsigned int i = 0;
4816 +
4817    for (i = 0; VEC_iterate (ce_s, *constraints, i, c); i++)
4818      {
4819        if (c->type == SCALAR)
4820 @@ -2576,6 +2545,7 @@
4821               tree pttype = TREE_TYPE (TREE_TYPE (t));
4822  
4823               get_constraint_for (exp, results);
4824 +
4825               /* Make sure we capture constraints to all elements
4826                  of an array.  */
4827               if ((handled_component_p (exp)
4828 @@ -2588,7 +2558,7 @@
4829  
4830                   if (VEC_length (ce_s, *results) == 0)
4831                     return;
4832 -                 
4833 +
4834                   gcc_assert (VEC_length (ce_s, *results) == 1);
4835                   origrhs = VEC_last (ce_s, *results);
4836                   tmp = *origrhs;
4837 @@ -2619,12 +2589,12 @@
4838                       VEC_safe_push (ce_s, heap, *results, &tmp);
4839                     }
4840                 }
4841 -             
4842 +
4843               for (i = 0; VEC_iterate (ce_s, *results, i, c); i++)
4844                 {
4845                   if (c->type == DEREF)
4846                     c->type = SCALAR;
4847 -                 else 
4848 +                 else
4849                     c->type = ADDRESSOF;
4850                 }
4851               return;
4852 @@ -2638,9 +2608,9 @@
4853               {
4854                 varinfo_t vi;
4855                 tree heapvar = heapvar_lookup (t);
4856 -               
4857 +
4858                 if (heapvar == NULL)
4859 -                 {                 
4860 +                 {
4861                     heapvar = create_tmp_var_raw (ptr_type_node, "HEAP");
4862                     DECL_EXTERNAL (heapvar) = 1;
4863                     if (referenced_vars)
4864 @@ -2650,7 +2620,7 @@
4865  
4866                 temp.var = create_variable_info_for (heapvar,
4867                                                      alias_get_name (heapvar));
4868 -               
4869 +
4870                 vi = get_varinfo (temp.var);
4871                 vi->is_artificial_var = 1;
4872                 vi->is_heap_var = 1;
4873 @@ -2712,7 +2682,7 @@
4874           case NON_LVALUE_EXPR:
4875             {
4876               tree op = TREE_OPERAND (t, 0);
4877 -             
4878 +
4879               /* Cast from non-pointer to pointers are bad news for us.
4880                  Anything else, we see through */
4881               if (!(POINTER_TYPE_P (TREE_TYPE (t))
4882 @@ -2738,7 +2708,7 @@
4883        {
4884         switch (TREE_CODE (t))
4885           {
4886 -         case PHI_NODE:           
4887 +         case PHI_NODE:
4888             {
4889               get_constraint_for (PHI_RESULT (t), results);
4890               return;
4891 @@ -2782,8 +2752,8 @@
4892  
4893  
4894  /* Handle the structure copy case where we have a simple structure copy
4895 -   between LHS and RHS that is of SIZE (in bits) 
4896 -  
4897 +   between LHS and RHS that is of SIZE (in bits)
4898 +
4899     For each field of the lhs variable (lhsfield)
4900       For each field of the rhs variable at lhsfield.offset (rhsfield)
4901         add the constraint lhsfield = rhsfield
4902 @@ -2808,7 +2778,7 @@
4903        struct constraint_expr temprhs = rhs;
4904        unsigned HOST_WIDE_INT fieldoffset;
4905  
4906 -      templhs.var = p->id;            
4907 +      templhs.var = p->id;
4908        q = get_varinfo (temprhs.var);
4909        fieldoffset = p->offset - pstart;
4910        q = first_vi_for_offset (q, q->offset + fieldoffset);
4911 @@ -2823,8 +2793,8 @@
4912  
4913  /* Handle the structure copy case where we have a  structure copy between a
4914     aggregate on the LHS and a dereference of a pointer on the RHS
4915 -   that is of SIZE (in bits) 
4916 -  
4917 +   that is of SIZE (in bits)
4918 +
4919     For each field of the lhs variable (lhsfield)
4920         rhs.offset = lhsfield->offset
4921         add the constraint lhsfield = rhs
4922 @@ -2849,12 +2819,12 @@
4923  
4924  
4925        if (templhs.type == SCALAR)
4926 -       templhs.var = p->id;      
4927 +       templhs.var = p->id;
4928        else
4929         templhs.offset = p->offset;
4930 -      
4931 +
4932        q = get_varinfo (temprhs.var);
4933 -      fieldoffset = p->offset - pstart;      
4934 +      fieldoffset = p->offset - pstart;
4935        temprhs.offset += fieldoffset;
4936        process_constraint (new_constraint (templhs, temprhs));
4937      }
4938 @@ -2862,7 +2832,7 @@
4939  
4940  /* Handle the structure copy case where we have a structure copy
4941     between a aggregate on the RHS and a dereference of a pointer on
4942 -   the LHS that is of SIZE (in bits) 
4943 +   the LHS that is of SIZE (in bits)
4944  
4945     For each field of the rhs variable (rhsfield)
4946         lhs.offset = rhsfield->offset
4947 @@ -2888,12 +2858,12 @@
4948  
4949  
4950        if (temprhs.type == SCALAR)
4951 -       temprhs.var = p->id;      
4952 +       temprhs.var = p->id;
4953        else
4954         temprhs.offset = p->offset;
4955 -      
4956 +
4957        q = get_varinfo (templhs.var);
4958 -      fieldoffset = p->offset - pstart;      
4959 +      fieldoffset = p->offset - pstart;
4960        templhs.offset += fieldoffset;
4961        process_constraint (new_constraint (templhs, temprhs));
4962      }
4963 @@ -2901,7 +2871,7 @@
4964  
4965  /* Sometimes, frontends like to give us bad type information.  This
4966     function will collapse all the fields from VAR to the end of VAR,
4967 -   into VAR, so that we treat those fields as a single variable. 
4968 +   into VAR, so that we treat those fields as a single variable.
4969     We return the variable they were collapsed into.  */
4970  
4971  static unsigned int
4972 @@ -2913,16 +2883,16 @@
4973    for (field = currvar->next; field; field = field->next)
4974      {
4975        if (dump_file)
4976 -       fprintf (dump_file, "Type safety: Collapsing var %s into %s\n", 
4977 +       fprintf (dump_file, "Type safety: Collapsing var %s into %s\n",
4978                  field->name, currvar->name);
4979 -      
4980 +
4981        gcc_assert (!field->collapsed_to);
4982        field->collapsed_to = currvar;
4983      }
4984  
4985    currvar->next = NULL;
4986    currvar->size = currvar->fullsize - currvar->offset;
4987 -  
4988 +
4989    return currvar->id;
4990  }
4991  
4992 @@ -2944,7 +2914,7 @@
4993    gcc_assert (VEC_length (ce_s, rhsc) == 1);
4994    lhs = *(VEC_last (ce_s, lhsc));
4995    rhs = *(VEC_last (ce_s, rhsc));
4996 -  
4997 +
4998    VEC_free (ce_s, heap, lhsc);
4999    VEC_free (ce_s, heap, rhsc);
5000  
5001 @@ -2955,7 +2925,7 @@
5002        lhs = rhs;
5003        rhs = tmp;
5004      }
5005 -  
5006 +
5007    /*  This is fairly conservative for the RHS == ADDRESSOF case, in that it's
5008        possible it's something we could handle.  However, most cases falling
5009        into this are dealing with transparent unions, which are slightly
5010 @@ -3021,11 +2991,11 @@
5011        else
5012         lhssize = TREE_INT_CST_LOW (lhstypesize);
5013  
5014 -  
5015 -      if (rhs.type == SCALAR && lhs.type == SCALAR)  
5016 +
5017 +      if (rhs.type == SCALAR && lhs.type == SCALAR)
5018         {
5019           if (!do_simple_structure_copy (lhs, rhs, MIN (lhssize, rhssize)))
5020 -           {         
5021 +           {
5022               lhs.var = collapse_rest_of_var (lhs.var);
5023               rhs.var = collapse_rest_of_var (rhs.var);
5024               lhs.offset = 0;
5025 @@ -3042,7 +3012,7 @@
5026        else
5027         {
5028           tree pointedtotype = lhstype;
5029 -         tree tmpvar;  
5030 +         tree tmpvar;
5031  
5032           gcc_assert (rhs.type == DEREF && lhs.type == DEREF);
5033           tmpvar = create_tmp_var_raw (pointedtotype, "structcopydereftmp");
5034 @@ -3052,6 +3022,7 @@
5035      }
5036  }
5037  
5038 +
5039  /* Update related alias information kept in AI.  This is used when
5040     building name tags, alias sets and deciding grouping heuristics.
5041     STMT is the statement to process.  This function also updates
5042 @@ -3261,7 +3232,6 @@
5043      }
5044  }
5045  
5046 -
5047  /* Handle pointer arithmetic EXPR when creating aliasing constraints.
5048     Expressions of the type PTR + CST can be handled in two ways:
5049  
5050 @@ -3307,6 +3277,7 @@
5051    else
5052      return false;
5053  
5054 +
5055    for (i = 0; VEC_iterate (ce_s, lhsc, i, c); i++)
5056      for (j = 0; VEC_iterate (ce_s, temp, j, c2); j++)
5057        {
5058 @@ -3360,12 +3331,12 @@
5059         {
5060           int i;
5061           unsigned int j;
5062 -         
5063 +
5064           /* For a phi node, assign all the arguments to
5065              the result.  */
5066           get_constraint_for (PHI_RESULT (t), &lhsc);
5067           for (i = 0; i < PHI_NUM_ARGS (t); i++)
5068 -           { 
5069 +           {
5070               tree rhstype;
5071               tree strippedrhs = PHI_ARG_DEF (t, i);
5072  
5073 @@ -3401,7 +3372,6 @@
5074      {
5075        tree lhsop;
5076        tree rhsop;
5077 -      unsigned int varid;
5078        tree arglist;
5079        varinfo_t fi;
5080        int i = 1;
5081 @@ -3423,17 +3393,16 @@
5082          we should still be able to handle.  */
5083        if (decl)
5084         {
5085 -         varid = get_id_for_tree (decl);
5086 +         fi = get_vi_for_tree (decl);
5087         }
5088        else
5089         {
5090           decl = TREE_OPERAND (rhsop, 0);
5091 -         varid = get_id_for_tree (decl);
5092 +         fi = get_vi_for_tree (decl);
5093         }
5094  
5095        /* Assign all the passed arguments to the appropriate incoming
5096          parameters of the function.  */
5097 -      fi = get_varinfo (varid);
5098        arglist = TREE_OPERAND (rhsop, 1);
5099         
5100        for (;arglist; arglist = TREE_CHAIN (arglist))
5101 @@ -3463,13 +3432,14 @@
5102             }
5103           i++;
5104         }
5105 +
5106        /* If we are returning a value, assign it to the result.  */
5107        if (lhsop)
5108         {
5109           struct constraint_expr rhs;
5110           struct constraint_expr *lhsp;
5111           unsigned int j = 0;
5112 -         
5113 +
5114           get_constraint_for (lhsop, &lhsc);
5115           if (TREE_CODE (decl) != FUNCTION_DECL)
5116             {
5117 @@ -3485,7 +3455,7 @@
5118             }
5119           for (j = 0; VEC_iterate (ce_s, lhsc, j, lhsp); j++)
5120             process_constraint (new_constraint (*lhsp, rhs));
5121 -       }      
5122 +       }
5123      }
5124    /* Otherwise, just a regular assignment statement.  */
5125    else if (TREE_CODE (t) == MODIFY_EXPR)
5126 @@ -3494,7 +3464,7 @@
5127        tree rhsop = TREE_OPERAND (t, 1);
5128        int i;
5129  
5130 -      if ((AGGREGATE_TYPE_P (TREE_TYPE (lhsop)) 
5131 +      if ((AGGREGATE_TYPE_P (TREE_TYPE (lhsop))
5132            || TREE_CODE (TREE_TYPE (lhsop)) == COMPLEX_TYPE)
5133           && (AGGREGATE_TYPE_P (TREE_TYPE (rhsop))
5134               || TREE_CODE (TREE_TYPE (lhsop)) == COMPLEX_TYPE))
5135 @@ -3513,7 +3483,7 @@
5136                 {
5137                   /* RHS that consist of unary operations,
5138                      exceptional types, or bare decls/constants, get
5139 -                    handled directly by get_constraint_for.  */ 
5140 +                    handled directly by get_constraint_for.  */
5141                   case tcc_reference:
5142                   case tcc_declaration:
5143                   case tcc_constant:
5144 @@ -3528,7 +3498,7 @@
5145                           {
5146                             struct constraint_expr *c2;
5147                             unsigned int k;
5148 -                           
5149 +
5150                             for (k = 0; VEC_iterate (ce_s, rhsc, k, c2); k++)
5151                               process_constraint (new_constraint (*c, *c2));
5152                           }
5153 @@ -3570,7 +3540,7 @@
5154                               }
5155                           }
5156                       }
5157 -               }      
5158 +               }
5159             }
5160         }
5161      }
5162 @@ -3578,7 +3548,7 @@
5163    /* After promoting variables and computing aliasing we will
5164       need to re-scan most statements.  FIXME: Try to minimize the
5165       number of statements re-scanned.  It's not really necessary to
5166 -     re-scan *all* statements.  */  
5167 +     re-scan *all* statements.  */
5168    mark_stmt_modified (origt);
5169    VEC_free (ce_s, heap, rhsc);
5170    VEC_free (ce_s, heap, lhsc);
5171 @@ -3591,7 +3561,7 @@
5172     first field that overlaps with OFFSET.
5173     Return NULL if we can't find one.  */
5174  
5175 -static varinfo_t 
5176 +static varinfo_t
5177  first_vi_for_offset (varinfo_t start, unsigned HOST_WIDE_INT offset)
5178  {
5179    varinfo_t curr = start;
5180 @@ -3617,7 +3587,7 @@
5181  {
5182    varinfo_t prev = base;
5183    varinfo_t curr = base->next;
5184 -  
5185 +
5186    field->next = curr;
5187    prev->next = field;
5188  }
5189 @@ -3630,7 +3600,7 @@
5190  {
5191    varinfo_t prev = base;
5192    varinfo_t curr = base->next;
5193 -  
5194 +
5195    if (curr == NULL)
5196      {
5197        prev->next = field;
5198 @@ -3652,13 +3622,13 @@
5199  
5200  /* qsort comparison function for two fieldoff's PA and PB */
5201  
5202 -static int 
5203 +static int
5204  fieldoff_compare (const void *pa, const void *pb)
5205  {
5206    const fieldoff_s *foa = (const fieldoff_s *)pa;
5207    const fieldoff_s *fob = (const fieldoff_s *)pb;
5208    HOST_WIDE_INT foasize, fobsize;
5209 -  
5210 +
5211    if (foa->offset != fob->offset)
5212      return foa->offset - fob->offset;
5213  
5214 @@ -3671,8 +3641,8 @@
5215  void
5216  sort_fieldstack (VEC(fieldoff_s,heap) *fieldstack)
5217  {
5218 -  qsort (VEC_address (fieldoff_s, fieldstack), 
5219 -        VEC_length (fieldoff_s, fieldstack), 
5220 +  qsort (VEC_address (fieldoff_s, fieldstack),
5221 +        VEC_length (fieldoff_s, fieldstack),
5222          sizeof (fieldoff_s),
5223          fieldoff_compare);
5224  }
5225 @@ -3686,12 +3656,12 @@
5226     TYPE.  */
5227  
5228  int
5229 -push_fields_onto_fieldstack (tree type, VEC(fieldoff_s,heap) **fieldstack, 
5230 +push_fields_onto_fieldstack (tree type, VEC(fieldoff_s,heap) **fieldstack,
5231                              HOST_WIDE_INT offset, bool *has_union)
5232  {
5233    tree field;
5234    int count = 0;
5235 -  
5236 +
5237    if (TREE_CODE (type) == COMPLEX_TYPE)
5238      {
5239        fieldoff_s *real_part, *img_part;
5240 @@ -3700,13 +3670,13 @@
5241        real_part->size = TYPE_SIZE (TREE_TYPE (type));
5242        real_part->offset = offset;
5243        real_part->decl = NULL_TREE;
5244 -      
5245 +
5246        img_part = VEC_safe_push (fieldoff_s, heap, *fieldstack, NULL);
5247        img_part->type = TREE_TYPE (type);
5248        img_part->size = TYPE_SIZE (TREE_TYPE (type));
5249        img_part->offset = offset + TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (type)));
5250        img_part->decl = NULL_TREE;
5251 -      
5252 +
5253        return 2;
5254      }
5255  
5256 @@ -3733,12 +3703,12 @@
5257         {
5258           bool push = false;
5259           int pushed = 0;
5260 -       
5261 -         if (has_union 
5262 +
5263 +         if (has_union
5264               && (TREE_CODE (TREE_TYPE (type)) == QUAL_UNION_TYPE
5265                   || TREE_CODE (TREE_TYPE (type)) == UNION_TYPE))
5266             *has_union = true;
5267 -       
5268 +
5269           if (!AGGREGATE_TYPE_P (TREE_TYPE (type))) /* var_can_have_subvars */
5270             push = true;
5271           else if (!(pushed = push_fields_onto_fieldstack
5272 @@ -3772,12 +3742,12 @@
5273        {
5274         bool push = false;
5275         int pushed = 0;
5276 -       
5277 -       if (has_union 
5278 +
5279 +       if (has_union
5280             && (TREE_CODE (TREE_TYPE (field)) == QUAL_UNION_TYPE
5281                 || TREE_CODE (TREE_TYPE (field)) == UNION_TYPE))
5282           *has_union = true;
5283 -       
5284 +
5285         if (!var_can_have_subvars (field))
5286           push = true;
5287         else if (!(pushed = push_fields_onto_fieldstack
5288 @@ -3789,7 +3759,7 @@
5289              see if we didn't push any subfields and the size is
5290              nonzero, push the field onto the stack */
5291           push = true;
5292 -       
5293 +
5294         if (push)
5295           {
5296             fieldoff_s *pair;
5297 @@ -3848,15 +3818,15 @@
5298    unsigned int i = 0;
5299    tree t;
5300  
5301 -  for (t = TYPE_ARG_TYPES (TREE_TYPE (decl)); 
5302 +  for (t = TYPE_ARG_TYPES (TREE_TYPE (decl));
5303         t;
5304         t = TREE_CHAIN (t))
5305 -    {  
5306 +    {
5307        if (TREE_VALUE (t) == void_type_node)
5308         break;
5309        i++;
5310      }
5311 -  
5312 +
5313    if (!t)
5314      *is_varargs = true;
5315    return i;
5316 @@ -3870,19 +3840,19 @@
5317  {
5318    unsigned int index = VEC_length (varinfo_t, varmap);
5319    varinfo_t vi;
5320 -  tree arg; 
5321 +  tree arg;
5322    unsigned int i;
5323    bool is_varargs = false;
5324  
5325    /* Create the variable info.  */
5326  
5327 -  vi = new_var_info (decl, index, name, index);
5328 +  vi = new_var_info (decl, index, name);
5329    vi->decl = decl;
5330    vi->offset = 0;
5331    vi->has_union = 0;
5332    vi->size = 1;
5333    vi->fullsize = count_num_arguments (decl, &is_varargs) + 1;
5334 -  insert_id_for_tree (vi->decl, index);  
5335 +  insert_vi_for_tree (vi->decl, vi);
5336    VEC_safe_push (varinfo_t, heap, varmap, vi);
5337  
5338    stats.total_vars++;
5339 @@ -3898,12 +3868,12 @@
5340        return index;
5341      }
5342  
5343 -  
5344 +
5345    arg = DECL_ARGUMENTS (decl);
5346  
5347    /* Set up variables for each argument.  */
5348    for (i = 1; i < vi->fullsize; i++)
5349 -    {      
5350 +    {
5351        varinfo_t argvi;
5352        const char *newname;
5353        char *tempname;
5354 @@ -3912,13 +3882,13 @@
5355  
5356        if (arg)
5357         argdecl = arg;
5358 -      
5359 +
5360        newindex = VEC_length (varinfo_t, varmap);
5361        asprintf (&tempname, "%s.arg%d", name, i-1);
5362        newname = ggc_strdup (tempname);
5363        free (tempname);
5364  
5365 -      argvi = new_var_info (argdecl, newindex,newname, newindex);
5366 +      argvi = new_var_info (argdecl, newindex, newname);
5367        argvi->decl = argdecl;
5368        VEC_safe_push (varinfo_t, heap, varmap, argvi);
5369        argvi->offset = i;
5370 @@ -3929,7 +3899,7 @@
5371        stats.total_vars ++;
5372        if (arg)
5373         {
5374 -         insert_id_for_tree (arg, newindex);
5375 +         insert_vi_for_tree (arg, argvi);
5376           arg = TREE_CHAIN (arg);
5377         }
5378      }
5379 @@ -3948,13 +3918,13 @@
5380  
5381        if (DECL_RESULT (decl))
5382         resultdecl = DECL_RESULT (decl);
5383 -      
5384 +
5385        newindex = VEC_length (varinfo_t, varmap);
5386        asprintf (&tempname, "%s.result", name);
5387        newname = ggc_strdup (tempname);
5388        free (tempname);
5389  
5390 -      resultvi = new_var_info (resultdecl, newindex, newname, newindex);
5391 +      resultvi = new_var_info (resultdecl, newindex, newname);
5392        resultvi->decl = resultdecl;
5393        VEC_safe_push (varinfo_t, heap, varmap, resultvi);
5394        resultvi->offset = i;
5395 @@ -3964,13 +3934,13 @@
5396        insert_into_field_list_sorted (vi, resultvi);
5397        stats.total_vars ++;
5398        if (DECL_RESULT (decl))
5399 -       insert_id_for_tree (DECL_RESULT (decl), newindex);
5400 +       insert_vi_for_tree (DECL_RESULT (decl), resultvi);
5401      }
5402    return index;
5403 -}  
5404 +}
5405  
5406  
5407 -/* Return true if FIELDSTACK contains fields that overlap. 
5408 +/* Return true if FIELDSTACK contains fields that overlap.
5409     FIELDSTACK is assumed to be sorted by offset.  */
5410  
5411  static bool
5412 @@ -4057,12 +4027,12 @@
5413    bool hasunion;
5414    bool is_global = DECL_P (decl) ? is_global_var (decl) : false;
5415    VEC (fieldoff_s,heap) *fieldstack = NULL;
5416 -  
5417 +
5418    if (TREE_CODE (decl) == FUNCTION_DECL && in_ipa_mode)
5419      return create_function_info_for (decl, name);
5420  
5421    hasunion = TREE_CODE (decltype) == UNION_TYPE
5422 -             || TREE_CODE (decltype) == QUAL_UNION_TYPE;
5423 +            || TREE_CODE (decltype) == QUAL_UNION_TYPE;
5424    if (var_can_have_subvars (decl) && use_field_sensitive && !hasunion)
5425      {
5426        push_fields_onto_fieldstack (decltype, &fieldstack, 0, &hasunion);
5427 @@ -4072,12 +4042,12 @@
5428           notokay = true;
5429         }
5430      }
5431 -  
5432  
5433 +
5434    /* If the variable doesn't have subvars, we may end up needing to
5435       sort the field list and create fake variables for all the
5436       fields.  */
5437 -  vi = new_var_info (decl, index, name, index);
5438 +  vi = new_var_info (decl, index, name);
5439    vi->decl = decl;
5440    vi->offset = 0;
5441    vi->has_union = hasunion;
5442 @@ -4095,8 +4065,8 @@
5443        vi->fullsize = TREE_INT_CST_LOW (declsize);
5444        vi->size = vi->fullsize;
5445      }
5446 -  
5447 -  insert_id_for_tree (vi->decl, index);  
5448 +
5449 +  insert_vi_for_tree (vi->decl, vi);
5450    VEC_safe_push (varinfo_t, heap, varmap, vi);
5451    if (is_global && (!flag_whole_program || !in_ipa_mode))
5452      {
5453 @@ -4122,9 +4092,9 @@
5454      }
5455  
5456    stats.total_vars++;
5457 -  if (use_field_sensitive 
5458 -      && !notokay 
5459 -      && !vi->is_unknown_size_var 
5460 +  if (use_field_sensitive
5461 +      && !notokay
5462 +      && !vi->is_unknown_size_var
5463        && var_can_have_subvars (decl)
5464        && VEC_length (fieldoff_s, fieldstack) <= MAX_FIELDS_FOR_FIELD_SENSITIVE)
5465      {
5466 @@ -4148,7 +4118,7 @@
5467          without creating varinfos for the fields anyway, so sorting them is a
5468          waste to boot.  */
5469        if (!notokay)
5470 -       {       
5471 +       {
5472           sort_fieldstack (fieldstack);
5473           /* Due to some C++ FE issues, like PR 22488, we might end up
5474              what appear to be overlapping fields even though they,
5475 @@ -4156,8 +4126,8 @@
5476              we will simply disable field-sensitivity for these cases.  */
5477           notokay = check_for_overlaps (fieldstack);
5478         }
5479 -      
5480 -      
5481 +
5482 +
5483        if (VEC_length (fieldoff_s, fieldstack) != 0)
5484         fo = VEC_index (fieldoff_s, fieldstack, 0);
5485  
5486 @@ -4169,11 +4139,11 @@
5487           VEC_free (fieldoff_s, heap, fieldstack);
5488           return index;
5489         }
5490 -      
5491 +
5492        vi->size = TREE_INT_CST_LOW (fo->size);
5493        vi->offset = fo->offset;
5494 -      for (i = VEC_length (fieldoff_s, fieldstack) - 1; 
5495 -          i >= 1 && VEC_iterate (fieldoff_s, fieldstack, i, fo); 
5496 +      for (i = VEC_length (fieldoff_s, fieldstack) - 1;
5497 +          i >= 1 && VEC_iterate (fieldoff_s, fieldstack, i, fo);
5498            i--)
5499         {
5500           varinfo_t newvi;
5501 @@ -4184,15 +4154,15 @@
5502           if (dump_file)
5503             {
5504               if (fo->decl)
5505 -               asprintf (&tempname, "%s.%s",
5506 +               asprintf (&tempname, "%s.%s",
5507                           vi->name, alias_get_name (fo->decl));
5508               else
5509 -               asprintf (&tempname, "%s." HOST_WIDE_INT_PRINT_DEC,
5510 +               asprintf (&tempname, "%s." HOST_WIDE_INT_PRINT_DEC,
5511                           vi->name, fo->offset);
5512               newname = ggc_strdup (tempname);
5513               free (tempname);
5514             }
5515 -         newvi = new_var_info (decl, newindex, newname, newindex);
5516 +         newvi = new_var_info (decl, newindex, newname);
5517           newvi->offset = fo->offset;
5518           newvi->size = TREE_INT_CST_LOW (fo->size);
5519           newvi->fullsize = vi->fullsize;
5520 @@ -4228,14 +4198,22 @@
5521  {
5522    varinfo_t vi = get_varinfo (var);
5523    unsigned int i;
5524 -  bitmap_iterator bi; 
5525 -  
5526 -  fprintf (file, "%s = { ", vi->name);
5527 -  EXECUTE_IF_SET_IN_BITMAP (get_varinfo (vi->node)->solution, 0, i, bi)
5528 +  bitmap_iterator bi;
5529 +
5530 +  if (find (var) != var)
5531      {
5532 -      fprintf (file, "%s ", get_varinfo (i)->name);
5533 +      varinfo_t vipt = get_varinfo (find (var));
5534 +      fprintf (file, "%s = same as %s\n", vi->name, vipt->name);
5535      }
5536 -  fprintf (file, "}\n");
5537 +  else
5538 +    {
5539 +      fprintf (file, "%s = { ", vi->name);
5540 +      EXECUTE_IF_SET_IN_BITMAP (vi->solution, 0, i, bi)
5541 +       {
5542 +         fprintf (file, "%s ", get_varinfo (i)->name);
5543 +       }
5544 +      fprintf (file, "}\n");
5545 +    }
5546  }
5547  
5548  /* Print the points-to solution for VAR to stdout.  */
5549 @@ -4266,7 +4244,7 @@
5550        if (!could_have_pointers (t))
5551         continue;
5552        
5553 -      arg_id = get_id_for_tree (t);
5554 +      arg_id = get_vi_for_tree (t)->id;
5555  
5556        /* With flag_argument_noalias greater than two means that the incoming
5557           argument cannot alias anything except for itself so create a HEAP
5558 @@ -4276,11 +4254,10 @@
5559         {
5560           varinfo_t vi;
5561           tree heapvar = heapvar_lookup (t);
5562 -         unsigned int id;
5563           
5564           lhs.offset = 0;
5565           lhs.type = SCALAR;
5566 -         lhs.var  = get_id_for_tree (t);
5567 +         lhs.var  = get_vi_for_tree (t)->id;
5568           
5569           if (heapvar == NULL_TREE)
5570             {
5571 @@ -4291,11 +4268,11 @@
5572                 add_referenced_var (heapvar);
5573               heapvar_insert (t, heapvar);
5574             }
5575 -         id = get_id_for_tree (heapvar);
5576 -         vi = get_varinfo (id);
5577 +
5578 +         vi = get_vi_for_tree (heapvar);
5579           vi->is_artificial_var = 1;
5580           vi->is_heap_var = 1;
5581 -         rhs.var = id;
5582 +         rhs.var = vi->id;
5583           rhs.type = ADDRESSOF;
5584           rhs.offset = 0;
5585            for (p = get_varinfo (lhs.var); p; p = p->next)
5586 @@ -4409,8 +4386,8 @@
5587  bool
5588  find_what_p_points_to (tree p)
5589  {
5590 -  unsigned int id = 0;
5591    tree lookup_p = p;
5592 +  varinfo_t vi;
5593  
5594    if (!have_alias_info)
5595      return false;
5596 @@ -4422,10 +4399,10 @@
5597        && default_def (SSA_NAME_VAR (p)) == p)
5598      lookup_p = SSA_NAME_VAR (p);
5599  
5600 -  if (lookup_id_for_tree (lookup_p, &id))
5601 +  vi = lookup_vi_for_tree (lookup_p);
5602 +  if (vi)
5603      {
5604 -      varinfo_t vi = get_varinfo (id);
5605 -
5606 +      
5607        if (vi->is_artificial_var)
5608         return false;
5609  
5610 @@ -4447,7 +4424,7 @@
5611  
5612           /* This variable may have been collapsed, let's get the real
5613              variable.  */
5614 -         vi = get_varinfo (vi->node);
5615 +         vi = get_varinfo (find (vi->id));
5616           
5617           /* Translate artificial variables into SSA_NAME_PTR_INFO
5618              attributes.  */
5619 @@ -4506,13 +4483,16 @@
5620      {
5621        fprintf (outfile, "Stats:\n");
5622        fprintf (outfile, "Total vars:               %d\n", stats.total_vars);
5623 +      fprintf (outfile, "Non-pointer vars:          %d\n",
5624 +              stats.nonpointer_vars);
5625        fprintf (outfile, "Statically unified vars:  %d\n",
5626                stats.unified_vars_static);
5627 -      fprintf (outfile, "Collapsed vars:           %d\n", stats.collapsed_vars);
5628        fprintf (outfile, "Dynamically unified vars: %d\n",
5629                stats.unified_vars_dynamic);
5630        fprintf (outfile, "Iterations:               %d\n", stats.iterations);
5631        fprintf (outfile, "Number of edges:          %d\n", stats.num_edges);
5632 +      fprintf (outfile, "Number of implicit edges: %d\n",
5633 +              stats.num_implicit_edges);
5634      }
5635  
5636    for (i = 0; i < VEC_length (varinfo_t, varmap); i++)
5637 @@ -4540,8 +4520,8 @@
5638    /* Create the NULL variable, used to represent that a variable points
5639       to NULL.  */
5640    nothing_tree = create_tmp_var_raw (void_type_node, "NULL");
5641 -  var_nothing = new_var_info (nothing_tree, 0, "NULL", 0);
5642 -  insert_id_for_tree (nothing_tree, 0);
5643 +  var_nothing = new_var_info (nothing_tree, 0, "NULL");
5644 +  insert_vi_for_tree (nothing_tree, var_nothing);
5645    var_nothing->is_artificial_var = 1;
5646    var_nothing->offset = 0;
5647    var_nothing->size = ~0;
5648 @@ -4553,8 +4533,8 @@
5649    /* Create the ANYTHING variable, used to represent that a variable
5650       points to some unknown piece of memory.  */
5651    anything_tree = create_tmp_var_raw (void_type_node, "ANYTHING");
5652 -  var_anything = new_var_info (anything_tree, 1, "ANYTHING", 1); 
5653 -  insert_id_for_tree (anything_tree, 1);
5654 +  var_anything = new_var_info (anything_tree, 1, "ANYTHING"); 
5655 +  insert_vi_for_tree (anything_tree, var_anything);
5656    var_anything->is_artificial_var = 1;
5657    var_anything->size = ~0;
5658    var_anything->offset = 0;
5659 @@ -4573,7 +4553,6 @@
5660    rhs.type = ADDRESSOF;
5661    rhs.var = anything_id;
5662    rhs.offset = 0;
5663 -  var_anything->address_taken = true;
5664  
5665    /* This specifically does not use process_constraint because
5666       process_constraint ignores all anything = anything constraints, since all
5667 @@ -4583,14 +4562,14 @@
5668    /* Create the READONLY variable, used to represent that a variable
5669       points to readonly memory.  */
5670    readonly_tree = create_tmp_var_raw (void_type_node, "READONLY");
5671 -  var_readonly = new_var_info (readonly_tree, 2, "READONLY", 2);
5672 +  var_readonly = new_var_info (readonly_tree, 2, "READONLY");
5673    var_readonly->is_artificial_var = 1;
5674    var_readonly->offset = 0;
5675    var_readonly->size = ~0;
5676    var_readonly->fullsize = ~0;
5677    var_readonly->next = NULL;
5678    var_readonly->is_special_var = 1;
5679 -  insert_id_for_tree (readonly_tree, 2);
5680 +  insert_vi_for_tree (readonly_tree, var_readonly);
5681    readonly_id = 2;
5682    VEC_safe_push (varinfo_t, heap, varmap, var_readonly);
5683  
5684 @@ -4610,8 +4589,8 @@
5685    /* Create the INTEGER variable, used to represent that a variable points
5686       to an INTEGER.  */
5687    integer_tree = create_tmp_var_raw (void_type_node, "INTEGER");
5688 -  var_integer = new_var_info (integer_tree, 3, "INTEGER", 3);
5689 -  insert_id_for_tree (integer_tree, 3);
5690 +  var_integer = new_var_info (integer_tree, 3, "INTEGER");
5691 +  insert_vi_for_tree (integer_tree, var_integer);
5692    var_integer->is_artificial_var = 1;
5693    var_integer->size = ~0;
5694    var_integer->fullsize = ~0;
5695 @@ -4634,8 +4613,8 @@
5696    /* Create the ESCAPED_VARS variable used to represent variables that
5697       escape this function.  */
5698    escaped_vars_tree = create_tmp_var_raw (void_type_node, "ESCAPED_VARS");
5699 -  var_escaped_vars = new_var_info (escaped_vars_tree, 4, "ESCAPED_VARS", 4);
5700 -  insert_id_for_tree (escaped_vars_tree, 4);
5701 +  var_escaped_vars = new_var_info (escaped_vars_tree, 4, "ESCAPED_VARS");
5702 +  insert_vi_for_tree (escaped_vars_tree, var_escaped_vars);
5703    var_escaped_vars->is_artificial_var = 1;
5704    var_escaped_vars->size = ~0;
5705    var_escaped_vars->fullsize = ~0;
5706 @@ -4660,21 +4639,19 @@
5707  static void
5708  init_alias_vars (void)
5709  {
5710 -  bitmap_obstack_initialize (&ptabitmap_obstack);
5711 +  bitmap_obstack_initialize (&pta_obstack);
5712 +  bitmap_obstack_initialize (&oldpta_obstack);
5713    bitmap_obstack_initialize (&predbitmap_obstack);
5714  
5715 -  constraint_pool = create_alloc_pool ("Constraint pool", 
5716 +  constraint_pool = create_alloc_pool ("Constraint pool",
5717                                        sizeof (struct constraint), 30);
5718    variable_info_pool = create_alloc_pool ("Variable info pool",
5719                                           sizeof (struct variable_info), 30);
5720 -  constraint_edge_pool = create_alloc_pool ("Constraint edges",
5721 -                                           sizeof (struct constraint_edge), 30);
5722 -  
5723    constraints = VEC_alloc (constraint_t, heap, 8);
5724    varmap = VEC_alloc (varinfo_t, heap, 8);
5725 -  id_for_tree = htab_create (10, tree_id_hash, tree_id_eq, free);
5726 +  vi_for_tree = pointer_map_create ();
5727 +
5728    memset (&stats, 0, sizeof (stats));
5729 -
5730    init_base_vars ();
5731  }
5732  
5733 @@ -4777,6 +4754,43 @@
5734    VEC_free (ce_s, heap, rhsc);
5735  }
5736  
5737 +
5738 +/* Remove the REF and ADDRESS edges from GRAPH, as well as all the
5739 +   predecessor edges.  */
5740 +
5741 +static void
5742 +remove_preds_and_fake_succs (constraint_graph_t graph)
5743 +{
5744 +  unsigned int i;
5745 +
5746 +  /* Clear the implicit ref and address nodes from the successor
5747 +     lists.  */
5748 +  for (i = 0; i < FIRST_REF_NODE; i++)
5749 +    {
5750 +      if (graph->succs[i])
5751 +       bitmap_clear_range (graph->succs[i], FIRST_REF_NODE,
5752 +                           FIRST_REF_NODE * 2);
5753 +    }
5754 +
5755 +  /* Free the successor list for the non-ref nodes.  */
5756 +  for (i = FIRST_REF_NODE; i < graph->size; i++)
5757 +    {
5758 +      if (graph->succs[i])
5759 +       BITMAP_FREE (graph->succs[i]);
5760 +    }
5761 +
5762 +  /* Now reallocate the size of the successor list as, and blow away
5763 +     the predecessor bitmaps.  */
5764 +  graph->size = VEC_length (varinfo_t, varmap);
5765 +  graph->succs = xrealloc (graph->succs, graph->size * sizeof (bitmap));
5766 +
5767 +  free (graph->implicit_preds);
5768 +  graph->implicit_preds = NULL;
5769 +  free (graph->preds);
5770 +  graph->preds = NULL;
5771 +  bitmap_obstack_release (&predbitmap_obstack);
5772 +}
5773 +
5774  /* Create points-to sets for the current function.  See the comments
5775     at the start of the file for an algorithmic overview.  */
5776  
5777 @@ -4784,11 +4798,13 @@
5778  compute_points_to_sets (struct alias_info *ai)
5779  {
5780    basic_block bb;
5781 +  struct scc_info *si;
5782  
5783    timevar_push (TV_TREE_PTA);
5784  
5785    init_alias_vars ();
5786 -
5787 +  init_alias_heapvars ();
5788 +  
5789    intra_create_variable_infos ();
5790  
5791    /* Now walk all statements and derive aliases.  */
5792 @@ -4824,36 +4840,42 @@
5793         }
5794      }
5795  
5796 -  build_constraint_graph ();
5797  
5798    if (dump_file)
5799      {
5800        fprintf (dump_file, "Points-to analysis\n\nConstraints:\n\n");
5801        dump_constraints (dump_file);
5802      }
5803 -  
5804 +
5805    if (dump_file)
5806      fprintf (dump_file,
5807              "\nCollapsing static cycles and doing variable "
5808              "substitution:\n");
5809 -      
5810 -  find_and_collapse_graph_cycles (graph, false);
5811 -  perform_var_substitution (graph);
5812 -      
5813 +
5814 +  build_pred_graph ();
5815 +  si = perform_var_substitution (graph);
5816 +  move_complex_constraints (graph, si);
5817 +  free_var_substitution_info (si);
5818 +  
5819 +  build_succ_graph ();
5820 +  find_indirect_cycles (graph);
5821 +
5822 +  /* Implicit nodes and predecessors are no longer necessary at this
5823 +     point. */
5824 +  remove_preds_and_fake_succs (graph);
5825 +
5826    if (dump_file)
5827      fprintf (dump_file, "\nSolving graph:\n");
5828 -      
5829 +
5830    solve_graph (graph);
5831 -  
5832 +
5833    if (dump_file)
5834      dump_sa_points_to_info (dump_file);
5835 -  
5836    have_alias_info = true;
5837  
5838    timevar_pop (TV_TREE_PTA);
5839  }
5840  
5841 -
5842  /* Delete created points-to sets.  */
5843  
5844  void
5845 @@ -4861,33 +4883,27 @@
5846  {
5847    varinfo_t v;
5848    int i;
5849 -  
5850 -  htab_delete (id_for_tree);
5851 -  bitmap_obstack_release (&ptabitmap_obstack);
5852 -  bitmap_obstack_release (&predbitmap_obstack);
5853 +
5854 +  if (dump_file && (dump_flags & TDF_STATS))
5855 +    fprintf (dump_file, "Points to sets created:%d\n",
5856 +            stats.points_to_sets_created);
5857 +
5858 +  pointer_map_destroy (vi_for_tree);
5859 +  bitmap_obstack_release (&pta_obstack);
5860    VEC_free (constraint_t, heap, constraints);
5861 -  
5862 +
5863    for (i = 0; VEC_iterate (varinfo_t, varmap, i, v); i++)
5864 -    {
5865 -      /* Nonlocal vars may add more varinfos.  */
5866 -      if (i >= graph_size)
5867 -       break;
5868 +    VEC_free (constraint_t, heap, graph->complex[i]);
5869 +  free (graph->complex);
5870  
5871 -      VEC_free (constraint_edge_t, heap, graph->succs[i]);
5872 -      VEC_free (constraint_edge_t, heap, graph->preds[i]);
5873 -      VEC_free (constraint_t, heap, v->complex);
5874 -    }
5875 -  free (graph->zero_weight_preds);
5876 -  free (graph->zero_weight_succs);
5877 +  free (graph->rep);
5878    free (graph->succs);
5879 -  free (graph->preds);
5880 +  free (graph->indirect_cycles);
5881    free (graph);
5882  
5883    VEC_free (varinfo_t, heap, varmap);
5884    free_alloc_pool (variable_info_pool);
5885 -  free_alloc_pool (constraint_pool); 
5886 -  free_alloc_pool (constraint_edge_pool);
5887 -
5888 +  free_alloc_pool (constraint_pool);
5889    have_alias_info = false;
5890  }
5891  
5892 @@ -4905,6 +4921,7 @@
5893  static unsigned int
5894  ipa_pta_execute (void)
5895  {
5896 +#if 0
5897    struct cgraph_node *node;
5898    in_ipa_mode = 1;
5899    init_alias_heapvars ();
5900 @@ -4994,6 +5011,7 @@
5901    in_ipa_mode = 0;
5902    delete_alias_heapvars ();
5903    delete_points_to_sets ();
5904 +#endif
5905    return 0;
5906  }
5907    
5908 @@ -5018,8 +5036,9 @@
5909  void
5910  init_alias_heapvars (void)
5911  {
5912 -  heapvar_for_stmt = htab_create_ggc (11, tree_map_hash, tree_map_eq,
5913 -                                     NULL);
5914 +  if (!heapvar_for_stmt)
5915 +    heapvar_for_stmt = htab_create_ggc (11, tree_map_hash, tree_map_eq,
5916 +                                       NULL);
5917    nonlocal_all = NULL_TREE;
5918  }
5919  
5920 @@ -5028,7 +5047,7 @@
5921  {
5922    nonlocal_all = NULL_TREE;
5923    htab_delete (heapvar_for_stmt);
5924 +  heapvar_for_stmt = NULL;
5925  }
5926 -
5927    
5928  #include "gt-tree-ssa-structalias.h"
5929 Index: gcc/config/i386/i386.md
5930 ===================================================================
5931 --- gcc/config/i386/i386.md     (.../tags/gcc_4_2_0_release)    (revision 125292)
5932 +++ gcc/config/i386/i386.md     (.../branches/gcc-4_2-branch)   (revision 125292)
5933 @@ -4749,7 +4749,7 @@
5934  (define_insn "*addti3_1"
5935    [(set (match_operand:TI 0 "nonimmediate_operand" "=r,o")
5936         (plus:TI (match_operand:TI 1 "nonimmediate_operand" "%0,0")
5937 -                (match_operand:TI 2 "general_operand" "roiF,riF")))
5938 +                (match_operand:TI 2 "x86_64_general_operand" "roe,re")))
5939     (clobber (reg:CC FLAGS_REG))]
5940    "TARGET_64BIT && ix86_binary_operator_ok (PLUS, TImode, operands)"
5941    "#")
5942 @@ -4757,7 +4757,7 @@
5943  (define_split
5944    [(set (match_operand:TI 0 "nonimmediate_operand" "")
5945         (plus:TI (match_operand:TI 1 "nonimmediate_operand" "")
5946 -                (match_operand:TI 2 "general_operand" "")))
5947 +                (match_operand:TI 2 "x86_64_general_operand" "")))
5948     (clobber (reg:CC FLAGS_REG))]
5949    "TARGET_64BIT && reload_completed"
5950    [(parallel [(set (reg:CC FLAGS_REG) (unspec:CC [(match_dup 1) (match_dup 2)]
5951 @@ -6483,7 +6483,7 @@
5952  (define_insn "*subti3_1"
5953    [(set (match_operand:TI 0 "nonimmediate_operand" "=r,o")
5954         (minus:TI (match_operand:TI 1 "nonimmediate_operand" "0,0")
5955 -                 (match_operand:TI 2 "general_operand" "roiF,riF")))
5956 +                 (match_operand:TI 2 "x86_64_general_operand" "roe,re")))
5957     (clobber (reg:CC FLAGS_REG))]
5958    "TARGET_64BIT && ix86_binary_operator_ok (MINUS, TImode, operands)"
5959    "#")
5960 @@ -6491,7 +6491,7 @@
5961  (define_split
5962    [(set (match_operand:TI 0 "nonimmediate_operand" "")
5963         (minus:TI (match_operand:TI 1 "nonimmediate_operand" "")
5964 -                 (match_operand:TI 2 "general_operand" "")))
5965 +                 (match_operand:TI 2 "x86_64_general_operand" "")))
5966     (clobber (reg:CC FLAGS_REG))]
5967    "TARGET_64BIT && reload_completed"
5968    [(parallel [(set (reg:CC FLAGS_REG) (compare:CC (match_dup 1) (match_dup 2)))
5969 @@ -9326,7 +9326,7 @@
5970  
5971  (define_insn "*negti2_1"
5972    [(set (match_operand:TI 0 "nonimmediate_operand" "=ro")
5973 -       (neg:TI (match_operand:TI 1 "general_operand" "0")))
5974 +       (neg:TI (match_operand:TI 1 "nonimmediate_operand" "0")))
5975     (clobber (reg:CC FLAGS_REG))]
5976    "TARGET_64BIT
5977     && ix86_unary_operator_ok (NEG, TImode, operands)"
5978 @@ -9334,7 +9334,7 @@
5979  
5980  (define_split
5981    [(set (match_operand:TI 0 "nonimmediate_operand" "")
5982 -       (neg:TI (match_operand:TI 1 "general_operand" "")))
5983 +       (neg:TI (match_operand:TI 1 "nonimmediate_operand" "")))
5984     (clobber (reg:CC FLAGS_REG))]
5985    "TARGET_64BIT && reload_completed"
5986    [(parallel
5987 Index: gcc/config/i386/sse.md
5988 ===================================================================
5989 --- gcc/config/i386/sse.md      (.../tags/gcc_4_2_0_release)    (revision 125292)
5990 +++ gcc/config/i386/sse.md      (.../branches/gcc-4_2-branch)   (revision 125292)
5991 @@ -2055,11 +2055,11 @@
5992             (match_dup 1))
5993           (parallel [(const_int 0)
5994                      (const_int 2)])))]
5995 -  "TARGET_SSE3 && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
5996 +  "TARGET_SSE3 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
5997    "@
5998     movddup\t{%1, %0|%0, %1}
5999     #"
6000 -  [(set_attr "type" "sselog,ssemov")
6001 +  [(set_attr "type" "sselog1,ssemov")
6002     (set_attr "mode" "V2DF")])
6003  
6004  (define_split
6005 @@ -3494,9 +3494,10 @@
6006    "TARGET_SSE2 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
6007    "@
6008     movhps\t{%1, %0|%0, %1}
6009 -   psrldq\t{$4, %0|%0, 4}
6010 +   psrldq\t{$8, %0|%0, 8}
6011     movq\t{%H1, %0|%0, %H1}"
6012    [(set_attr "type" "ssemov,sseishft,ssemov")
6013 +   (set_attr "memory" "*,none,*")
6014     (set_attr "mode" "V2SF,TI,TI")])
6015  
6016  ;; Not sure this is ever used, but it doesn't hurt to have it. -aoliva
6017 Index: gcc/config/i386/i386.c
6018 ===================================================================
6019 --- gcc/config/i386/i386.c      (.../tags/gcc_4_2_0_release)    (revision 125292)
6020 +++ gcc/config/i386/i386.c      (.../branches/gcc-4_2-branch)   (revision 125292)
6021 @@ -15539,13 +15539,13 @@
6022    /* Access to the vec_extract patterns.  */
6023    ftype = build_function_type_list (double_type_node, V2DF_type_node,
6024                                     integer_type_node, NULL_TREE);
6025 -  def_builtin (MASK_SSE, "__builtin_ia32_vec_ext_v2df",
6026 +  def_builtin (MASK_SSE2, "__builtin_ia32_vec_ext_v2df",
6027                ftype, IX86_BUILTIN_VEC_EXT_V2DF);
6028  
6029    ftype = build_function_type_list (long_long_integer_type_node,
6030                                     V2DI_type_node, integer_type_node,
6031                                     NULL_TREE);
6032 -  def_builtin (MASK_SSE, "__builtin_ia32_vec_ext_v2di",
6033 +  def_builtin (MASK_SSE2, "__builtin_ia32_vec_ext_v2di",
6034                ftype, IX86_BUILTIN_VEC_EXT_V2DI);
6035  
6036    ftype = build_function_type_list (float_type_node, V4SF_type_node,
6037 @@ -15555,12 +15555,12 @@
6038  
6039    ftype = build_function_type_list (intSI_type_node, V4SI_type_node,
6040                                     integer_type_node, NULL_TREE);
6041 -  def_builtin (MASK_SSE, "__builtin_ia32_vec_ext_v4si",
6042 +  def_builtin (MASK_SSE2, "__builtin_ia32_vec_ext_v4si",
6043                ftype, IX86_BUILTIN_VEC_EXT_V4SI);
6044  
6045    ftype = build_function_type_list (intHI_type_node, V8HI_type_node,
6046                                     integer_type_node, NULL_TREE);
6047 -  def_builtin (MASK_SSE, "__builtin_ia32_vec_ext_v8hi",
6048 +  def_builtin (MASK_SSE2, "__builtin_ia32_vec_ext_v8hi",
6049                ftype, IX86_BUILTIN_VEC_EXT_V8HI);
6050  
6051    ftype = build_function_type_list (intHI_type_node, V4HI_type_node,
6052 @@ -15577,7 +15577,7 @@
6053    ftype = build_function_type_list (V8HI_type_node, V8HI_type_node,
6054                                     intHI_type_node,
6055                                     integer_type_node, NULL_TREE);
6056 -  def_builtin (MASK_SSE, "__builtin_ia32_vec_set_v8hi",
6057 +  def_builtin (MASK_SSE2, "__builtin_ia32_vec_set_v8hi",
6058                ftype, IX86_BUILTIN_VEC_SET_V8HI);
6059  
6060    ftype = build_function_type_list (V4HI_type_node, V4HI_type_node,
6061 Index: gcc/config/sh/sh.c
6062 ===================================================================
6063 --- gcc/config/sh/sh.c  (.../tags/gcc_4_2_0_release)    (revision 125292)
6064 +++ gcc/config/sh/sh.c  (.../branches/gcc-4_2-branch)   (revision 125292)
6065 @@ -5295,7 +5295,13 @@
6066               temp = scavenge_reg (&temps);
6067             }
6068           if (temp < 0 && live_regs_mask)
6069 -           temp = scavenge_reg (live_regs_mask);
6070 +           {
6071 +             HARD_REG_SET temps;
6072 +
6073 +             COPY_HARD_REG_SET (temps, *live_regs_mask);
6074 +             CLEAR_HARD_REG_BIT (temps, REGNO (reg));
6075 +             temp = scavenge_reg (&temps);
6076 +           }
6077           if (temp < 0)
6078             {
6079               rtx adj_reg, tmp_reg, mem;
6080 @@ -5344,6 +5350,9 @@
6081               emit_move_insn (adj_reg, mem);
6082               mem = gen_tmp_stack_mem (Pmode, gen_rtx_POST_INC (Pmode, reg));
6083               emit_move_insn (tmp_reg, mem);
6084 +             /* Tell flow the insns that pop r4/r5 aren't dead.  */
6085 +             emit_insn (gen_rtx_USE (VOIDmode, tmp_reg));
6086 +             emit_insn (gen_rtx_USE (VOIDmode, adj_reg));
6087               return;
6088             }
6089           const_reg = gen_rtx_REG (GET_MODE (reg), temp);
6090 @@ -8618,7 +8627,7 @@
6091        else if (TARGET_SH4
6092                && get_attr_type (insn) == TYPE_DYN_SHIFT
6093                && get_attr_any_int_load (dep_insn) == ANY_INT_LOAD_YES
6094 -              && reg_overlap_mentioned_p (SET_DEST (PATTERN (dep_insn)),
6095 +              && reg_overlap_mentioned_p (SET_DEST (single_set (dep_insn)),
6096                                            XEXP (SET_SRC (single_set (insn)),
6097                                                  1)))
6098         cost++;
6099 Index: gcc/config/sh/sh.md
6100 ===================================================================
6101 --- gcc/config/sh/sh.md (.../tags/gcc_4_2_0_release)    (revision 125292)
6102 +++ gcc/config/sh/sh.md (.../branches/gcc-4_2-branch)   (revision 125292)
6103 @@ -413,10 +413,12 @@
6104          (eq_attr "type" "jump")
6105          (cond [(eq_attr "med_branch_p" "yes")
6106                 (const_int 2)
6107 -               (and (eq (symbol_ref "GET_CODE (prev_nonnote_insn (insn))")
6108 -                         (symbol_ref "INSN"))
6109 -                     (eq (symbol_ref "INSN_CODE (prev_nonnote_insn (insn))")
6110 -                         (symbol_ref "code_for_indirect_jump_scratch")))
6111 +               (and (ne (symbol_ref "prev_nonnote_insn (insn)")
6112 +                        (const_int 0))
6113 +                    (and (eq (symbol_ref "GET_CODE (prev_nonnote_insn (insn))")
6114 +                             (symbol_ref "INSN"))
6115 +                         (eq (symbol_ref "INSN_CODE (prev_nonnote_insn (insn))")
6116 +                             (symbol_ref "code_for_indirect_jump_scratch"))))
6117                  (cond [(eq_attr "braf_branch_p" "yes")
6118                         (const_int 6)
6119                         (eq (symbol_ref "flag_pic") (const_int 0))
6120 @@ -750,54 +752,6 @@
6121     (set_attr "type" "arith3")])
6122  
6123  (define_insn "cmpeqsi_media"
6124 -  [(set (match_operand:DI 0 "register_operand" "=r")
6125 -       (eq:DI (match_operand:SI 1 "logical_operand" "%r")
6126 -              (match_operand:SI 2 "cmp_operand" "Nr")))]
6127 -  "TARGET_SHMEDIA"
6128 -  "cmpeq       %1, %N2, %0"
6129 -  [(set_attr "type" "cmp_media")])
6130 -
6131 -(define_insn "cmpeqdi_media"
6132 -  [(set (match_operand:DI 0 "register_operand" "=r")
6133 -       (eq:DI (match_operand:DI 1 "register_operand" "%r")
6134 -              (match_operand:DI 2 "cmp_operand" "Nr")))]
6135 -  "TARGET_SHMEDIA"
6136 -  "cmpeq       %1, %N2, %0"
6137 -  [(set_attr "type" "cmp_media")])
6138 -
6139 -(define_insn "cmpgtsi_media"
6140 -  [(set (match_operand:DI 0 "register_operand" "=r")
6141 -       (gt:DI (match_operand:SI 1 "cmp_operand" "Nr")
6142 -              (match_operand:SI 2 "cmp_operand" "rN")))]
6143 -  "TARGET_SHMEDIA"
6144 -  "cmpgt       %N1, %N2, %0"
6145 -  [(set_attr "type" "cmp_media")])
6146 -
6147 -(define_insn "cmpgtdi_media"
6148 -  [(set (match_operand:DI 0 "register_operand" "=r")
6149 -       (gt:DI (match_operand:DI 1 "arith_reg_or_0_operand" "Nr")
6150 -              (match_operand:DI 2 "arith_reg_or_0_operand" "rN")))]
6151 -  "TARGET_SHMEDIA"
6152 -  "cmpgt       %N1, %N2, %0"
6153 -  [(set_attr "type" "cmp_media")])
6154 -
6155 -(define_insn "cmpgtusi_media"
6156 -  [(set (match_operand:DI 0 "register_operand" "=r")
6157 -       (gtu:DI (match_operand:SI 1 "cmp_operand" "Nr")
6158 -               (match_operand:SI 2 "cmp_operand" "rN")))]
6159 -  "TARGET_SHMEDIA"
6160 -  "cmpgtu      %N1, %N2, %0"
6161 -  [(set_attr "type" "cmp_media")])
6162 -
6163 -(define_insn "cmpgtudi_media"
6164 -  [(set (match_operand:DI 0 "register_operand" "=r")
6165 -       (gtu:DI (match_operand:DI 1 "arith_reg_or_0_operand" "Nr")
6166 -               (match_operand:DI 2 "arith_reg_or_0_operand" "rN")))]
6167 -  "TARGET_SHMEDIA"
6168 -  "cmpgtu      %N1, %N2, %0"
6169 -  [(set_attr "type" "cmp_media")])
6170 -
6171 -(define_insn "cmpsieqsi_media"
6172    [(set (match_operand:SI 0 "register_operand" "=r")
6173         (eq:SI (match_operand:SI 1 "logical_operand" "%r")
6174                (match_operand:SI 2 "cmp_operand" "Nr")))]
6175 @@ -805,7 +759,7 @@
6176    "cmpeq       %1, %N2, %0"
6177    [(set_attr "type" "cmp_media")])
6178  
6179 -(define_insn "cmpsieqdi_media"
6180 +(define_insn "cmpeqdi_media"
6181    [(set (match_operand:SI 0 "register_operand" "=r")
6182         (eq:SI (match_operand:DI 1 "register_operand" "%r")
6183                (match_operand:DI 2 "cmp_operand" "Nr")))]
6184 @@ -813,7 +767,7 @@
6185    "cmpeq       %1, %N2, %0"
6186    [(set_attr "type" "cmp_media")])
6187  
6188 -(define_insn "cmpsigtsi_media"
6189 +(define_insn "cmpgtsi_media"
6190    [(set (match_operand:SI 0 "register_operand" "=r")
6191         (gt:SI (match_operand:SI 1 "cmp_operand" "Nr")
6192                (match_operand:SI 2 "cmp_operand" "rN")))]
6193 @@ -821,7 +775,7 @@
6194    "cmpgt       %N1, %N2, %0"
6195    [(set_attr "type" "cmp_media")])
6196  
6197 -(define_insn "cmpsigtdi_media"
6198 +(define_insn "cmpgtdi_media"
6199    [(set (match_operand:SI 0 "register_operand" "=r")
6200         (gt:SI (match_operand:DI 1 "arith_reg_or_0_operand" "Nr")
6201                (match_operand:DI 2 "arith_reg_or_0_operand" "rN")))]
6202 @@ -829,7 +783,7 @@
6203    "cmpgt       %N1, %N2, %0"
6204    [(set_attr "type" "cmp_media")])
6205  
6206 -(define_insn "cmpsigtusi_media"
6207 +(define_insn "cmpgtusi_media"
6208    [(set (match_operand:SI 0 "register_operand" "=r")
6209         (gtu:SI (match_operand:SI 1 "cmp_operand" "Nr")
6210                 (match_operand:SI 2 "cmp_operand" "rN")))]
6211 @@ -837,7 +791,7 @@
6212    "cmpgtu      %N1, %N2, %0"
6213    [(set_attr "type" "cmp_media")])
6214  
6215 -(define_insn "cmpsigtudi_media"
6216 +(define_insn "cmpgtudi_media"
6217    [(set (match_operand:SI 0 "register_operand" "=r")
6218         (gtu:SI (match_operand:DI 1 "arith_reg_or_0_operand" "Nr")
6219                 (match_operand:DI 2 "arith_reg_or_0_operand" "rN")))]
6220 @@ -846,13 +800,6 @@
6221    [(set_attr "type" "cmp_media")])
6222  
6223  ; These two patterns are for combine.
6224 -(define_insn "*cmpne0si_media"
6225 -  [(set (match_operand:DI 0 "register_operand" "=r")
6226 -       (ne:DI (match_operand:SI 1 "arith_reg_operand" "r") (const_int 0)))]
6227 -  "TARGET_SHMEDIA"
6228 -  "cmpgtu      %1,r63,%0"
6229 -  [(set_attr "type" "cmp_media")])
6230 -
6231  (define_insn "*cmpne0sisi_media"
6232    [(set (match_operand:SI 0 "register_operand" "=r")
6233         (ne:SI (match_operand:SI 1 "arith_reg_operand" "r") (const_int 0)))]
6234 @@ -1177,7 +1124,7 @@
6235  {
6236    emit_insn (gen_movsicc_false (operands[0], operands[1], operands[2],
6237                                 operands[3]));
6238 -  emit_insn (gen_cmpsigtusi_media (operands[5], operands[4], operands[0]));
6239 +  emit_insn (gen_cmpgtusi_media (operands[5], operands[4], operands[0]));
6240    emit_insn (gen_movsicc_false (operands[0], operands[5], operands[4],
6241                                 operands[0]));
6242    DONE;
6243 @@ -7200,7 +7147,7 @@
6244  }")
6245  
6246  (define_expand "bunordered"
6247 -  [(set (match_dup 1) (unordered:DI (match_dup 2) (match_dup 3)))
6248 +  [(set (match_dup 1) (unordered:SI (match_dup 2) (match_dup 3)))
6249     (set (pc)
6250         (if_then_else (ne (match_dup 1) (const_int 0))
6251                       (match_operand 0 "" "")
6252 @@ -7209,7 +7156,7 @@
6253    "
6254  {
6255    operands[0] = gen_rtx_LABEL_REF (Pmode, operands[0]);
6256 -  operands[1] = gen_reg_rtx (DImode);
6257 +  operands[1] = gen_reg_rtx (SImode);
6258    operands[2] = force_reg (GET_MODE (sh_compare_op0), sh_compare_op0);
6259    operands[3] = force_reg (GET_MODE (sh_compare_op1), sh_compare_op1);
6260  }")
6261 @@ -9112,6 +9059,8 @@
6262  {
6263    if (TARGET_SHMEDIA)
6264      {
6265 +      rtx reg;
6266 +
6267        sh_compare_op0 = force_reg (GET_MODE (sh_compare_op0), sh_compare_op0);
6268        if (sh_compare_op1 != const0_rtx)
6269         sh_compare_op1 = force_reg (GET_MODE (sh_compare_op1) == VOIDmode
6270 @@ -9126,26 +9075,26 @@
6271           switch (GET_MODE (sh_compare_op0))
6272             {
6273             case SImode:
6274 -             emit_insn (gen_cmpsieqsi_media (operands[0],
6275 +             emit_insn (gen_cmpeqsi_media (operands[0],
6276                                               sh_compare_op0, sh_compare_op1));
6277               break;
6278  
6279             case DImode:
6280 -             emit_insn (gen_cmpsieqdi_media (operands[0],
6281 +             emit_insn (gen_cmpeqdi_media (operands[0],
6282                                               sh_compare_op0, sh_compare_op1));
6283               break;
6284  
6285             case SFmode:
6286               if (! TARGET_SHMEDIA_FPU)
6287                 FAIL;
6288 -             emit_insn (gen_cmpsieqsf_media (operands[0],
6289 +             emit_insn (gen_cmpeqsf_media (operands[0],
6290                                               sh_compare_op0, sh_compare_op1));
6291               break;
6292  
6293             case DFmode:
6294               if (! TARGET_SHMEDIA_FPU)
6295                 FAIL;
6296 -             emit_insn (gen_cmpsieqdf_media (operands[0],
6297 +             emit_insn (gen_cmpeqdf_media (operands[0],
6298                                               sh_compare_op0, sh_compare_op1));
6299               break;
6300  
6301 @@ -9155,38 +9104,44 @@
6302           DONE;
6303         }
6304  
6305 -      if (GET_MODE (operands[0]) != DImode)
6306 -       operands[0] = gen_rtx_SUBREG (DImode, operands[0], 0);
6307 +      reg = operands[0];
6308 +      if (GET_MODE (operands[0]) != SImode)
6309 +       reg = no_new_pseudos ? gen_rtx_SUBREG (SImode, operands[0], 0)
6310 +                            : gen_reg_rtx (SImode);
6311  
6312        switch (GET_MODE (sh_compare_op0))
6313         {
6314         case SImode:
6315 -         emit_insn (gen_cmpeqsi_media (operands[0],
6316 +         emit_insn (gen_cmpeqsi_media (reg,
6317                                         sh_compare_op0, sh_compare_op1));
6318           break;
6319  
6320         case DImode:
6321 -         emit_insn (gen_cmpeqdi_media (operands[0],
6322 +         emit_insn (gen_cmpeqdi_media (reg,
6323                                         sh_compare_op0, sh_compare_op1));
6324           break;
6325  
6326         case SFmode:
6327           if (! TARGET_SHMEDIA_FPU)
6328             FAIL;
6329 -         emit_insn (gen_cmpeqsf_media (operands[0],
6330 +         emit_insn (gen_cmpeqsf_media (reg,
6331                                         sh_compare_op0, sh_compare_op1));
6332           break;
6333  
6334         case DFmode:
6335           if (! TARGET_SHMEDIA_FPU)
6336             FAIL;
6337 -         emit_insn (gen_cmpeqdf_media (operands[0],
6338 +         emit_insn (gen_cmpeqdf_media (reg,
6339                                         sh_compare_op0, sh_compare_op1));
6340           break;
6341  
6342         default:
6343           FAIL;
6344         }
6345 +
6346 +      if (GET_MODE (operands[0]) == DImode)
6347 +       emit_insn (gen_extendsidi2 (operands[0], reg));
6348 +
6349        DONE;
6350      }
6351    if (sh_expand_t_scc (EQ, operands[0]))
6352 @@ -9204,8 +9159,8 @@
6353  {
6354    if (TARGET_SHMEDIA)
6355      {
6356 -      if (GET_MODE (operands[0]) != DImode)
6357 -       operands[0] = gen_rtx_SUBREG (DImode, operands[0], 0);
6358 +      rtx reg;
6359 +
6360        sh_compare_op0 = force_reg (GET_MODE (sh_compare_op0), sh_compare_op0);
6361        if (sh_compare_op1 != const0_rtx)
6362         sh_compare_op1 = force_reg (GET_MODE (sh_compare_op1) == VOIDmode
6363 @@ -9213,35 +9168,44 @@
6364                                     : GET_MODE (sh_compare_op1),
6365                                     sh_compare_op1);
6366  
6367 +      reg = operands[0];
6368 +      if (GET_MODE (operands[0]) != SImode)
6369 +       reg = no_new_pseudos ? gen_rtx_SUBREG (SImode, operands[0], 0)
6370 +                            : gen_reg_rtx (SImode);
6371 +
6372        switch (GET_MODE (sh_compare_op0))
6373         {
6374         case SImode:
6375 -         emit_insn (gen_cmpgtsi_media (operands[0],
6376 +         emit_insn (gen_cmpgtsi_media (reg,
6377                                         sh_compare_op1, sh_compare_op0));
6378           break;
6379  
6380         case DImode:
6381 -         emit_insn (gen_cmpgtdi_media (operands[0],
6382 +         emit_insn (gen_cmpgtdi_media (reg,
6383                                         sh_compare_op1, sh_compare_op0));
6384           break;
6385  
6386         case SFmode:
6387           if (! TARGET_SHMEDIA_FPU)
6388             FAIL;
6389 -         emit_insn (gen_cmpgtsf_media (operands[0],
6390 +         emit_insn (gen_cmpgtsf_media (reg,
6391                                         sh_compare_op1, sh_compare_op0));
6392           break;
6393  
6394         case DFmode:
6395           if (! TARGET_SHMEDIA_FPU)
6396             FAIL;
6397 -         emit_insn (gen_cmpgtdf_media (operands[0],
6398 +         emit_insn (gen_cmpgtdf_media (reg,
6399                                         sh_compare_op1, sh_compare_op0));
6400           break;
6401  
6402         default:
6403           FAIL;
6404         }
6405 +
6406 +      if (GET_MODE (operands[0]) == DImode)
6407 +       emit_insn (gen_extendsidi2 (operands[0], reg));
6408 +
6409        DONE;
6410      }
6411    if (! currently_expanding_to_rtl)
6412 @@ -9258,8 +9222,8 @@
6413  
6414    if (TARGET_SHMEDIA)
6415      {
6416 -      if (GET_MODE (operands[0]) != DImode)
6417 -       operands[0] = gen_rtx_SUBREG (DImode, operands[0], 0);
6418 +      rtx reg;
6419 +
6420        sh_compare_op0 = force_reg (GET_MODE (sh_compare_op0), sh_compare_op0);
6421        if (sh_compare_op1 != const0_rtx)
6422         sh_compare_op1 = force_reg (GET_MODE (sh_compare_op1) == VOIDmode
6423 @@ -9267,45 +9231,54 @@
6424                                     : GET_MODE (sh_compare_op1),
6425                                     sh_compare_op1);
6426  
6427 +      reg = operands[0];
6428 +      if (GET_MODE (operands[0]) != SImode)
6429 +       reg = no_new_pseudos ? gen_rtx_SUBREG (SImode, operands[0], 0)
6430 +                            : gen_reg_rtx (SImode);
6431 +
6432        switch (GET_MODE (sh_compare_op0))
6433         {
6434         case SImode:
6435           {
6436 -           tmp = no_new_pseudos ? operands[0] : gen_reg_rtx (DImode);
6437 +           tmp = no_new_pseudos ? reg : gen_reg_rtx (SImode);
6438  
6439             emit_insn (gen_cmpgtsi_media (tmp,
6440                                           sh_compare_op0, sh_compare_op1));
6441 -           emit_insn (gen_cmpeqdi_media (operands[0], tmp, const0_rtx));
6442 +           emit_insn (gen_cmpeqdi_media (reg, tmp, const0_rtx));
6443             break;
6444           }
6445  
6446         case DImode:
6447           {
6448 -           tmp = no_new_pseudos ? operands[0] : gen_reg_rtx (DImode);
6449 +           tmp = no_new_pseudos ? reg : gen_reg_rtx (SImode);
6450  
6451             emit_insn (gen_cmpgtdi_media (tmp,
6452                                           sh_compare_op0, sh_compare_op1));
6453 -           emit_insn (gen_cmpeqdi_media (operands[0], tmp, const0_rtx));
6454 +           emit_insn (gen_cmpeqdi_media (reg, tmp, const0_rtx));
6455             break;
6456           }
6457  
6458         case SFmode:
6459           if (! TARGET_SHMEDIA_FPU)
6460             FAIL;
6461 -         emit_insn (gen_cmpgesf_media (operands[0],
6462 +         emit_insn (gen_cmpgesf_media (reg,
6463                                         sh_compare_op1, sh_compare_op0));
6464           break;
6465  
6466         case DFmode:
6467           if (! TARGET_SHMEDIA_FPU)
6468             FAIL;
6469 -         emit_insn (gen_cmpgedf_media (operands[0],
6470 +         emit_insn (gen_cmpgedf_media (reg,
6471                                         sh_compare_op1, sh_compare_op0));
6472           break;
6473  
6474         default:
6475           FAIL;
6476         }
6477 +
6478 +      if (GET_MODE (operands[0]) == DImode)
6479 +       emit_insn (gen_extendsidi2 (operands[0], reg));
6480 +
6481        DONE;
6482      }
6483  
6484 @@ -9323,8 +9296,12 @@
6485  {
6486    if (TARGET_SHMEDIA)
6487      {
6488 -      if (GET_MODE (operands[0]) != DImode)
6489 -       operands[0] = gen_rtx_SUBREG (DImode, operands[0], 0);
6490 +      rtx reg;
6491 +
6492 +      reg = operands[0];
6493 +      if (GET_MODE (operands[0]) != SImode)
6494 +       reg = no_new_pseudos ? gen_rtx_SUBREG (SImode, operands[0], 0)
6495 +                            : gen_reg_rtx (SImode);
6496        sh_compare_op0 = force_reg (GET_MODE (sh_compare_op0), sh_compare_op0);
6497        if (sh_compare_op1 != const0_rtx)
6498         sh_compare_op1 = force_reg (GET_MODE (sh_compare_op1) == VOIDmode
6499 @@ -9335,32 +9312,36 @@
6500        switch (GET_MODE (sh_compare_op0))
6501         {
6502         case SImode:
6503 -         emit_insn (gen_cmpgtsi_media (operands[0],
6504 +         emit_insn (gen_cmpgtsi_media (reg,
6505                                         sh_compare_op0, sh_compare_op1));
6506           break;
6507  
6508         case DImode:
6509 -         emit_insn (gen_cmpgtdi_media (operands[0],
6510 +         emit_insn (gen_cmpgtdi_media (reg,
6511                                         sh_compare_op0, sh_compare_op1));
6512           break;
6513  
6514         case SFmode:
6515           if (! TARGET_SHMEDIA_FPU)
6516             FAIL;
6517 -         emit_insn (gen_cmpgtsf_media (operands[0],
6518 +         emit_insn (gen_cmpgtsf_media (reg,
6519                                         sh_compare_op0, sh_compare_op1));
6520           break;
6521  
6522         case DFmode:
6523           if (! TARGET_SHMEDIA_FPU)
6524             FAIL;
6525 -         emit_insn (gen_cmpgtdf_media (operands[0],
6526 +         emit_insn (gen_cmpgtdf_media (reg,
6527                                         sh_compare_op0, sh_compare_op1));
6528           break;
6529  
6530         default:
6531           FAIL;
6532         }
6533 +
6534 +      if (GET_MODE (operands[0]) == DImode)
6535 +       emit_insn (gen_extendsidi2 (operands[0], reg));
6536 +
6537        DONE;
6538      }
6539    if (! currently_expanding_to_rtl)
6540 @@ -9376,12 +9357,15 @@
6541  {
6542    if (TARGET_SHMEDIA)
6543      {
6544 +      rtx reg;
6545        enum machine_mode mode = GET_MODE (sh_compare_op0);
6546  
6547        if ((mode) == VOIDmode)
6548         mode = GET_MODE (sh_compare_op1);
6549 -      if (GET_MODE (operands[0]) != DImode)
6550 -       operands[0] = gen_rtx_SUBREG (DImode, operands[0], 0);
6551 +      reg = operands[0];
6552 +      if (GET_MODE (operands[0]) != SImode)
6553 +       reg = no_new_pseudos ? gen_rtx_SUBREG (SImode, operands[0], 0)
6554 +                            : gen_reg_rtx (SImode);
6555        sh_compare_op0 = force_reg (mode, sh_compare_op0);
6556        if (sh_compare_op1 != const0_rtx)
6557         sh_compare_op1 = force_reg (mode, sh_compare_op1);
6558 @@ -9390,41 +9374,45 @@
6559         {
6560         case SImode:
6561           {
6562 -           rtx tmp = no_new_pseudos ? operands[0] : gen_reg_rtx (DImode);
6563 +           rtx tmp = no_new_pseudos ? reg : gen_reg_rtx (SImode);
6564  
6565             emit_insn (gen_cmpgtsi_media (tmp,
6566                                           sh_compare_op1, sh_compare_op0));
6567 -           emit_insn (gen_cmpeqdi_media (operands[0], tmp, const0_rtx));
6568 +           emit_insn (gen_cmpeqdi_media (reg, tmp, const0_rtx));
6569             break;
6570           }
6571  
6572         case DImode:
6573           {
6574 -           rtx tmp = no_new_pseudos ? operands[0] : gen_reg_rtx (DImode);
6575 +           rtx tmp = no_new_pseudos ? reg : gen_reg_rtx (SImode);
6576  
6577             emit_insn (gen_cmpgtdi_media (tmp,
6578                                           sh_compare_op1, sh_compare_op0));
6579 -           emit_insn (gen_cmpeqdi_media (operands[0], tmp, const0_rtx));
6580 +           emit_insn (gen_cmpeqdi_media (reg, tmp, const0_rtx));
6581             break;
6582           }
6583  
6584         case SFmode:
6585           if (! TARGET_SHMEDIA_FPU)
6586             FAIL;
6587 -         emit_insn (gen_cmpgesf_media (operands[0],
6588 +         emit_insn (gen_cmpgesf_media (reg,
6589                                         sh_compare_op0, sh_compare_op1));
6590           break;
6591  
6592         case DFmode:
6593           if (! TARGET_SHMEDIA_FPU)
6594             FAIL;
6595 -         emit_insn (gen_cmpgedf_media (operands[0],
6596 +         emit_insn (gen_cmpgedf_media (reg,
6597                                         sh_compare_op0, sh_compare_op1));
6598           break;
6599  
6600         default:
6601           FAIL;
6602         }
6603 +
6604 +      if (GET_MODE (operands[0]) == DImode)
6605 +       emit_insn (gen_extendsidi2 (operands[0], reg));
6606 +
6607        DONE;
6608      }
6609  
6610 @@ -9456,8 +9444,12 @@
6611  {
6612    if (TARGET_SHMEDIA)
6613      {
6614 -      if (GET_MODE (operands[0]) != DImode)
6615 -       operands[0] = gen_rtx_SUBREG (DImode, operands[0], 0);
6616 +      rtx reg;
6617 +
6618 +      reg = operands[0];
6619 +      if (GET_MODE (operands[0]) == DImode)
6620 +       reg = no_new_pseudos ? gen_rtx_SUBREG (SImode, operands[0], 0)
6621 +                            : gen_reg_rtx (SImode);
6622        sh_compare_op0 = force_reg (GET_MODE (sh_compare_op0), sh_compare_op0);
6623        if (sh_compare_op1 != const0_rtx)
6624         sh_compare_op1 = force_reg (GET_MODE (sh_compare_op1) == VOIDmode
6625 @@ -9465,8 +9457,11 @@
6626                                     : GET_MODE (sh_compare_op1),
6627                                     sh_compare_op1);
6628  
6629 -      emit_insn (gen_cmpgtudi_media (operands[0],
6630 +      emit_insn (gen_cmpgtudi_media (reg,
6631                                      sh_compare_op0, sh_compare_op1));
6632 +      if (GET_MODE (operands[0]) == DImode)
6633 +       emit_insn (gen_extendsidi2 (operands[0], reg));
6634 +
6635        DONE;
6636      }
6637    if (! currently_expanding_to_rtl)
6638 @@ -9482,8 +9477,12 @@
6639  {
6640    if (TARGET_SHMEDIA)
6641      {
6642 -      if (GET_MODE (operands[0]) != DImode)
6643 -       operands[0] = gen_rtx_SUBREG (DImode, operands[0], 0);
6644 +      rtx reg;
6645 +
6646 +      reg = operands[0];
6647 +      if (GET_MODE (operands[0]) == DImode)
6648 +       reg = no_new_pseudos ? gen_rtx_SUBREG (SImode, operands[0], 0)
6649 +                            : gen_reg_rtx (SImode);
6650        sh_compare_op0 = force_reg (GET_MODE (sh_compare_op0), sh_compare_op0);
6651        if (sh_compare_op1 != const0_rtx)
6652         sh_compare_op1 = force_reg (GET_MODE (sh_compare_op1) == VOIDmode
6653 @@ -9491,8 +9490,11 @@
6654                                     : GET_MODE (sh_compare_op1),
6655                                     sh_compare_op1);
6656  
6657 -      emit_insn (gen_cmpgtudi_media (operands[0],
6658 +      emit_insn (gen_cmpgtudi_media (reg,
6659                                      sh_compare_op1, sh_compare_op0));
6660 +      if (GET_MODE (operands[0]) == DImode)
6661 +       emit_insn (gen_extendsidi2 (operands[0], reg));
6662 +
6663        DONE;
6664      }
6665    if (! currently_expanding_to_rtl)
6666 @@ -9508,10 +9510,12 @@
6667  {
6668    if (TARGET_SHMEDIA)
6669      {
6670 -      rtx tmp;
6671 +      rtx tmp, reg;
6672  
6673 -      if (GET_MODE (operands[0]) != DImode)
6674 -       operands[0] = gen_rtx_SUBREG (DImode, operands[0], 0);
6675 +      reg = operands[0];
6676 +      if (GET_MODE (operands[0]) != SImode)
6677 +       reg = no_new_pseudos ? gen_rtx_SUBREG (SImode, operands[0], 0)
6678 +                            : gen_reg_rtx (SImode);
6679        sh_compare_op0 = force_reg (GET_MODE (sh_compare_op0), sh_compare_op0);
6680        if (sh_compare_op1 != const0_rtx)
6681         sh_compare_op1 = force_reg (GET_MODE (sh_compare_op1) == VOIDmode
6682 @@ -9519,10 +9523,12 @@
6683                                     : GET_MODE (sh_compare_op1),
6684                                     sh_compare_op1);
6685  
6686 -      tmp = no_new_pseudos ? operands[0] : gen_reg_rtx (DImode);
6687 +      tmp = no_new_pseudos ? reg : gen_reg_rtx (SImode);
6688  
6689        emit_insn (gen_cmpgtudi_media (tmp, sh_compare_op0, sh_compare_op1));
6690 -      emit_insn (gen_cmpeqdi_media (operands[0], tmp, const0_rtx));
6691 +      emit_insn (gen_cmpeqdi_media (reg, tmp, const0_rtx));
6692 +      if (GET_MODE (operands[0]) == DImode)
6693 +       emit_insn (gen_extendsidi2 (operands[0], reg));
6694  
6695        DONE;
6696      }
6697 @@ -9539,10 +9545,12 @@
6698  {
6699    if (TARGET_SHMEDIA)
6700      {
6701 -      rtx tmp;
6702 +      rtx tmp, reg;
6703  
6704 -      if (GET_MODE (operands[0]) != DImode)
6705 -       operands[0] = gen_rtx_SUBREG (DImode, operands[0], 0);
6706 +      reg = operands[0];
6707 +      if (GET_MODE (operands[0]) != SImode)
6708 +       reg = no_new_pseudos ? gen_rtx_SUBREG (SImode, operands[0], 0)
6709 +                            : gen_reg_rtx (SImode);
6710        sh_compare_op0 = force_reg (GET_MODE (sh_compare_op0), sh_compare_op0);
6711        if (sh_compare_op1 != const0_rtx)
6712         sh_compare_op1 = force_reg (GET_MODE (sh_compare_op1) == VOIDmode
6713 @@ -9550,10 +9558,12 @@
6714                                     : GET_MODE (sh_compare_op1),
6715                                     sh_compare_op1);
6716  
6717 -      tmp = no_new_pseudos ? operands[0] : gen_reg_rtx (DImode);
6718 +      tmp = no_new_pseudos ? operands[0] : gen_reg_rtx (SImode);
6719  
6720        emit_insn (gen_cmpgtudi_media (tmp, sh_compare_op1, sh_compare_op0));
6721 -      emit_insn (gen_cmpeqdi_media (operands[0], tmp, const0_rtx));
6722 +      emit_insn (gen_cmpeqdi_media (reg, tmp, const0_rtx));
6723 +      if (GET_MODE (operands[0]) == DImode)
6724 +       emit_insn (gen_extendsidi2 (operands[0], reg));
6725  
6726        DONE;
6727      }
6728 @@ -9584,11 +9594,12 @@
6729  {
6730    if (TARGET_SHMEDIA)
6731      {
6732 -      rtx tmp;
6733 +      rtx tmp, reg;
6734  
6735 -      if (GET_MODE (operands[0]) != DImode)
6736 -       operands[0] = gen_rtx_SUBREG (DImode, operands[0], 0);
6737 -
6738 +      reg = operands[0];
6739 +      if (GET_MODE (operands[0]) != SImode)
6740 +       reg = no_new_pseudos ? gen_rtx_SUBREG (SImode, operands[0], 0)
6741 +                            : gen_reg_rtx (SImode);
6742        if (! TARGET_SHMEDIA_FPU
6743           && GET_MODE (sh_compare_op0) != DImode
6744           && GET_MODE (sh_compare_op0) != SImode)
6745 @@ -9601,10 +9612,12 @@
6746                                     : GET_MODE (sh_compare_op1),
6747                                     sh_compare_op1);
6748  
6749 -      tmp = no_new_pseudos ? operands[0] : gen_reg_rtx (DImode);
6750 +      tmp = no_new_pseudos ? reg : gen_reg_rtx (SImode);
6751  
6752        emit_insn (gen_seq (tmp));
6753 -      emit_insn (gen_cmpeqdi_media (operands[0], tmp, const0_rtx));
6754 +      emit_insn (gen_cmpeqdi_media (reg, tmp, const0_rtx));
6755 +      if (GET_MODE (operands[0]) == DImode)
6756 +       emit_insn (gen_extendsidi2 (operands[0], reg));
6757  
6758        DONE;
6759      }
6760 @@ -9618,8 +9631,8 @@
6761  }")
6762  
6763  (define_expand "sunordered"
6764 -  [(set (match_operand:DI 0 "arith_reg_operand" "")
6765 -       (unordered:DI (match_dup 1) (match_dup 2)))]
6766 +  [(set (match_operand:SI 0 "arith_reg_operand" "")
6767 +       (unordered:SI (match_dup 1) (match_dup 2)))]
6768    "TARGET_SHMEDIA_FPU"
6769    "
6770  {
6771 @@ -10378,14 +10391,6 @@
6772     (set_attr "fp_mode" "single")])
6773  
6774  (define_insn "cmpeqsf_media"
6775 -  [(set (match_operand:DI 0 "register_operand" "=r")
6776 -       (eq:DI (match_operand:SF 1 "fp_arith_reg_operand" "f")
6777 -              (match_operand:SF 2 "fp_arith_reg_operand" "f")))]
6778 -  "TARGET_SHMEDIA_FPU"
6779 -  "fcmpeq.s    %1, %2, %0"
6780 -  [(set_attr "type" "fcmp_media")])
6781 -
6782 -(define_insn "cmpsieqsf_media"
6783    [(set (match_operand:SI 0 "register_operand" "=r")
6784         (eq:SI (match_operand:SF 1 "fp_arith_reg_operand" "f")
6785                (match_operand:SF 2 "fp_arith_reg_operand" "f")))]
6786 @@ -10394,24 +10399,24 @@
6787    [(set_attr "type" "fcmp_media")])
6788  
6789  (define_insn "cmpgtsf_media"
6790 -  [(set (match_operand:DI 0 "register_operand" "=r")
6791 -       (gt:DI (match_operand:SF 1 "fp_arith_reg_operand" "f")
6792 +  [(set (match_operand:SI 0 "register_operand" "=r")
6793 +       (gt:SI (match_operand:SF 1 "fp_arith_reg_operand" "f")
6794                (match_operand:SF 2 "fp_arith_reg_operand" "f")))]
6795    "TARGET_SHMEDIA_FPU"
6796    "fcmpgt.s    %1, %2, %0"
6797    [(set_attr "type" "fcmp_media")])
6798  
6799  (define_insn "cmpgesf_media"
6800 -  [(set (match_operand:DI 0 "register_operand" "=r")
6801 -       (ge:DI (match_operand:SF 1 "fp_arith_reg_operand" "f")
6802 +  [(set (match_operand:SI 0 "register_operand" "=r")
6803 +       (ge:SI (match_operand:SF 1 "fp_arith_reg_operand" "f")
6804                (match_operand:SF 2 "fp_arith_reg_operand" "f")))]
6805    "TARGET_SHMEDIA_FPU"
6806    "fcmpge.s    %1, %2, %0"
6807    [(set_attr "type" "fcmp_media")])
6808  
6809  (define_insn "cmpunsf_media"
6810 -  [(set (match_operand:DI 0 "register_operand" "=r")
6811 -       (unordered:DI (match_operand:SF 1 "fp_arith_reg_operand" "f")
6812 +  [(set (match_operand:SI 0 "register_operand" "=r")
6813 +       (unordered:SI (match_operand:SF 1 "fp_arith_reg_operand" "f")
6814                       (match_operand:SF 2 "fp_arith_reg_operand" "f")))]
6815    "TARGET_SHMEDIA_FPU"
6816    "fcmpun.s    %1, %2, %0"
6817 @@ -10884,14 +10889,6 @@
6818     (set_attr "fp_mode" "double")])
6819  
6820  (define_insn "cmpeqdf_media"
6821 -  [(set (match_operand:DI 0 "register_operand" "=r")
6822 -       (eq:DI (match_operand:DF 1 "fp_arith_reg_operand" "f")
6823 -              (match_operand:DF 2 "fp_arith_reg_operand" "f")))]
6824 -  "TARGET_SHMEDIA_FPU"
6825 -  "fcmpeq.d    %1,%2,%0"
6826 -  [(set_attr "type" "fcmp_media")])
6827 -
6828 -(define_insn "cmpsieqdf_media"
6829    [(set (match_operand:SI 0 "register_operand" "=r")
6830         (eq:SI (match_operand:DF 1 "fp_arith_reg_operand" "f")
6831                (match_operand:DF 2 "fp_arith_reg_operand" "f")))]
6832 @@ -10900,24 +10897,24 @@
6833    [(set_attr "type" "fcmp_media")])
6834  
6835  (define_insn "cmpgtdf_media"
6836 -  [(set (match_operand:DI 0 "register_operand" "=r")
6837 -       (gt:DI (match_operand:DF 1 "fp_arith_reg_operand" "f")
6838 +  [(set (match_operand:SI 0 "register_operand" "=r")
6839 +       (gt:SI (match_operand:DF 1 "fp_arith_reg_operand" "f")
6840                (match_operand:DF 2 "fp_arith_reg_operand" "f")))]
6841    "TARGET_SHMEDIA_FPU"
6842    "fcmpgt.d    %1,%2,%0"
6843    [(set_attr "type" "fcmp_media")])
6844  
6845  (define_insn "cmpgedf_media"
6846 -  [(set (match_operand:DI 0 "register_operand" "=r")
6847 -       (ge:DI (match_operand:DF 1 "fp_arith_reg_operand" "f")
6848 +  [(set (match_operand:SI 0 "register_operand" "=r")
6849 +       (ge:SI (match_operand:DF 1 "fp_arith_reg_operand" "f")
6850                (match_operand:DF 2 "fp_arith_reg_operand" "f")))]
6851    "TARGET_SHMEDIA_FPU"
6852    "fcmpge.d    %1,%2,%0"
6853    [(set_attr "type" "fcmp_media")])
6854  
6855  (define_insn "cmpundf_media"
6856 -  [(set (match_operand:DI 0 "register_operand" "=r")
6857 -       (unordered:DI (match_operand:DF 1 "fp_arith_reg_operand" "f")
6858 +  [(set (match_operand:SI 0 "register_operand" "=r")
6859 +       (unordered:SI (match_operand:DF 1 "fp_arith_reg_operand" "f")
6860                       (match_operand:DF 2 "fp_arith_reg_operand" "f")))]
6861    "TARGET_SHMEDIA_FPU"
6862    "fcmpun.d    %1,%2,%0"
6863 Index: gcc/config/score/predicates.md
6864 ===================================================================
6865 --- gcc/config/score/predicates.md      (.../tags/gcc_4_2_0_release)    (revision 125292)
6866 +++ gcc/config/score/predicates.md      (.../branches/gcc-4_2-branch)   (revision 125292)
6867 @@ -75,14 +75,3 @@
6868    return IMM_IN_RANGE (INTVAL (op), 15, 1);
6869  })
6870  
6871 -(define_predicate "const_pow2"
6872 -  (match_code "const_int")
6873 -{
6874 -  return IMM_IS_POW_OF_2 ((unsigned HOST_WIDE_INT) INTVAL (op), 0, 31);
6875 -})
6876 -
6877 -(define_predicate "const_npow2"
6878 -  (match_code "const_int")
6879 -{
6880 -  return IMM_IS_POW_OF_2 (~(unsigned HOST_WIDE_INT) INTVAL (op), 0, 31);
6881 -})
6882 Index: gcc/config/score/misc.md
6883 ===================================================================
6884 --- gcc/config/score/misc.md    (.../tags/gcc_4_2_0_release)    (revision 125292)
6885 +++ gcc/config/score/misc.md    (.../branches/gcc-4_2-branch)   (revision 125292)
6886 @@ -380,38 +380,3 @@
6887    [(set_attr "type" "arith")
6888     (set_attr "mode" "SI")])
6889  
6890 -(define_insn "bitclr_c"
6891 -  [(set (match_operand:SI 0 "register_operand" "=e,d")
6892 -        (and:SI (match_operand:SI 1 "register_operand" "0,d")
6893 -                (match_operand:SI 2 "const_npow2")))
6894 -   (clobber (reg:CC CC_REGNUM))]
6895 -  ""
6896 -  "@
6897 -   bitclr!    %0, %F2
6898 -   bitclr.c   %0, %1, %F2"
6899 -  [(set_attr "type" "arith")
6900 -   (set_attr "mode" "SI")])
6901 -
6902 -(define_insn "bitset_c"
6903 -  [(set (match_operand:SI 0 "register_operand" "=e,d")
6904 -        (ior:SI (match_operand:SI 1 "register_operand" "0,d")
6905 -                (match_operand:SI 2 "const_pow2")))
6906 -   (clobber (reg:CC CC_REGNUM))]
6907 -  ""
6908 -  "@
6909 -   bitset!    %0, %E2
6910 -   bitset.c   %0, %1, %E2"
6911 -  [(set_attr "type" "arith")
6912 -   (set_attr "mode" "SI")])
6913 -
6914 -(define_insn "bittgl_c"
6915 -  [(set (match_operand:SI 0 "register_operand" "=e,d")
6916 -        (xor:SI (match_operand:SI 1 "register_operand" "0,d")
6917 -                (match_operand:SI 2 "const_pow2")))
6918 -   (clobber (reg:CC CC_REGNUM))]
6919 -  ""
6920 -  "@
6921 -   bittgl!    %0, %E2
6922 -   bittgl.c   %0, %1, %E2"
6923 -  [(set_attr "type" "arith")
6924 -   (set_attr "mode" "SI")])
6925 Index: gcc/config/score/score.c
6926 ===================================================================
6927 --- gcc/config/score/score.c    (.../tags/gcc_4_2_0_release)    (revision 125292)
6928 +++ gcc/config/score/score.c    (.../branches/gcc-4_2-branch)   (revision 125292)
6929 @@ -1168,7 +1168,7 @@
6930      {
6931        gcc_assert (code == CONST_INT);
6932        fprintf (file, HOST_WIDE_INT_PRINT_HEX,
6933 -               (unsigned HOST_WIDE_INT) INTVAL (op) >> 16);
6934 +               (INTVAL (op) >> 16) & 0xffff);
6935      }
6936    else if (c == 'D')
6937      {
6938 @@ -1176,7 +1176,7 @@
6939          {
6940            rtx temp = gen_lowpart (SImode, op);
6941            gcc_assert (GET_MODE (op) == SFmode);
6942 -          fprintf (file, HOST_WIDE_INT_PRINT_HEX, INTVAL (temp));
6943 +          fprintf (file, HOST_WIDE_INT_PRINT_HEX, INTVAL (temp) & 0xffffffff);
6944          }
6945        else
6946          output_addr_const (file, op);
6947 Index: gcc/config/score/score.h
6948 ===================================================================
6949 --- gcc/config/score/score.h    (.../tags/gcc_4_2_0_release)    (revision 125292)
6950 +++ gcc/config/score/score.h    (.../branches/gcc-4_2-branch)   (revision 125292)
6951 @@ -785,6 +785,7 @@
6952     output anything and let undefined symbol become external. However
6953     the assembler uses length information on externals to allocate in
6954     data/sdata bss/sbss, thereby saving exec time.  */
6955 +#undef ASM_OUTPUT_EXTERNAL
6956  #define ASM_OUTPUT_EXTERNAL(STREAM, DECL, NAME) \
6957    score_output_external (STREAM, DECL, NAME)
6958  
6959 Index: gcc/config/pa/pa.md
6960 ===================================================================
6961 --- gcc/config/pa/pa.md (.../tags/gcc_4_2_0_release)    (revision 125292)
6962 +++ gcc/config/pa/pa.md (.../branches/gcc-4_2-branch)   (revision 125292)
6963 @@ -39,6 +39,9 @@
6964     (UNSPEC_TLSLDBASE   7)
6965     (UNSPEC_TLSIE       8)
6966     (UNSPEC_TLSLE       9)
6967 +   (UNSPEC_TLSGD_PIC   10)
6968 +   (UNSPEC_TLSLDM_PIC  11)
6969 +   (UNSPEC_TLSIE_PIC   12)
6970    ])
6971  
6972  ;; UNSPEC_VOLATILE:
6973 @@ -9890,33 +9893,55 @@
6974  (define_insn "tgd_load"
6975   [(set (match_operand:SI 0 "register_operand" "=r")
6976         (unspec:SI [(match_operand 1 "tgd_symbolic_operand" "")] UNSPEC_TLSGD))
6977 -  (clobber (reg:SI 1))]
6978 +  (clobber (reg:SI 1))
6979 +  (use (reg:SI 27))]
6980    ""
6981    "*
6982  {
6983 -  if (flag_pic)
6984 -    return \"addil LT'%1-$tls_gdidx$,%%r19\;ldo RT'%1-$tls_gdidx$(%%r1),%0\";
6985 -  else
6986 -    return \"addil LR'%1-$tls_gdidx$,%%r27\;ldo RR'%1-$tls_gdidx$(%%r1),%0\";
6987 +  return \"addil LR'%1-$tls_gdidx$,%%r27\;ldo RR'%1-$tls_gdidx$(%%r1),%0\";
6988  }"
6989    [(set_attr "type" "multi")
6990     (set_attr "length" "8")])
6991  
6992 +(define_insn "tgd_load_pic"
6993 + [(set (match_operand:SI 0 "register_operand" "=r")
6994 +       (unspec:SI [(match_operand 1 "tgd_symbolic_operand" "")] UNSPEC_TLSGD_PIC))
6995 +  (clobber (reg:SI 1))
6996 +  (use (reg:SI 19))]
6997 +  ""
6998 +  "*
6999 +{
7000 +  return \"addil LT'%1-$tls_gdidx$,%%r19\;ldo RT'%1-$tls_gdidx$(%%r1),%0\";
7001 +}"
7002 +  [(set_attr "type" "multi")
7003 +   (set_attr "length" "8")])
7004 +
7005  (define_insn "tld_load"
7006   [(set (match_operand:SI 0 "register_operand" "=r")
7007         (unspec:SI [(match_operand 1 "tld_symbolic_operand" "")] UNSPEC_TLSLDM))
7008 -  (clobber (reg:SI 1))]
7009 +  (clobber (reg:SI 1))
7010 +  (use (reg:SI 27))]
7011    ""
7012    "*
7013  {
7014 -  if (flag_pic)
7015 -    return \"addil LT'%1-$tls_ldidx$,%%r19\;ldo RT'%1-$tls_ldidx$(%%r1),%0\";
7016 -  else
7017 -    return \"addil LR'%1-$tls_ldidx$,%%r27\;ldo RR'%1-$tls_ldidx$(%%r1),%0\";
7018 +  return \"addil LR'%1-$tls_ldidx$,%%r27\;ldo RR'%1-$tls_ldidx$(%%r1),%0\";
7019  }"
7020    [(set_attr "type" "multi")
7021     (set_attr "length" "8")])
7022  
7023 +(define_insn "tld_load_pic"
7024 + [(set (match_operand:SI 0 "register_operand" "=r")
7025 +       (unspec:SI [(match_operand 1 "tld_symbolic_operand" "")] UNSPEC_TLSLDM_PIC))
7026 +  (clobber (reg:SI 1))
7027 +  (use (reg:SI 19))]
7028 +  ""
7029 +  "*
7030 +{
7031 +  return \"addil LT'%1-$tls_ldidx$,%%r19\;ldo RT'%1-$tls_ldidx$(%%r1),%0\";
7032 +}"
7033 +  [(set_attr "type" "multi")
7034 +   (set_attr "length" "8")])
7035 +
7036  (define_insn "tld_offset_load"
7037    [(set (match_operand:SI 0 "register_operand" "=r")
7038          (plus:SI (unspec:SI [(match_operand 1 "tld_symbolic_operand" "")] 
7039 @@ -9942,18 +9967,29 @@
7040  (define_insn "tie_load"
7041    [(set (match_operand:SI 0 "register_operand" "=r")
7042          (unspec:SI [(match_operand 1 "tie_symbolic_operand" "")] UNSPEC_TLSIE))
7043 -   (clobber (reg:SI 1))]
7044 +   (clobber (reg:SI 1))
7045 +   (use (reg:SI 27))]
7046    ""
7047    "*
7048  {
7049 -  if (flag_pic)
7050 -    return \"addil LT'%1-$tls_ieoff$,%%r19\;ldw RT'%1-$tls_ieoff$(%%r1),%0\";
7051 -  else
7052 -    return \"addil LR'%1-$tls_ieoff$,%%r27\;ldw RR'%1-$tls_ieoff$(%%r1),%0\";
7053 +  return \"addil LR'%1-$tls_ieoff$,%%r27\;ldw RR'%1-$tls_ieoff$(%%r1),%0\";
7054  }"
7055    [(set_attr "type" "multi")
7056     (set_attr "length" "8")])
7057  
7058 +(define_insn "tie_load_pic"
7059 +  [(set (match_operand:SI 0 "register_operand" "=r")
7060 +        (unspec:SI [(match_operand 1 "tie_symbolic_operand" "")] UNSPEC_TLSIE_PIC))
7061 +   (clobber (reg:SI 1))
7062 +   (use (reg:SI 19))]
7063 +  ""
7064 +  "*
7065 +{
7066 +  return \"addil LT'%1-$tls_ieoff$,%%r19\;ldw RT'%1-$tls_ieoff$(%%r1),%0\";
7067 +}"
7068 +  [(set_attr "type" "multi")
7069 +   (set_attr "length" "8")])
7070 +
7071  (define_insn "tle_load"
7072    [(set (match_operand:SI 0 "register_operand" "=r")
7073          (plus:SI (unspec:SI [(match_operand 1 "tle_symbolic_operand" "")] 
7074 Index: gcc/config/pa/pa.c
7075 ===================================================================
7076 --- gcc/config/pa/pa.c  (.../tags/gcc_4_2_0_release)    (revision 125292)
7077 +++ gcc/config/pa/pa.c  (.../branches/gcc-4_2-branch)   (revision 125292)
7078 @@ -726,7 +726,10 @@
7079      {
7080        case TLS_MODEL_GLOBAL_DYNAMIC:
7081         tmp = gen_reg_rtx (Pmode);
7082 -       emit_insn (gen_tgd_load (tmp, addr));
7083 +       if (flag_pic)
7084 +         emit_insn (gen_tgd_load_pic (tmp, addr));
7085 +       else
7086 +         emit_insn (gen_tgd_load (tmp, addr));
7087         ret = hppa_tls_call (tmp);
7088         break;
7089  
7090 @@ -734,7 +737,10 @@
7091         ret = gen_reg_rtx (Pmode);
7092         tmp = gen_reg_rtx (Pmode);
7093         start_sequence ();
7094 -       emit_insn (gen_tld_load (tmp, addr));
7095 +       if (flag_pic)
7096 +         emit_insn (gen_tld_load_pic (tmp, addr));
7097 +       else
7098 +         emit_insn (gen_tld_load (tmp, addr));
7099         t1 = hppa_tls_call (tmp);
7100         insn = get_insns ();
7101         end_sequence ();
7102 @@ -750,7 +756,10 @@
7103         tmp = gen_reg_rtx (Pmode);
7104         ret = gen_reg_rtx (Pmode);
7105         emit_insn (gen_tp_load (tp));
7106 -       emit_insn (gen_tie_load (tmp, addr));
7107 +       if (flag_pic)
7108 +         emit_insn (gen_tie_load_pic (tmp, addr));
7109 +       else
7110 +         emit_insn (gen_tie_load (tmp, addr));
7111         emit_move_insn (ret, gen_rtx_PLUS (Pmode, tp, tmp));
7112         break;
7113  
7114 Index: gcc/config/soft-fp/quad.h
7115 ===================================================================
7116 --- gcc/config/soft-fp/quad.h   (.../tags/gcc_4_2_0_release)    (revision 125292)
7117 +++ gcc/config/soft-fp/quad.h   (.../branches/gcc-4_2-branch)   (revision 125292)
7118 @@ -1,6 +1,6 @@
7119  /* Software floating-point emulation.
7120     Definitions for IEEE Quad Precision.
7121 -   Copyright (C) 1997,1998,1999,2006 Free Software Foundation, Inc.
7122 +   Copyright (C) 1997,1998,1999,2006,2007 Free Software Foundation, Inc.
7123     This file is part of the GNU C Library.
7124     Contributed by Richard Henderson (rth@cygnus.com),
7125                   Jakub Jelinek (jj@ultra.linux.cz),
7126 @@ -176,15 +176,15 @@
7127    } longs;
7128    struct {
7129  #if __BYTE_ORDER == __BIG_ENDIAN
7130 -    unsigned sign  : 1;
7131 -    unsigned exp   : _FP_EXPBITS_Q;
7132 -    unsigned long frac1 : _FP_FRACBITS_Q-(_FP_IMPLBIT_Q != 0)-_FP_W_TYPE_SIZE;
7133 -    unsigned long frac0 : _FP_W_TYPE_SIZE;
7134 +    unsigned sign    : 1;
7135 +    unsigned exp     : _FP_EXPBITS_Q;
7136 +    _FP_W_TYPE frac1 : _FP_FRACBITS_Q - (_FP_IMPLBIT_Q != 0) - _FP_W_TYPE_SIZE;
7137 +    _FP_W_TYPE frac0 : _FP_W_TYPE_SIZE;
7138  #else
7139 -    unsigned long frac0 : _FP_W_TYPE_SIZE;
7140 -    unsigned long frac1 : _FP_FRACBITS_Q-(_FP_IMPLBIT_Q != 0)-_FP_W_TYPE_SIZE;
7141 -    unsigned exp   : _FP_EXPBITS_Q;
7142 -    unsigned sign  : 1;
7143 +    _FP_W_TYPE frac0 : _FP_W_TYPE_SIZE;
7144 +    _FP_W_TYPE frac1 : _FP_FRACBITS_Q - (_FP_IMPLBIT_Q != 0) - _FP_W_TYPE_SIZE;
7145 +    unsigned exp     : _FP_EXPBITS_Q;
7146 +    unsigned sign    : 1;
7147  #endif
7148    } bits;
7149  };
7150 Index: gcc/config/soft-fp/floatunsidf.c
7151 ===================================================================
7152 --- gcc/config/soft-fp/floatunsidf.c    (.../tags/gcc_4_2_0_release)    (revision 125292)
7153 +++ gcc/config/soft-fp/floatunsidf.c    (.../branches/gcc-4_2-branch)   (revision 125292)
7154 @@ -1,6 +1,6 @@
7155  /* Software floating-point emulation.
7156     Convert a 32bit unsigned integer to IEEE double
7157 -   Copyright (C) 1997,1999, 2006 Free Software Foundation, Inc.
7158 +   Copyright (C) 1997, 1999, 2006, 2007 Free Software Foundation, Inc.
7159     This file is part of the GNU C Library.
7160     Contributed by Richard Henderson (rth@cygnus.com) and
7161                   Jakub Jelinek (jj@ultra.linux.cz).
7162 @@ -32,8 +32,7 @@
7163  #include "soft-fp.h"
7164  #include "double.h"
7165  
7166 -double
7167 -__floatunsidf(USItype i)
7168 +DFtype __floatunsidf(USItype i)
7169  {
7170    FP_DECL_EX;
7171    FP_DECL_D(A);
7172 Index: gcc/config/soft-fp/floatundidf.c
7173 ===================================================================
7174 --- gcc/config/soft-fp/floatundidf.c    (.../tags/gcc_4_2_0_release)    (revision 125292)
7175 +++ gcc/config/soft-fp/floatundidf.c    (.../branches/gcc-4_2-branch)   (revision 125292)
7176 @@ -1,6 +1,6 @@
7177  /* Software floating-point emulation.
7178     Convert a 64bit unsigned integer to IEEE double
7179 -   Copyright (C) 1997,1999, 2006 Free Software Foundation, Inc.
7180 +   Copyright (C) 1997, 1999, 2006, 2007 Free Software Foundation, Inc.
7181     This file is part of the GNU C Library.
7182     Contributed by Richard Henderson (rth@cygnus.com) and
7183                   Jakub Jelinek (jj@ultra.linux.cz).
7184 @@ -32,8 +32,7 @@
7185  #include "soft-fp.h"
7186  #include "double.h"
7187  
7188 -double
7189 -__floatundidf(UDItype i)
7190 +DFtype __floatundidf(UDItype i)
7191  {
7192    FP_DECL_EX;
7193    FP_DECL_D(A);
7194 Index: gcc/config/soft-fp/extended.h
7195 ===================================================================
7196 --- gcc/config/soft-fp/extended.h       (.../tags/gcc_4_2_0_release)    (revision 125292)
7197 +++ gcc/config/soft-fp/extended.h       (.../branches/gcc-4_2-branch)   (revision 125292)
7198 @@ -1,6 +1,6 @@
7199  /* Software floating-point emulation.
7200     Definitions for IEEE Extended Precision.
7201 -   Copyright (C) 1999,2006 Free Software Foundation, Inc.
7202 +   Copyright (C) 1999,2006,2007 Free Software Foundation, Inc.
7203     This file is part of the GNU C Library.
7204     Contributed by Jakub Jelinek (jj@ultra.linux.cz).
7205  
7206 @@ -94,12 +94,6 @@
7207      X##_f[1] = _flo.bits.frac1;                                \
7208      X##_e  = _flo.bits.exp;                            \
7209      X##_s  = _flo.bits.sign;                           \
7210 -    if (!X##_e && (X##_f[1] || X##_f[0])               \
7211 -        && !(X##_f[1] & _FP_IMPLBIT_E))                        \
7212 -      {                                                        \
7213 -        X##_e++;                                       \
7214 -        FP_SET_EXCEPTION(FP_EX_DENORM);                        \
7215 -      }                                                        \
7216    } while (0)
7217  
7218  #define FP_UNPACK_RAW_EP(X, val)                       \
7219 @@ -112,12 +106,6 @@
7220      X##_f[1] = _flo->bits.frac1;                       \
7221      X##_e  = _flo->bits.exp;                           \
7222      X##_s  = _flo->bits.sign;                          \
7223 -    if (!X##_e && (X##_f[1] || X##_f[0])               \
7224 -        && !(X##_f[1] & _FP_IMPLBIT_E))                        \
7225 -      {                                                        \
7226 -        X##_e++;                                       \
7227 -        FP_SET_EXCEPTION(FP_EX_DENORM);                        \
7228 -      }                                                        \
7229    } while (0)
7230  
7231  #define FP_PACK_RAW_E(val, X)                          \
7232 @@ -164,13 +152,13 @@
7233  
7234  #define FP_UNPACK_SEMIRAW_E(X,val)     \
7235    do {                                 \
7236 -    _FP_UNPACK_RAW_E(X,val);           \
7237 +    FP_UNPACK_RAW_E(X,val);            \
7238      _FP_UNPACK_SEMIRAW(E,4,X);         \
7239    } while (0)
7240  
7241  #define FP_UNPACK_SEMIRAW_EP(X,val)    \
7242    do {                                 \
7243 -    _FP_UNPACK_RAW_EP(X,val);          \
7244 +    FP_UNPACK_RAW_EP(X,val);           \
7245      _FP_UNPACK_SEMIRAW(E,4,X);         \
7246    } while (0)
7247  
7248 @@ -189,13 +177,13 @@
7249  #define FP_PACK_SEMIRAW_E(val,X)       \
7250    do {                                 \
7251      _FP_PACK_SEMIRAW(E,4,X);           \
7252 -    _FP_PACK_RAW_E(val,X);             \
7253 +    FP_PACK_RAW_E(val,X);              \
7254    } while (0)
7255  
7256  #define FP_PACK_SEMIRAW_EP(val,X)      \
7257    do {                                 \
7258      _FP_PACK_SEMIRAW(E,4,X);           \
7259 -    _FP_PACK_RAW_EP(val,X);            \
7260 +    FP_PACK_RAW_EP(val,X);             \
7261    } while (0)
7262  
7263  #define FP_ISSIGNAN_E(X)       _FP_ISSIGNAN(E,4,X)
7264 @@ -277,14 +265,14 @@
7265    XFtype flt;
7266    struct {
7267  #if __BYTE_ORDER == __BIG_ENDIAN
7268 -    unsigned long pad : (_FP_W_TYPE_SIZE - 1 - _FP_EXPBITS_E);
7269 -    unsigned sign  : 1;
7270 -    unsigned exp   : _FP_EXPBITS_E;
7271 -    unsigned long frac : _FP_W_TYPE_SIZE;
7272 +    _FP_W_TYPE pad  : (_FP_W_TYPE_SIZE - 1 - _FP_EXPBITS_E);
7273 +    unsigned sign   : 1;
7274 +    unsigned exp    : _FP_EXPBITS_E;
7275 +    _FP_W_TYPE frac : _FP_W_TYPE_SIZE;
7276  #else
7277 -    unsigned long frac : _FP_W_TYPE_SIZE;
7278 -    unsigned exp   : _FP_EXPBITS_E;
7279 -    unsigned sign  : 1;
7280 +    _FP_W_TYPE frac : _FP_W_TYPE_SIZE;
7281 +    unsigned exp    : _FP_EXPBITS_E;
7282 +    unsigned sign   : 1;
7283  #endif
7284    } bits;
7285  };
7286 @@ -299,11 +287,6 @@
7287      X##_f1 = 0;                                                        \
7288      X##_e = _flo.bits.exp;                                     \
7289      X##_s = _flo.bits.sign;                                    \
7290 -    if (!X##_e && X##_f0 && !(X##_f0 & _FP_IMPLBIT_E))         \
7291 -      {                                                                \
7292 -        X##_e++;                                               \
7293 -        FP_SET_EXCEPTION(FP_EX_DENORM);                                \
7294 -      }                                                                \
7295    } while (0)
7296  
7297  #define FP_UNPACK_RAW_EP(X, val)                               \
7298 @@ -315,11 +298,6 @@
7299      X##_f1 = 0;                                                        \
7300      X##_e = _flo->bits.exp;                                    \
7301      X##_s = _flo->bits.sign;                                   \
7302 -    if (!X##_e && X##_f0 && !(X##_f0 & _FP_IMPLBIT_E))         \
7303 -      {                                                                \
7304 -        X##_e++;                                               \
7305 -        FP_SET_EXCEPTION(FP_EX_DENORM);                                \
7306 -      }                                                                \
7307    } while (0)
7308  
7309  #define FP_PACK_RAW_E(val, X)                                  \
7310 @@ -365,13 +343,13 @@
7311  
7312  #define FP_UNPACK_SEMIRAW_E(X,val)     \
7313    do {                                 \
7314 -    _FP_UNPACK_RAW_E(X,val);           \
7315 +    FP_UNPACK_RAW_E(X,val);            \
7316      _FP_UNPACK_SEMIRAW(E,2,X);         \
7317    } while (0)
7318  
7319  #define FP_UNPACK_SEMIRAW_EP(X,val)    \
7320    do {                                 \
7321 -    _FP_UNPACK_RAW_EP(X,val);          \
7322 +    FP_UNPACK_RAW_EP(X,val);           \
7323      _FP_UNPACK_SEMIRAW(E,2,X);         \
7324    } while (0)
7325  
7326 @@ -390,13 +368,13 @@
7327  #define FP_PACK_SEMIRAW_E(val,X)       \
7328    do {                                 \
7329      _FP_PACK_SEMIRAW(E,2,X);           \
7330 -    _FP_PACK_RAW_E(val,X);             \
7331 +    FP_PACK_RAW_E(val,X);              \
7332    } while (0)
7333  
7334  #define FP_PACK_SEMIRAW_EP(val,X)      \
7335    do {                                 \
7336      _FP_PACK_SEMIRAW(E,2,X);           \
7337 -    _FP_PACK_RAW_EP(val,X);            \
7338 +    FP_PACK_RAW_EP(val,X);             \
7339    } while (0)
7340  
7341  #define FP_ISSIGNAN_E(X)       _FP_ISSIGNAN(E,2,X)
7342 Index: gcc/config/soft-fp/floatunsisf.c
7343 ===================================================================
7344 --- gcc/config/soft-fp/floatunsisf.c    (.../tags/gcc_4_2_0_release)    (revision 125292)
7345 +++ gcc/config/soft-fp/floatunsisf.c    (.../branches/gcc-4_2-branch)   (revision 125292)
7346 @@ -1,6 +1,6 @@
7347  /* Software floating-point emulation.
7348     Convert a 32bit unsigned integer to IEEE single
7349 -   Copyright (C) 1997,1999, 2006 Free Software Foundation, Inc.
7350 +   Copyright (C) 1997, 1999, 2006, 2007 Free Software Foundation, Inc.
7351     This file is part of the GNU C Library.
7352     Contributed by Richard Henderson (rth@cygnus.com) and
7353                   Jakub Jelinek (jj@ultra.linux.cz).
7354 @@ -32,8 +32,7 @@
7355  #include "soft-fp.h"
7356  #include "single.h"
7357  
7358 -float
7359 -__floatunsisf(USItype i)
7360 +SFtype __floatunsisf(USItype i)
7361  {
7362    FP_DECL_EX;
7363    FP_DECL_S(A);
7364 Index: gcc/config/soft-fp/op-common.h
7365 ===================================================================
7366 --- gcc/config/soft-fp/op-common.h      (.../tags/gcc_4_2_0_release)    (revision 125292)
7367 +++ gcc/config/soft-fp/op-common.h      (.../branches/gcc-4_2-branch)   (revision 125292)
7368 @@ -1153,7 +1153,8 @@
7369    if (_FP_FRACBITS_##dfs < _FP_FRACBITS_##sfs                           \
7370        || (_FP_EXPMAX_##dfs - _FP_EXPBIAS_##dfs                          \
7371           < _FP_EXPMAX_##sfs - _FP_EXPBIAS_##sfs)                        \
7372 -      || _FP_EXPBIAS_##dfs < _FP_EXPBIAS_##sfs + _FP_FRACBITS_##sfs - 1) \
7373 +      || (_FP_EXPBIAS_##dfs < _FP_EXPBIAS_##sfs + _FP_FRACBITS_##sfs - 1 \
7374 +         && _FP_EXPBIAS_##dfs != _FP_EXPBIAS_##sfs))                    \
7375      abort();                                                            \
7376    D##_s = S##_s;                                                        \
7377    _FP_FRAC_COPY_##dwc##_##swc(D, S);                                    \
7378 @@ -1168,6 +1169,14 @@
7379         {                                                                \
7380           if (_FP_FRAC_ZEROP_##swc(S))                                   \
7381             D##_e = 0;                                                   \
7382 +         else if (_FP_EXPBIAS_##dfs                                     \
7383 +                  < _FP_EXPBIAS_##sfs + _FP_FRACBITS_##sfs - 1)         \
7384 +           {                                                            \
7385 +             FP_SET_EXCEPTION(FP_EX_DENORM);                            \
7386 +             _FP_FRAC_SLL_##dwc(D, (_FP_FRACBITS_##dfs                  \
7387 +                                    - _FP_FRACBITS_##sfs));             \
7388 +             D##_e = 0;                                                 \
7389 +           }                                                            \
7390           else                                                           \
7391             {                                                            \
7392               int _lz;                                                   \
7393 @@ -1199,7 +1208,8 @@
7394  #define FP_TRUNC(dfs,sfs,dwc,swc,D,S)                                       \
7395  do {                                                                        \
7396    if (_FP_FRACBITS_##sfs < _FP_FRACBITS_##dfs                               \
7397 -      || _FP_EXPBIAS_##sfs < _FP_EXPBIAS_##dfs + _FP_FRACBITS_##dfs - 1)     \
7398 +      || (_FP_EXPBIAS_##sfs < _FP_EXPBIAS_##dfs + _FP_FRACBITS_##dfs - 1     \
7399 +         && _FP_EXPBIAS_##sfs != _FP_EXPBIAS_##dfs))                        \
7400      abort();                                                                \
7401    D##_s = S##_s;                                                            \
7402    if (_FP_EXP_NORMAL(sfs, swc, S))                                          \
7403 @@ -1211,8 +1221,11 @@
7404         {                                                                    \
7405           if (D##_e <= 0)                                                    \
7406             {                                                                \
7407 -             if (D##_e <= 1 - _FP_FRACBITS_##dfs)                           \
7408 -               _FP_FRAC_SET_##swc(S, _FP_ZEROFRAC_##swc);                   \
7409 +             if (D##_e < 1 - _FP_FRACBITS_##dfs)                            \
7410 +               {                                                            \
7411 +                 _FP_FRAC_SET_##swc(S, _FP_ZEROFRAC_##swc);                 \
7412 +                 _FP_FRAC_LOW_##swc(S) |= 1;                                \
7413 +               }                                                            \
7414               else                                                           \
7415                 {                                                            \
7416                   _FP_FRAC_HIGH_##sfs(S) |= _FP_IMPLBIT_SH_##sfs;            \
7417 @@ -1234,11 +1247,24 @@
7418        if (S##_e == 0)                                                       \
7419         {                                                                    \
7420           D##_e = 0;                                                         \
7421 -         _FP_FRAC_SET_##dwc(D, _FP_ZEROFRAC_##dwc);                         \
7422 -         if (!_FP_FRAC_ZEROP_##swc(S))                                      \
7423 +         if (_FP_FRAC_ZEROP_##swc(S))                                       \
7424 +           _FP_FRAC_SET_##dwc(D, _FP_ZEROFRAC_##dwc);                       \
7425 +         else                                                               \
7426             {                                                                \
7427               FP_SET_EXCEPTION(FP_EX_DENORM);                                \
7428 -             FP_SET_EXCEPTION(FP_EX_INEXACT);                               \
7429 +             if (_FP_EXPBIAS_##sfs                                          \
7430 +                 < _FP_EXPBIAS_##dfs + _FP_FRACBITS_##dfs - 1)              \
7431 +               {                                                            \
7432 +                 _FP_FRAC_SRS_##swc(S, (_FP_WFRACBITS_##sfs                 \
7433 +                                        - _FP_WFRACBITS_##dfs),             \
7434 +                                    _FP_WFRACBITS_##sfs);                   \
7435 +                 _FP_FRAC_COPY_##dwc##_##swc(D, S);                         \
7436 +               }                                                            \
7437 +             else                                                           \
7438 +               {                                                            \
7439 +                 _FP_FRAC_SET_##dwc(D, _FP_ZEROFRAC_##dwc);                 \
7440 +                 _FP_FRAC_LOW_##dwc(D) |= 1;                                \
7441 +               }                                                            \
7442             }                                                                \
7443         }                                                                    \
7444        else                                                                  \
7445 Index: gcc/config/soft-fp/floatundisf.c
7446 ===================================================================
7447 --- gcc/config/soft-fp/floatundisf.c    (.../tags/gcc_4_2_0_release)    (revision 125292)
7448 +++ gcc/config/soft-fp/floatundisf.c    (.../branches/gcc-4_2-branch)   (revision 125292)
7449 @@ -1,6 +1,6 @@
7450  /* Software floating-point emulation.
7451     Convert a 64bit unsigned integer to IEEE single
7452 -   Copyright (C) 1997,1999, 2006 Free Software Foundation, Inc.
7453 +   Copyright (C) 1997, 1999, 2006, 2007 Free Software Foundation, Inc.
7454     This file is part of the GNU C Library.
7455     Contributed by Richard Henderson (rth@cygnus.com) and
7456                   Jakub Jelinek (jj@ultra.linux.cz).
7457 @@ -32,8 +32,7 @@
7458  #include "soft-fp.h"
7459  #include "single.h"
7460  
7461 -float
7462 -__floatundisf(UDItype i)
7463 +SFtype __floatundisf(UDItype i)
7464  {
7465    FP_DECL_EX;
7466    FP_DECL_S(A);
7467 Index: gcc/config/soft-fp/op-2.h
7468 ===================================================================
7469 --- gcc/config/soft-fp/op-2.h   (.../tags/gcc_4_2_0_release)    (revision 125292)
7470 +++ gcc/config/soft-fp/op-2.h   (.../branches/gcc-4_2-branch)   (revision 125292)
7471 @@ -1,6 +1,6 @@
7472  /* Software floating-point emulation.
7473     Basic two-word fraction declaration and manipulation.
7474 -   Copyright (C) 1997,1998,1999,2006 Free Software Foundation, Inc.
7475 +   Copyright (C) 1997,1998,1999,2006,2007 Free Software Foundation, Inc.
7476     This file is part of the GNU C Library.
7477     Contributed by Richard Henderson (rth@cygnus.com),
7478                   Jakub Jelinek (jj@ultra.linux.cz),
7479 @@ -613,3 +613,5 @@
7480  #define _FP_FRAC_COPY_1_2(D, S)                (D##_f = S##_f0)
7481  
7482  #define _FP_FRAC_COPY_2_1(D, S)                ((D##_f0 = S##_f), (D##_f1 = 0))
7483 +
7484 +#define _FP_FRAC_COPY_2_2(D,S)         _FP_FRAC_COPY_2(D,S)
7485 Index: gcc/config/soft-fp/op-4.h
7486 ===================================================================
7487 --- gcc/config/soft-fp/op-4.h   (.../tags/gcc_4_2_0_release)    (revision 125292)
7488 +++ gcc/config/soft-fp/op-4.h   (.../branches/gcc-4_2-branch)   (revision 125292)
7489 @@ -1,6 +1,6 @@
7490  /* Software floating-point emulation.
7491     Basic four-word fraction declaration and manipulation.
7492 -   Copyright (C) 1997,1998,1999,2006 Free Software Foundation, Inc.
7493 +   Copyright (C) 1997,1998,1999,2006,2007 Free Software Foundation, Inc.
7494     This file is part of the GNU C Library.
7495     Contributed by Richard Henderson (rth@cygnus.com),
7496                   Jakub Jelinek (jj@ultra.linux.cz),
7497 @@ -684,3 +684,5 @@
7498    D##_f[1] = S##_f1;                           \
7499    D##_f[2] = D##_f[3] = 0;                     \
7500  } while (0)
7501 +
7502 +#define _FP_FRAC_COPY_4_4(D,S) _FP_FRAC_COPY_4(D,S)
7503 Index: gcc/config/soft-fp/double.h
7504 ===================================================================
7505 --- gcc/config/soft-fp/double.h (.../tags/gcc_4_2_0_release)    (revision 125292)
7506 +++ gcc/config/soft-fp/double.h (.../branches/gcc-4_2-branch)   (revision 125292)
7507 @@ -1,6 +1,6 @@
7508  /* Software floating-point emulation.
7509     Definitions for IEEE Double Precision
7510 -   Copyright (C) 1997,1998,1999,2006 Free Software Foundation, Inc.
7511 +   Copyright (C) 1997,1998,1999,2006,2007 Free Software Foundation, Inc.
7512     This file is part of the GNU C Library.
7513     Contributed by Richard Henderson (rth@cygnus.com),
7514                   Jakub Jelinek (jj@ultra.linux.cz),
7515 @@ -168,13 +168,13 @@
7516    DFtype flt;
7517    struct {
7518  #if __BYTE_ORDER == __BIG_ENDIAN
7519 -    unsigned sign : 1;
7520 -    unsigned exp  : _FP_EXPBITS_D;
7521 -    unsigned long frac : _FP_FRACBITS_D - (_FP_IMPLBIT_D != 0);
7522 +    unsigned sign   : 1;
7523 +    unsigned exp    : _FP_EXPBITS_D;
7524 +    _FP_W_TYPE frac : _FP_FRACBITS_D - (_FP_IMPLBIT_D != 0);
7525  #else
7526 -    unsigned long frac : _FP_FRACBITS_D - (_FP_IMPLBIT_D != 0);
7527 -    unsigned exp  : _FP_EXPBITS_D;
7528 -    unsigned sign : 1;
7529 +    _FP_W_TYPE frac : _FP_FRACBITS_D - (_FP_IMPLBIT_D != 0);
7530 +    unsigned exp    : _FP_EXPBITS_D;
7531 +    unsigned sign   : 1;
7532  #endif
7533    } bits __attribute__((packed));
7534  };
7535 Index: libstdc++-v3/configure
7536 ===================================================================
7537 --- libstdc++-v3/configure      (.../tags/gcc_4_2_0_release)    (revision 125292)
7538 +++ libstdc++-v3/configure      (.../branches/gcc-4_2-branch)   (revision 125292)
7539 @@ -5764,8 +5764,6 @@
7540  
7541  
7542  
7543 -  echo "$as_me:$LINENO: checking for C locale to use" >&5
7544 -echo $ECHO_N "checking for C locale to use... $ECHO_C" >&6
7545     # Check whether --enable-clocale or --disable-clocale was given.
7546  if test "${enable_clocale+set}" = set; then
7547    enableval="$enable_clocale"
7548 @@ -5782,32 +5780,53 @@
7549  fi;
7550  
7551  
7552 -  # If they didn't use this option switch, or if they specified --enable
7553 -  # with no specific model, we'll have to look for one.  If they
7554 -  # specified --disable (???), do likewise.
7555 +  # Deal with gettext issues.  Default to not using it (=no) until we detect
7556 +  # support for it later.  Let the user turn it off via --e/d, but let that
7557 +  # default to on for easier handling.
7558 +  USE_NLS=no
7559 +  # Check whether --enable-nls or --disable-nls was given.
7560 +if test "${enable_nls+set}" = set; then
7561 +  enableval="$enable_nls"
7562 +
7563 +else
7564 +  enable_nls=yes
7565 +fi;
7566 +
7567 +  # Either a known packaage, or "auto"
7568    if test $enable_clocale = no || test $enable_clocale = yes; then
7569       enable_clocale=auto
7570    fi
7571 -
7572 -  # Either a known package, or "auto"
7573    enable_clocale_flag=$enable_clocale
7574  
7575 -  # Probe for locale support if no specific model is specified.
7576 +  # Probe for locale model to use if none specified.
7577    # Default to "generic".
7578    if test $enable_clocale_flag = auto; then
7579      case ${target_os} in
7580        linux* | gnu* | kfreebsd*-gnu | knetbsd*-gnu)
7581 -        cat >conftest.$ac_ext <<_ACEOF
7582 +        enable_clocale_flag=gnu
7583 +        ;;
7584 +      darwin* | freebsd*)
7585 +        enable_clocale_flag=darwin
7586 +       ;;
7587 +      *)
7588 +        enable_clocale_flag=generic
7589 +        ;;
7590 +    esac
7591 +  fi
7592 +
7593 +  # Sanity check model, and test for special functionality.
7594 +  if test $enable_clocale_flag = gnu; then
7595 +    cat >conftest.$ac_ext <<_ACEOF
7596  /* confdefs.h.  */
7597  _ACEOF
7598  cat confdefs.h >>conftest.$ac_ext
7599  cat >>conftest.$ac_ext <<_ACEOF
7600  /* end confdefs.h.  */
7601  
7602 -        #include <features.h>
7603 -        #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2)
7604 -          _GLIBCXX_ok
7605 -        #endif
7606 +    #include <features.h>
7607 +    #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2)
7608 +      _GLIBCXX_ok
7609 +    #endif
7610  
7611  _ACEOF
7612  if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
7613 @@ -5819,9 +5838,8 @@
7614  rm -f conftest*
7615  
7616  
7617 -        # Test for bugs early in glibc-2.2.x series
7618 -          if test $enable_clocale_flag = gnu; then
7619 -          if test "$cross_compiling" = yes; then
7620 +    # Test for bugs early in glibc-2.2.x series
7621 +    if test "$cross_compiling" = yes; then
7622    enable_clocale_flag=generic
7623  else
7624    cat >conftest.$ac_ext <<_ACEOF
7625 @@ -5831,28 +5849,28 @@
7626  cat >>conftest.$ac_ext <<_ACEOF
7627  /* end confdefs.h.  */
7628  
7629 -          #define _GNU_SOURCE 1
7630 -          #include <locale.h>
7631 -          #include <string.h>
7632 -          #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
7633 -          extern __typeof(newlocale) __newlocale;
7634 -          extern __typeof(duplocale) __duplocale;
7635 -          extern __typeof(strcoll_l) __strcoll_l;
7636 -          #endif
7637 -          int main()
7638 -          {
7639 -              const char __one[] = "Äuglein Augmen";
7640 -              const char __two[] = "Äuglein";
7641 -              int i;
7642 -              int j;
7643 -              __locale_t        loc;
7644 -               __locale_t        loc_dup;
7645 -              loc = __newlocale(1 << LC_ALL, "de_DE", 0);
7646 -              loc_dup = __duplocale(loc);
7647 -              i = __strcoll_l(__one, __two, loc);
7648 -              j = __strcoll_l(__one, __two, loc_dup);
7649 -              return 0;
7650 -          }
7651 +    #define _GNU_SOURCE 1
7652 +    #include <locale.h>
7653 +    #include <string.h>
7654 +    #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
7655 +    extern __typeof(newlocale) __newlocale;
7656 +    extern __typeof(duplocale) __duplocale;
7657 +    extern __typeof(strcoll_l) __strcoll_l;
7658 +    #endif
7659 +    int main()
7660 +    {
7661 +        const char __one[] = "Äuglein Augmen";
7662 +        const char __two[] = "Äuglein";
7663 +        int i;
7664 +        int j;
7665 +        __locale_t        loc;
7666 +        __locale_t        loc_dup;
7667 +        loc = __newlocale(1 << LC_ALL, "de_DE", 0);
7668 +        loc_dup = __duplocale(loc);
7669 +        i = __strcoll_l(__one, __two, loc);
7670 +        j = __strcoll_l(__one, __two, loc_dup);
7671 +        return 0;
7672 +    }
7673  
7674  _ACEOF
7675  rm -f conftest$ac_exeext
7676 @@ -5877,32 +5895,176 @@
7677  fi
7678  rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
7679  fi
7680 -          fi
7681  
7682 -        # ... at some point put __strxfrm_l tests in as well.
7683 -        ;;
7684 -      darwin* | freebsd*)
7685 -        enable_clocale_flag=darwin
7686 -       ;;
7687 -      *)
7688 -        enable_clocale_flag=generic
7689 -        ;;
7690 -    esac
7691 +    # Set it to scream when it hurts.
7692 +    ac_save_CFLAGS="$CFLAGS"
7693 +    CFLAGS="-Wimplicit-function-declaration -Werror"
7694 +
7695 +    # Use strxfrm_l if available.
7696 +    cat >conftest.$ac_ext <<_ACEOF
7697 +/* confdefs.h.  */
7698 +_ACEOF
7699 +cat confdefs.h >>conftest.$ac_ext
7700 +cat >>conftest.$ac_ext <<_ACEOF
7701 +/* end confdefs.h.  */
7702 +#define _GNU_SOURCE 1
7703 +                   #include <string.h>
7704 +                   #include <locale.h>
7705 +int
7706 +main ()
7707 +{
7708 +char s[128]; __locale_t loc; strxfrm_l(s, "C", 5, loc);
7709 +  ;
7710 +  return 0;
7711 +}
7712 +_ACEOF
7713 +rm -f conftest.$ac_objext
7714 +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
7715 +  (eval $ac_compile) 2>conftest.er1
7716 +  ac_status=$?
7717 +  grep -v '^ *+' conftest.er1 >conftest.err
7718 +  rm -f conftest.er1
7719 +  cat conftest.err >&5
7720 +  echo "$as_me:$LINENO: \$? = $ac_status" >&5
7721 +  (exit $ac_status); } &&
7722 +        { ac_try='test -z "$ac_c_werror_flag"
7723 +                        || test ! -s conftest.err'
7724 +  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
7725 +  (eval $ac_try) 2>&5
7726 +  ac_status=$?
7727 +  echo "$as_me:$LINENO: \$? = $ac_status" >&5
7728 +  (exit $ac_status); }; } &&
7729 +        { ac_try='test -s conftest.$ac_objext'
7730 +  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
7731 +  (eval $ac_try) 2>&5
7732 +  ac_status=$?
7733 +  echo "$as_me:$LINENO: \$? = $ac_status" >&5
7734 +  (exit $ac_status); }; }; then
7735 +
7736 +cat >>confdefs.h <<\_ACEOF
7737 +#define HAVE_STRXFRM_L 1
7738 +_ACEOF
7739 +
7740 +else
7741 +  echo "$as_me: failed program was:" >&5
7742 +sed 's/^/| /' conftest.$ac_ext >&5
7743 +
7744 +fi
7745 +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
7746 +
7747 +    # Use strerror_l if available.
7748 +    cat >conftest.$ac_ext <<_ACEOF
7749 +/* confdefs.h.  */
7750 +_ACEOF
7751 +cat confdefs.h >>conftest.$ac_ext
7752 +cat >>conftest.$ac_ext <<_ACEOF
7753 +/* end confdefs.h.  */
7754 +#define _GNU_SOURCE 1
7755 +                   #include <string.h>
7756 +                   #include <locale.h>
7757 +int
7758 +main ()
7759 +{
7760 +__locale_t loc; strerror_l(5, loc);
7761 +  ;
7762 +  return 0;
7763 +}
7764 +_ACEOF
7765 +rm -f conftest.$ac_objext
7766 +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
7767 +  (eval $ac_compile) 2>conftest.er1
7768 +  ac_status=$?
7769 +  grep -v '^ *+' conftest.er1 >conftest.err
7770 +  rm -f conftest.er1
7771 +  cat conftest.err >&5
7772 +  echo "$as_me:$LINENO: \$? = $ac_status" >&5
7773 +  (exit $ac_status); } &&
7774 +        { ac_try='test -z "$ac_c_werror_flag"
7775 +                        || test ! -s conftest.err'
7776 +  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
7777 +  (eval $ac_try) 2>&5
7778 +  ac_status=$?
7779 +  echo "$as_me:$LINENO: \$? = $ac_status" >&5
7780 +  (exit $ac_status); }; } &&
7781 +        { ac_try='test -s conftest.$ac_objext'
7782 +  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
7783 +  (eval $ac_try) 2>&5
7784 +  ac_status=$?
7785 +  echo "$as_me:$LINENO: \$? = $ac_status" >&5
7786 +  (exit $ac_status); }; }; then
7787 +
7788 +cat >>confdefs.h <<\_ACEOF
7789 +#define HAVE_STRERROR_L 1
7790 +_ACEOF
7791 +
7792 +else
7793 +  echo "$as_me: failed program was:" >&5
7794 +sed 's/^/| /' conftest.$ac_ext >&5
7795 +
7796 +fi
7797 +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
7798 +
7799 +    CFLAGS="$ac_save_CFLAGS"
7800    fi
7801  
7802 -  # Deal with gettext issues.  Default to not using it (=no) until we detect
7803 -  # support for it later.  Let the user turn it off via --e/d, but let that
7804 -  # default to on for easier handling.
7805 -  USE_NLS=no
7806 -  # Check whether --enable-nls or --disable-nls was given.
7807 -if test "${enable_nls+set}" = set; then
7808 -  enableval="$enable_nls"
7809 +  # Perhaps use strerror_r if available, and strerror_l isn't.
7810 +  ac_save_CFLAGS="$CFLAGS"
7811 +  CFLAGS="-Wimplicit-function-declaration -Werror"
7812 +  cat >conftest.$ac_ext <<_ACEOF
7813 +/* confdefs.h.  */
7814 +_ACEOF
7815 +cat confdefs.h >>conftest.$ac_ext
7816 +cat >>conftest.$ac_ext <<_ACEOF
7817 +/* end confdefs.h.  */
7818 +#define _GNU_SOURCE 1
7819 +                 #include <string.h>
7820 +                 #include <locale.h>
7821 +int
7822 +main ()
7823 +{
7824 +char s[128]; strerror_r(5, s, 128);
7825 +  ;
7826 +  return 0;
7827 +}
7828 +_ACEOF
7829 +rm -f conftest.$ac_objext
7830 +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
7831 +  (eval $ac_compile) 2>conftest.er1
7832 +  ac_status=$?
7833 +  grep -v '^ *+' conftest.er1 >conftest.err
7834 +  rm -f conftest.er1
7835 +  cat conftest.err >&5
7836 +  echo "$as_me:$LINENO: \$? = $ac_status" >&5
7837 +  (exit $ac_status); } &&
7838 +        { ac_try='test -z "$ac_c_werror_flag"
7839 +                        || test ! -s conftest.err'
7840 +  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
7841 +  (eval $ac_try) 2>&5
7842 +  ac_status=$?
7843 +  echo "$as_me:$LINENO: \$? = $ac_status" >&5
7844 +  (exit $ac_status); }; } &&
7845 +        { ac_try='test -s conftest.$ac_objext'
7846 +  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
7847 +  (eval $ac_try) 2>&5
7848 +  ac_status=$?
7849 +  echo "$as_me:$LINENO: \$? = $ac_status" >&5
7850 +  (exit $ac_status); }; }; then
7851  
7852 +cat >>confdefs.h <<\_ACEOF
7853 +#define HAVE_STRERROR_R 1
7854 +_ACEOF
7855 +
7856  else
7857 -  enable_nls=yes
7858 -fi;
7859 +  echo "$as_me: failed program was:" >&5
7860 +sed 's/^/| /' conftest.$ac_ext >&5
7861  
7862 +fi
7863 +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
7864 +  CFLAGS="$ac_save_CFLAGS"
7865 +
7866    # Set configure bits for specified locale package
7867 +  echo "$as_me:$LINENO: checking for C locale to use" >&5
7868 +echo $ECHO_N "checking for C locale to use... $ECHO_C" >&6
7869    case ${enable_clocale_flag} in
7870      generic)
7871        echo "$as_me:$LINENO: result: generic" >&5
7872 @@ -8015,7 +8177,7 @@
7873  
7874    # Fake what AC_TRY_COMPILE does.  XXX Look at redoing this new-style.
7875      cat > conftest.$ac_ext << EOF
7876 -#line 8018 "configure"
7877 +#line 8180 "configure"
7878  int main()
7879  {
7880    // NB: _Atomic_word not necessarily int.
7881 @@ -8395,11 +8557,9 @@
7882      # NB: This flag only works reliably after 2.16.1. Configure tests
7883      # for this are difficult, so hard wire a value that should work.
7884  
7885 -    # All these tests are for C++, but run with the "C" compiler driver.
7886 -    # Need to do this so that g++ won't try to link in libstdc++/libsupc++.
7887      ac_test_CFLAGS="${CFLAGS+set}"
7888      ac_save_CFLAGS="$CFLAGS"
7889 -    CFLAGS='-x c++ -Wl,--gc-sections'
7890 +    CFLAGS='-Wl,--gc-sections'
7891  
7892      # Check for -Wl,--gc-sections
7893      echo "$as_me:$LINENO: checking for ld that supports -Wl,--gc-sections" >&5
7894 @@ -54307,11 +54467,9 @@
7895      # NB: This flag only works reliably after 2.16.1. Configure tests
7896      # for this are difficult, so hard wire a value that should work.
7897  
7898 -    # All these tests are for C++, but run with the "C" compiler driver.
7899 -    # Need to do this so that g++ won't try to link in libstdc++/libsupc++.
7900      ac_test_CFLAGS="${CFLAGS+set}"
7901      ac_save_CFLAGS="$CFLAGS"
7902 -    CFLAGS='-x c++ -Wl,--gc-sections'
7903 +    CFLAGS='-Wl,--gc-sections'
7904  
7905      # Check for -Wl,--gc-sections
7906      echo "$as_me:$LINENO: checking for ld that supports -Wl,--gc-sections" >&5
7907 @@ -75669,11 +75827,9 @@
7908      # NB: This flag only works reliably after 2.16.1. Configure tests
7909      # for this are difficult, so hard wire a value that should work.
7910  
7911 -    # All these tests are for C++, but run with the "C" compiler driver.
7912 -    # Need to do this so that g++ won't try to link in libstdc++/libsupc++.
7913      ac_test_CFLAGS="${CFLAGS+set}"
7914      ac_save_CFLAGS="$CFLAGS"
7915 -    CFLAGS='-x c++ -Wl,--gc-sections'
7916 +    CFLAGS='-Wl,--gc-sections'
7917  
7918      # Check for -Wl,--gc-sections
7919      echo "$as_me:$LINENO: checking for ld that supports -Wl,--gc-sections" >&5
7920 @@ -77194,11 +77350,9 @@
7921      # NB: This flag only works reliably after 2.16.1. Configure tests
7922      # for this are difficult, so hard wire a value that should work.
7923  
7924 -    # All these tests are for C++, but run with the "C" compiler driver.
7925 -    # Need to do this so that g++ won't try to link in libstdc++/libsupc++.
7926      ac_test_CFLAGS="${CFLAGS+set}"
7927      ac_save_CFLAGS="$CFLAGS"
7928 -    CFLAGS='-x c++ -Wl,--gc-sections'
7929 +    CFLAGS='-Wl,--gc-sections'
7930  
7931      # Check for -Wl,--gc-sections
7932      echo "$as_me:$LINENO: checking for ld that supports -Wl,--gc-sections" >&5
7933 @@ -78687,11 +78841,9 @@
7934      # NB: This flag only works reliably after 2.16.1. Configure tests
7935      # for this are difficult, so hard wire a value that should work.
7936  
7937 -    # All these tests are for C++, but run with the "C" compiler driver.
7938 -    # Need to do this so that g++ won't try to link in libstdc++/libsupc++.
7939      ac_test_CFLAGS="${CFLAGS+set}"
7940      ac_save_CFLAGS="$CFLAGS"
7941 -    CFLAGS='-x c++ -Wl,--gc-sections'
7942 +    CFLAGS='-Wl,--gc-sections'
7943  
7944      # Check for -Wl,--gc-sections
7945      echo "$as_me:$LINENO: checking for ld that supports -Wl,--gc-sections" >&5
7946 @@ -100579,11 +100731,9 @@
7947      # NB: This flag only works reliably after 2.16.1. Configure tests
7948      # for this are difficult, so hard wire a value that should work.
7949  
7950 -    # All these tests are for C++, but run with the "C" compiler driver.
7951 -    # Need to do this so that g++ won't try to link in libstdc++/libsupc++.
7952      ac_test_CFLAGS="${CFLAGS+set}"
7953      ac_save_CFLAGS="$CFLAGS"
7954 -    CFLAGS='-x c++ -Wl,--gc-sections'
7955 +    CFLAGS='-Wl,--gc-sections'
7956  
7957      # Check for -Wl,--gc-sections
7958      echo "$as_me:$LINENO: checking for ld that supports -Wl,--gc-sections" >&5
7959 @@ -101426,11 +101576,9 @@
7960      # NB: This flag only works reliably after 2.16.1. Configure tests
7961      # for this are difficult, so hard wire a value that should work.
7962  
7963 -    # All these tests are for C++, but run with the "C" compiler driver.
7964 -    # Need to do this so that g++ won't try to link in libstdc++/libsupc++.
7965      ac_test_CFLAGS="${CFLAGS+set}"
7966      ac_save_CFLAGS="$CFLAGS"
7967 -    CFLAGS='-x c++ -Wl,--gc-sections'
7968 +    CFLAGS='-Wl,--gc-sections'
7969  
7970      # Check for -Wl,--gc-sections
7971      echo "$as_me:$LINENO: checking for ld that supports -Wl,--gc-sections" >&5
7972 @@ -102829,11 +102977,9 @@
7973      # NB: This flag only works reliably after 2.16.1. Configure tests
7974      # for this are difficult, so hard wire a value that should work.
7975  
7976 -    # All these tests are for C++, but run with the "C" compiler driver.
7977 -    # Need to do this so that g++ won't try to link in libstdc++/libsupc++.
7978      ac_test_CFLAGS="${CFLAGS+set}"
7979      ac_save_CFLAGS="$CFLAGS"
7980 -    CFLAGS='-x c++ -Wl,--gc-sections'
7981 +    CFLAGS='-Wl,--gc-sections'
7982  
7983      # Check for -Wl,--gc-sections
7984      echo "$as_me:$LINENO: checking for ld that supports -Wl,--gc-sections" >&5
7985 @@ -104624,11 +104770,9 @@
7986      # NB: This flag only works reliably after 2.16.1. Configure tests
7987      # for this are difficult, so hard wire a value that should work.
7988  
7989 -    # All these tests are for C++, but run with the "C" compiler driver.
7990 -    # Need to do this so that g++ won't try to link in libstdc++/libsupc++.
7991      ac_test_CFLAGS="${CFLAGS+set}"
7992      ac_save_CFLAGS="$CFLAGS"
7993 -    CFLAGS='-x c++ -Wl,--gc-sections'
7994 +    CFLAGS='-Wl,--gc-sections'
7995  
7996      # Check for -Wl,--gc-sections
7997      echo "$as_me:$LINENO: checking for ld that supports -Wl,--gc-sections" >&5
7998 @@ -105869,11 +106013,9 @@
7999      # NB: This flag only works reliably after 2.16.1. Configure tests
8000      # for this are difficult, so hard wire a value that should work.
8001  
8002 -    # All these tests are for C++, but run with the "C" compiler driver.
8003 -    # Need to do this so that g++ won't try to link in libstdc++/libsupc++.
8004      ac_test_CFLAGS="${CFLAGS+set}"
8005      ac_save_CFLAGS="$CFLAGS"
8006 -    CFLAGS='-x c++ -Wl,--gc-sections'
8007 +    CFLAGS='-Wl,--gc-sections'
8008  
8009      # Check for -Wl,--gc-sections
8010      echo "$as_me:$LINENO: checking for ld that supports -Wl,--gc-sections" >&5
8011 @@ -106898,11 +107040,9 @@
8012      # NB: This flag only works reliably after 2.16.1. Configure tests
8013      # for this are difficult, so hard wire a value that should work.
8014  
8015 -    # All these tests are for C++, but run with the "C" compiler driver.
8016 -    # Need to do this so that g++ won't try to link in libstdc++/libsupc++.
8017      ac_test_CFLAGS="${CFLAGS+set}"
8018      ac_save_CFLAGS="$CFLAGS"
8019 -    CFLAGS='-x c++ -Wl,--gc-sections'
8020 +    CFLAGS='-Wl,--gc-sections'
8021  
8022      # Check for -Wl,--gc-sections
8023      echo "$as_me:$LINENO: checking for ld that supports -Wl,--gc-sections" >&5
8024 Index: libstdc++-v3/include/bits/ostream.tcc
8025 ===================================================================
8026 --- libstdc++-v3/include/bits/ostream.tcc       (.../tags/gcc_4_2_0_release)    (revision 125292)
8027 +++ libstdc++-v3/include/bits/ostream.tcc       (.../branches/gcc-4_2-branch)   (revision 125292)
8028 @@ -334,7 +334,6 @@
8029    extern template ostream& operator<<(ostream&, const char*);
8030    extern template ostream& operator<<(ostream&, const unsigned char*);
8031    extern template ostream& operator<<(ostream&, const signed char*);
8032 -  extern template ostream& __ostream_insert(ostream&, const char*, streamsize);
8033  
8034    extern template ostream& ostream::_M_insert(long);
8035    extern template ostream& ostream::_M_insert(unsigned long);
8036 @@ -356,8 +355,6 @@
8037    extern template wostream& operator<<(wostream&, char);
8038    extern template wostream& operator<<(wostream&, const wchar_t*);
8039    extern template wostream& operator<<(wostream&, const char*);
8040 -  extern template wostream& __ostream_insert(wostream&, const wchar_t*,
8041 -                                            streamsize);
8042  
8043    extern template wostream& wostream::_M_insert(long);
8044    extern template wostream& wostream::_M_insert(unsigned long);
8045 Index: libstdc++-v3/include/bits/ostream_insert.h
8046 ===================================================================
8047 --- libstdc++-v3/include/bits/ostream_insert.h  (.../tags/gcc_4_2_0_release)    (revision 125292)
8048 +++ libstdc++-v3/include/bits/ostream_insert.h  (.../branches/gcc-4_2-branch)   (revision 125292)
8049 @@ -109,6 +109,18 @@
8050        return __out;
8051      }
8052  
8053 +  // Inhibit implicit instantiations for required instantiations,
8054 +  // which are defined via explicit instantiations elsewhere.
8055 +  // NB:  This syntax is a GNU extension.
8056 +#if _GLIBCXX_EXTERN_TEMPLATE
8057 +  extern template ostream& __ostream_insert(ostream&, const char*, streamsize);
8058 +
8059 +#ifdef _GLIBCXX_USE_WCHAR_T
8060 +  extern template wostream& __ostream_insert(wostream&, const wchar_t*,
8061 +                                            streamsize);
8062 +#endif
8063 +#endif
8064 +
8065  _GLIBCXX_END_NAMESPACE
8066  
8067  #endif /* _OSTREAM_INSERT_H */
8068 Index: libstdc++-v3/ChangeLog
8069 ===================================================================
8070 --- libstdc++-v3/ChangeLog      (.../tags/gcc_4_2_0_release)    (revision 125292)
8071 +++ libstdc++-v3/ChangeLog      (.../branches/gcc-4_2-branch)   (revision 125292)
8072 @@ -1,3 +1,26 @@
8073 +2007-05-28  Benjamin Kosnik  <bkoz@redhat.com>
8074 +
8075 +       PR libstdc++/31717 
8076 +       * acinclude.m4 (GLIBCXX_ENABLE_CLOCALE): Re-organize. Sanity check
8077 +       gnu locale model requests to make sure it will work for the requested
8078 +       target. Add checks for strxfrm_l, strerror_l when in gnu locale,
8079 +       and strerror_r everywhere.
8080 +       * aclocal.m4: Regenerated.
8081 +       * configure: Regenerated.
8082 +       * config.h.in: Regenerated.
8083 +
8084 +2007-05-24  Paolo Carlini  <pcarlini@suse.de>
8085 +
8086 +       * include/bits/ostream.tcc: Do not inhibit implicit instantiation
8087 +       of __ostream_insert here...
8088 +       * include/bits/ostream_insert.h: ... do it here.
8089 +
8090 +2007-05-21  Paolo Carlini  <pcarlini@suse.de>
8091 +
8092 +       PR libstdc++/31621
8093 +       * acinclude.m4 ([GLIBCXX_CHECK_LINKER_FEATURES]): Use the C compiler.
8094 +       * configure: Regenerate.
8095 +
8096  2007-05-13  Release Manager
8097  
8098         * GCC 4.2.0 released.
8099 Index: libstdc++-v3/config.h.in
8100 ===================================================================
8101 --- libstdc++-v3/config.h.in    (.../tags/gcc_4_2_0_release)    (revision 125292)
8102 +++ libstdc++-v3/config.h.in    (.../branches/gcc-4_2-branch)   (revision 125292)
8103 @@ -298,6 +298,12 @@
8104  /* Define to 1 if you have the <stdlib.h> header file. */
8105  #undef HAVE_STDLIB_H
8106  
8107 +/* Define if strerror_l is available in <string.h>. */
8108 +#undef HAVE_STRERROR_L
8109 +
8110 +/* Define if strerror_r is available in <string.h>. */
8111 +#undef HAVE_STRERROR_R
8112 +
8113  /* Define to 1 if you have the <strings.h> header file. */
8114  #undef HAVE_STRINGS_H
8115  
8116 @@ -310,6 +316,9 @@
8117  /* Define to 1 if you have the `strtold' function. */
8118  #undef HAVE_STRTOLD
8119  
8120 +/* Define if strxfrm_l is available in <string.h>. */
8121 +#undef HAVE_STRXFRM_L
8122 +
8123  /* Define to 1 if you have the <sys/filio.h> header file. */
8124  #undef HAVE_SYS_FILIO_H
8125  
8126 Index: libstdc++-v3/acinclude.m4
8127 ===================================================================
8128 --- libstdc++-v3/acinclude.m4   (.../tags/gcc_4_2_0_release)    (revision 125292)
8129 +++ libstdc++-v3/acinclude.m4   (.../branches/gcc-4_2-branch)   (revision 125292)
8130 @@ -251,11 +251,9 @@
8131      # NB: This flag only works reliably after 2.16.1. Configure tests
8132      # for this are difficult, so hard wire a value that should work.
8133  
8134 -    # All these tests are for C++, but run with the "C" compiler driver.
8135 -    # Need to do this so that g++ won't try to link in libstdc++/libsupc++.
8136      ac_test_CFLAGS="${CFLAGS+set}"
8137      ac_save_CFLAGS="$CFLAGS"
8138 -    CFLAGS='-x c++ -Wl,--gc-sections'
8139 +    CFLAGS='-Wl,--gc-sections'
8140  
8141      # Check for -Wl,--gc-sections
8142      AC_MSG_CHECKING([for ld that supports -Wl,--gc-sections])
8143 @@ -1334,64 +1332,31 @@
8144  dnl Default is generic.
8145  dnl
8146  AC_DEFUN([GLIBCXX_ENABLE_CLOCALE], [
8147 -  AC_MSG_CHECKING([for C locale to use])
8148    GLIBCXX_ENABLE(clocale,auto,[@<:@=MODEL@:>@],
8149      [use MODEL for target locale package],
8150      [permit generic|gnu|ieee_1003.1-2001|yes|no|auto])
8151 +
8152 +  # Deal with gettext issues.  Default to not using it (=no) until we detect
8153 +  # support for it later.  Let the user turn it off via --e/d, but let that
8154 +  # default to on for easier handling.
8155 +  USE_NLS=no
8156 +  AC_ARG_ENABLE(nls,
8157 +    AC_HELP_STRING([--enable-nls],[use Native Language Support (default)]),
8158 +    [],
8159 +    [enable_nls=yes])
8160    
8161 -  # If they didn't use this option switch, or if they specified --enable
8162 -  # with no specific model, we'll have to look for one.  If they
8163 -  # specified --disable (???), do likewise.
8164 +  # Either a known packaage, or "auto"
8165    if test $enable_clocale = no || test $enable_clocale = yes; then
8166       enable_clocale=auto
8167    fi
8168 -
8169 -  # Either a known package, or "auto"
8170    enable_clocale_flag=$enable_clocale
8171  
8172 -  # Probe for locale support if no specific model is specified.
8173 +  # Probe for locale model to use if none specified.
8174    # Default to "generic".
8175    if test $enable_clocale_flag = auto; then
8176      case ${target_os} in
8177        linux* | gnu* | kfreebsd*-gnu | knetbsd*-gnu)
8178 -        AC_EGREP_CPP([_GLIBCXX_ok], [
8179 -        #include <features.h>
8180 -        #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2)
8181 -          _GLIBCXX_ok
8182 -        #endif
8183 -        ], enable_clocale_flag=gnu, enable_clocale_flag=generic)
8184 -
8185 -        # Test for bugs early in glibc-2.2.x series
8186 -          if test $enable_clocale_flag = gnu; then
8187 -          AC_TRY_RUN([
8188 -          #define _GNU_SOURCE 1
8189 -          #include <locale.h>
8190 -          #include <string.h>
8191 -          #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
8192 -          extern __typeof(newlocale) __newlocale;
8193 -          extern __typeof(duplocale) __duplocale;
8194 -          extern __typeof(strcoll_l) __strcoll_l;
8195 -          #endif
8196 -          int main()
8197 -          {
8198 -              const char __one[] = "Äuglein Augmen";
8199 -              const char __two[] = "Äuglein";
8200 -              int i;
8201 -              int j;
8202 -              __locale_t        loc;
8203 -               __locale_t        loc_dup;
8204 -              loc = __newlocale(1 << LC_ALL, "de_DE", 0);
8205 -              loc_dup = __duplocale(loc);
8206 -              i = __strcoll_l(__one, __two, loc);
8207 -              j = __strcoll_l(__one, __two, loc_dup);
8208 -              return 0;
8209 -          }
8210 -          ],
8211 -          [enable_clocale_flag=gnu],[enable_clocale_flag=generic],
8212 -          [enable_clocale_flag=generic])
8213 -          fi
8214 -
8215 -        # ... at some point put __strxfrm_l tests in as well.
8216 +        enable_clocale_flag=gnu        
8217          ;;
8218        darwin* | freebsd*)
8219          enable_clocale_flag=darwin
8220 @@ -1402,16 +1367,79 @@
8221      esac
8222    fi
8223  
8224 -  # Deal with gettext issues.  Default to not using it (=no) until we detect
8225 -  # support for it later.  Let the user turn it off via --e/d, but let that
8226 -  # default to on for easier handling.
8227 -  USE_NLS=no
8228 -  AC_ARG_ENABLE(nls,
8229 -    AC_HELP_STRING([--enable-nls],[use Native Language Support (default)]),
8230 -    [],
8231 -    [enable_nls=yes])
8232 +  # Sanity check model, and test for special functionality.
8233 +  if test $enable_clocale_flag = gnu; then
8234 +    AC_EGREP_CPP([_GLIBCXX_ok], [
8235 +    #include <features.h>
8236 +    #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2)
8237 +      _GLIBCXX_ok
8238 +    #endif
8239 +    ], enable_clocale_flag=gnu, enable_clocale_flag=generic)
8240  
8241 +    # Test for bugs early in glibc-2.2.x series
8242 +    AC_TRY_RUN([
8243 +    #define _GNU_SOURCE 1
8244 +    #include <locale.h>
8245 +    #include <string.h>
8246 +    #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
8247 +    extern __typeof(newlocale) __newlocale;
8248 +    extern __typeof(duplocale) __duplocale;
8249 +    extern __typeof(strcoll_l) __strcoll_l;
8250 +    #endif
8251 +    int main()
8252 +    {
8253 +        const char __one[] = "Äuglein Augmen";
8254 +        const char __two[] = "Äuglein";
8255 +        int i;
8256 +        int j;
8257 +        __locale_t        loc;
8258 +        __locale_t        loc_dup;
8259 +        loc = __newlocale(1 << LC_ALL, "de_DE", 0);
8260 +        loc_dup = __duplocale(loc);
8261 +        i = __strcoll_l(__one, __two, loc);
8262 +        j = __strcoll_l(__one, __two, loc_dup);
8263 +        return 0;
8264 +    }
8265 +    ],
8266 +    [enable_clocale_flag=gnu],[enable_clocale_flag=generic],
8267 +    [enable_clocale_flag=generic])
8268 +
8269 +    # Set it to scream when it hurts.
8270 +    ac_save_CFLAGS="$CFLAGS"   
8271 +    CFLAGS="-Wimplicit-function-declaration -Werror"
8272 +
8273 +    # Use strxfrm_l if available.
8274 +    AC_TRY_COMPILE([#define _GNU_SOURCE 1
8275 +                   #include <string.h>
8276 +                   #include <locale.h>],
8277 +                   [char s[128]; __locale_t loc; strxfrm_l(s, "C", 5, loc);], 
8278 +                    AC_DEFINE(HAVE_STRXFRM_L, 1, 
8279 +                    [Define if strxfrm_l is available in <string.h>.]),)
8280 +    
8281 +    # Use strerror_l if available.
8282 +    AC_TRY_COMPILE([#define _GNU_SOURCE 1
8283 +                   #include <string.h>
8284 +                   #include <locale.h>],
8285 +                   [__locale_t loc; strerror_l(5, loc);], 
8286 +                    AC_DEFINE(HAVE_STRERROR_L, 1, 
8287 +                    [Define if strerror_l is available in <string.h>.]),)
8288 +
8289 +    CFLAGS="$ac_save_CFLAGS"
8290 +  fi
8291 +
8292 +  # Perhaps use strerror_r if available, and strerror_l isn't.
8293 +  ac_save_CFLAGS="$CFLAGS"     
8294 +  CFLAGS="-Wimplicit-function-declaration -Werror"
8295 +  AC_TRY_COMPILE([#define _GNU_SOURCE 1
8296 +                 #include <string.h>
8297 +                 #include <locale.h>],
8298 +                 [char s[128]; strerror_r(5, s, 128);], 
8299 +                  AC_DEFINE(HAVE_STRERROR_R, 1, 
8300 +                  [Define if strerror_r is available in <string.h>.]),)
8301 +  CFLAGS="$ac_save_CFLAGS"
8302 +
8303    # Set configure bits for specified locale package
8304 +  AC_MSG_CHECKING([for C locale to use])
8305    case ${enable_clocale_flag} in
8306      generic)
8307        AC_MSG_RESULT(generic)
8308 Index: libgfortran/runtime/environ.c
8309 ===================================================================
8310 --- libgfortran/runtime/environ.c       (.../tags/gcc_4_2_0_release)    (revision 125292)
8311 +++ libgfortran/runtime/environ.c       (.../branches/gcc-4_2-branch)   (revision 125292)
8312 @@ -861,14 +861,13 @@
8313  static int
8314  do_parse (void)
8315  {
8316 -  int tok, def;
8317 +  int tok;
8318    int unit1;
8319    int continue_ulist;
8320    char *start;
8321  
8322    unit_count = 0;
8323  
8324 -  def = 0;
8325    start = p;
8326  
8327    /* Parse the string.  First, let's look for a default.  */
8328 @@ -923,6 +922,7 @@
8329        break;
8330  
8331      case END:
8332 +      def = endian;
8333        goto end;
8334        break;
8335  
8336 @@ -939,6 +939,18 @@
8337        tok = next_token ();
8338        switch (tok)
8339         {
8340 +       case NATIVE:
8341 +         if (next_token () != ':')
8342 +           goto error;
8343 +         endian = CONVERT_NATIVE;
8344 +         break;
8345 +
8346 +       case SWAP:
8347 +         if (next_token () != ':')
8348 +           goto error;
8349 +         endian = CONVERT_SWAP;
8350 +         break;
8351 +
8352         case LITTLE:
8353           if (next_token () != ':')
8354             goto error;
8355 Index: libgfortran/intrinsics/reshape_generic.c
8356 ===================================================================
8357 --- libgfortran/intrinsics/reshape_generic.c    (.../tags/gcc_4_2_0_release)    (revision 125292)
8358 +++ libgfortran/intrinsics/reshape_generic.c    (.../branches/gcc-4_2-branch)   (revision 125292)
8359 @@ -266,7 +266,7 @@
8360            else
8361              {
8362                scount[n]++;
8363 -              sptr += sstride[n] * size;
8364 +              src += sstride[n] * size;
8365              }
8366          }
8367      }
8368 Index: libgfortran/intrinsics/ishftc.c
8369 ===================================================================
8370 --- libgfortran/intrinsics/ishftc.c     (.../tags/gcc_4_2_0_release)    (revision 125292)
8371 +++ libgfortran/intrinsics/ishftc.c     (.../branches/gcc-4_2-branch)   (revision 125292)
8372 @@ -36,8 +36,7 @@
8373  GFC_INTEGER_4
8374  ishftc4 (GFC_INTEGER_4 i, GFC_INTEGER_4 shift, GFC_INTEGER_4 size)
8375  {
8376 -  GFC_INTEGER_4 mask;
8377 -  GFC_UINTEGER_4 bits;
8378 +  GFC_UINTEGER_4 mask, bits;
8379  
8380    if (shift < 0)
8381      shift = shift + size;
8382 @@ -45,9 +44,14 @@
8383    if (shift == 0 || shift == size)
8384      return i;
8385  
8386 -  mask = (~(GFC_INTEGER_4)0) << size;
8387 -  bits = i & ~mask;
8388 -  return (i & mask) | (bits >> (size - shift)) | ((i << shift) & ~mask);
8389 +  /* In C, the result of the shift operator is undefined if the right operand
8390 +     is greater than or equal to the number of bits in the left operand. So we
8391 +     have to special case it for fortran.  */
8392 +  mask = ~((size == 32) ? 0 : (~0 << size));
8393 +
8394 +  bits = i & mask;
8395 +  
8396 +  return (i & ~mask) | ((bits << shift) & mask) | (bits >> (size - shift));
8397  }
8398  
8399  extern GFC_INTEGER_8 ishftc8 (GFC_INTEGER_8, GFC_INTEGER_4, GFC_INTEGER_4);
8400 @@ -56,8 +60,7 @@
8401  GFC_INTEGER_8
8402  ishftc8 (GFC_INTEGER_8 i, GFC_INTEGER_4 shift, GFC_INTEGER_4 size)
8403  {
8404 -  GFC_INTEGER_8 mask;
8405 -  GFC_UINTEGER_8 bits;
8406 +  GFC_UINTEGER_8 mask, bits;
8407  
8408    if (shift < 0)
8409      shift = shift + size;
8410 @@ -65,9 +68,14 @@
8411    if (shift == 0 || shift == size)
8412      return i;
8413  
8414 -  mask = (~(GFC_INTEGER_8)0) << size;
8415 -  bits = i & ~mask;
8416 -  return (i & mask) | (bits >> (size - shift)) | ((i << shift) & ~mask);
8417 +  /* In C, the result of the shift operator is undefined if the right operand
8418 +     is greater than or equal to the number of bits in the left operand. So we
8419 +     have to special case it for fortran.  */
8420 +  mask = ~((size == 64) ? 0 : (~0 << size));
8421 +
8422 +  bits = i & mask;
8423 +  
8424 +  return (i & ~mask) | ((bits << shift) & mask) | (bits >> (size - shift));
8425  }
8426  
8427  #ifdef HAVE_GFC_INTEGER_16
8428 @@ -77,8 +85,7 @@
8429  GFC_INTEGER_16
8430  ishftc16 (GFC_INTEGER_16 i, GFC_INTEGER_4 shift, GFC_INTEGER_4 size)
8431  {
8432 -  GFC_INTEGER_16 mask;
8433 -  GFC_UINTEGER_16 bits;
8434 +  GFC_UINTEGER_16 mask, bits;
8435  
8436    if (shift < 0)
8437      shift = shift + size;
8438 @@ -86,8 +93,13 @@
8439    if (shift == 0 || shift == size)
8440      return i;
8441  
8442 -  mask = (~(GFC_INTEGER_16)0) << size;
8443 -  bits = i & ~mask;
8444 -  return (i & mask) | (bits >> (size - shift)) | ((i << shift) & ~mask);
8445 +  /* In C, the result of the shift operator is undefined if the right operand
8446 +     is greater than or equal to the number of bits in the left operand. So we
8447 +     have to special case it for fortran.  */
8448 +  mask = ~((size == 128) ? 0 : (~0 << size));
8449 +
8450 +  bits = i & mask;
8451 +  
8452 +  return (i & ~mask) | ((bits << shift) & mask) | (bits >> (size - shift));
8453  }
8454  #endif
8455 Index: libgfortran/ChangeLog
8456 ===================================================================
8457 --- libgfortran/ChangeLog       (.../tags/gcc_4_2_0_release)    (revision 125292)
8458 +++ libgfortran/ChangeLog       (.../branches/gcc-4_2-branch)   (revision 125292)
8459 @@ -1,3 +1,53 @@
8460 +2007-05-23  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
8461 +
8462 +       PR libfortran/31964
8463 +       Backport from trunk.
8464 +       * intrinsics/ishftc.c (ishftc4, ishftc8, ishftc16): Fix mask to handle
8465 +       shift of bit-size number of bits.
8466 +
8467 +2007-05-23  Tobias Burnus <burnus@net-b.de>
8468 +
8469 +       PR fortran/31917
8470 +       Backport from trunk.
8471 +       * runtime/environ.c (mark_range): Fix setting default convert unit.
8472 +
8473 +2007-05-22  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
8474 +
8475 +       PR libfortran/31051
8476 +       Backport from trunk.
8477 +       * io/transfer.c (formatted_transfer_scalar): Adjust position for pending
8478 +       spaces when in writing mode.  Clean up some formatting.
8479 +       
8480 +2007-05-22  Tobias Burnus  <burnus@net-b.de>
8481 +
8482 +       PR libfortran/31915
8483 +       Backport from trunk.
8484 +       * io/transfer.c (unformatted_read): Use proper size for real(10).
8485 +         (unformatted_write): Ditto.
8486 +
8487 +2007-05-20  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
8488 +
8489 +       PR libfortran/31395
8490 +       Backport from 4.3.
8491 +       * io/format.c (parse_format_list): Fix parsing. Regression against g77.
8492 +
8493 +2007-05-20  Thomas Koenig  <tkoenig@gcc.gnu.org>
8494 +
8495 +       PR fortran/31618
8496 +       Backport from trunk.
8497 +       * io/transfer.c (read_block_direct):  Instead of calling us_read,
8498 +       set dtp->u.p.current_unit->current_record = 0 so that pre_position
8499 +       will read the record marker.
8500 +       (data_transfer_init):  For different error conditions, call
8501 +       generate_error, then return.
8502 +
8503 +2007-05-20  Thomas Koenig  <tkoenig@gcc.gnu.org>
8504 +
8505 +       PR libfortran/31196
8506 +       Backport from trunk.
8507 +       * intrinsics/reshape_generic.c (reshape_internal):  Increment
8508 +       correct variable.
8509 +
8510  2007-05-13  Release Manager
8511  
8512         * GCC 4.2.0 released.
8513 Index: libgfortran/io/transfer.c
8514 ===================================================================
8515 --- libgfortran/io/transfer.c   (.../tags/gcc_4_2_0_release)    (revision 125292)
8516 +++ libgfortran/io/transfer.c   (.../branches/gcc-4_2-branch)   (revision 125292)
8517 @@ -493,11 +493,11 @@
8518             }
8519           else
8520             {
8521 -             /* Let's make sure the file position is correctly set for the
8522 -                next read statement.  */
8523 +             /* Let's make sure the file position is correctly pre-positioned
8524 +                for the next read statement.  */
8525  
8526 +             dtp->u.p.current_unit->current_record = 0;
8527               next_record_r_unf (dtp, 0);
8528 -             us_read (dtp, 0);
8529               generate_error (&dtp->common, ERROR_SHORT_RECORD, NULL);
8530               return;
8531             }
8532 @@ -722,7 +722,11 @@
8533          of the padding.  If we hit a short record, then sz is
8534          adjusted accordingly, making later reads no-ops.  */
8535        
8536 -      sz = kind;
8537 +      if (type == BT_REAL || type == BT_COMPLEX)
8538 +       sz = size_from_real_kind (kind);
8539 +      else
8540 +       sz = kind;
8541 +
8542        for (i=0; i<nelems; i++)
8543         {
8544           read_block_direct (dtp, buffer, &sz);
8545 @@ -767,7 +771,11 @@
8546          read kind bytes.  We don't care about the contents
8547          of the padding.  */
8548  
8549 -      sz = kind;
8550 +      if (type == BT_REAL || type == BT_COMPLEX)
8551 +       sz = size_from_real_kind (kind);
8552 +      else
8553 +       sz = kind;
8554 +
8555        for (i=0; i<nelems; i++)
8556         {
8557           reverse_memcpy(buffer, p, size);
8558 @@ -1144,7 +1152,7 @@
8559         /* Format codes that don't transfer data.  */
8560         case FMT_X:
8561         case FMT_TR:
8562 -         consume_data_flag = 0 ;
8563 +         consume_data_flag = 0;
8564  
8565           pos = bytes_used + f->u.n + dtp->u.p.skips;
8566           dtp->u.p.skips = f->u.n + dtp->u.p.skips;
8567 @@ -1160,6 +1168,7 @@
8568               write_x (dtp, dtp->u.p.skips, dtp->u.p.pending_spaces);
8569               dtp->u.p.skips = dtp->u.p.pending_spaces = 0;
8570             }
8571 +
8572           if (dtp->u.p.mode == READING)
8573             read_x (dtp, f->u.n);
8574  
8575 @@ -1167,6 +1176,8 @@
8576  
8577         case FMT_TL:
8578         case FMT_T:
8579 +         consume_data_flag = 0;
8580 +
8581           if (f->format == FMT_TL)
8582             {
8583  
8584 @@ -1185,8 +1196,10 @@
8585             }
8586           else /* FMT_T */
8587             {
8588 -             consume_data_flag = 0;
8589 -             pos = f->u.n - 1;
8590 +             if (dtp->u.p.mode == READING)
8591 +               pos = f->u.n - 1;
8592 +             else
8593 +               pos = f->u.n - dtp->u.p.pending_spaces - 1;
8594             }
8595  
8596           /* Standard 10.6.1.1: excessive left tabbing is reset to the
8597 @@ -1753,16 +1766,19 @@
8598    /* Check the action.  */
8599  
8600    if (read_flag && dtp->u.p.current_unit->flags.action == ACTION_WRITE)
8601 -    generate_error (&dtp->common, ERROR_BAD_ACTION,
8602 -                   "Cannot read from file opened for WRITE");
8603 +    {
8604 +      generate_error (&dtp->common, ERROR_BAD_ACTION,
8605 +                     "Cannot read from file opened for WRITE");
8606 +      return;
8607 +    }
8608  
8609    if (!read_flag && dtp->u.p.current_unit->flags.action == ACTION_READ)
8610 -    generate_error (&dtp->common, ERROR_BAD_ACTION,
8611 -                   "Cannot write to file opened for READ");
8612 +    {
8613 +      generate_error (&dtp->common, ERROR_BAD_ACTION,
8614 +                     "Cannot write to file opened for READ");
8615 +      return;
8616 +    }
8617  
8618 -  if ((dtp->common.flags & IOPARM_LIBRETURN_MASK) != IOPARM_LIBRETURN_OK)
8619 -    return;
8620 -
8621    dtp->u.p.first_item = 1;
8622  
8623    /* Check the format.  */
8624 @@ -1770,14 +1786,14 @@
8625    if ((cf & IOPARM_DT_HAS_FORMAT) != 0)
8626      parse_format (dtp);
8627  
8628 -  if ((dtp->common.flags & IOPARM_LIBRETURN_MASK) != IOPARM_LIBRETURN_OK)
8629 -    return;
8630 -
8631    if (dtp->u.p.current_unit->flags.form == FORM_UNFORMATTED
8632        && (cf & (IOPARM_DT_HAS_FORMAT | IOPARM_DT_LIST_FORMAT))
8633          != 0)
8634 -    generate_error (&dtp->common, ERROR_OPTION_CONFLICT,
8635 -                   "Format present for UNFORMATTED data transfer");
8636 +    {
8637 +      generate_error (&dtp->common, ERROR_OPTION_CONFLICT,
8638 +                     "Format present for UNFORMATTED data transfer");
8639 +      return;
8640 +    }
8641  
8642    if ((cf & IOPARM_DT_HAS_NAMELIST_NAME) != 0 && dtp->u.p.ionml != NULL)
8643       {
8644 @@ -1787,13 +1803,19 @@
8645       }
8646    else if (dtp->u.p.current_unit->flags.form == FORM_FORMATTED &&
8647            !(cf & (IOPARM_DT_HAS_FORMAT | IOPARM_DT_LIST_FORMAT)))
8648 -    generate_error (&dtp->common, ERROR_OPTION_CONFLICT,
8649 -                   "Missing format for FORMATTED data transfer");
8650 +    {
8651 +      generate_error (&dtp->common, ERROR_OPTION_CONFLICT,
8652 +                     "Missing format for FORMATTED data transfer");
8653 +    }
8654  
8655    if (is_internal_unit (dtp)
8656        && dtp->u.p.current_unit->flags.form == FORM_UNFORMATTED)
8657 -    generate_error (&dtp->common, ERROR_OPTION_CONFLICT,
8658 -                   "Internal file cannot be accessed by UNFORMATTED data transfer");
8659 +    {
8660 +      generate_error (&dtp->common, ERROR_OPTION_CONFLICT,
8661 +                     "Internal file cannot be accessed by UNFORMATTED "
8662 +                     "data transfer");
8663 +      return;
8664 +    }
8665  
8666    /* Check the record or position number.  */
8667  
8668 @@ -1823,49 +1845,71 @@
8669    if (dtp->u.p.advance_status != ADVANCE_UNSPECIFIED)
8670      {
8671        if (dtp->u.p.current_unit->flags.access == ACCESS_DIRECT)
8672 -       generate_error (&dtp->common, ERROR_OPTION_CONFLICT,
8673 -                       "ADVANCE specification conflicts with sequential access");
8674 +       {
8675 +         generate_error (&dtp->common, ERROR_OPTION_CONFLICT,
8676 +                         "ADVANCE specification conflicts with sequential access");
8677 +         return;
8678 +       }
8679  
8680        if (is_internal_unit (dtp))
8681 -       generate_error (&dtp->common, ERROR_OPTION_CONFLICT,
8682 -                       "ADVANCE specification conflicts with internal file");
8683 +       {
8684 +         generate_error (&dtp->common, ERROR_OPTION_CONFLICT,
8685 +                         "ADVANCE specification conflicts with internal file");
8686 +         return;
8687 +       }
8688  
8689        if ((cf & (IOPARM_DT_HAS_FORMAT | IOPARM_DT_LIST_FORMAT))
8690           != IOPARM_DT_HAS_FORMAT)
8691 -       generate_error (&dtp->common, ERROR_OPTION_CONFLICT,
8692 -                       "ADVANCE specification requires an explicit format");
8693 +       {
8694 +         generate_error (&dtp->common, ERROR_OPTION_CONFLICT,
8695 +                         "ADVANCE specification requires an explicit format");
8696 +         return;
8697 +       }
8698      }
8699  
8700    if (read_flag)
8701      {
8702        if ((cf & IOPARM_EOR) != 0 && dtp->u.p.advance_status != ADVANCE_NO)
8703 -       generate_error (&dtp->common, ERROR_MISSING_OPTION,
8704 -                       "EOR specification requires an ADVANCE specification of NO");
8705 +       {
8706 +         generate_error (&dtp->common, ERROR_MISSING_OPTION,
8707 +                         "EOR specification requires an ADVANCE specification "
8708 +                         "of NO");
8709 +         return;
8710 +       }
8711  
8712        if ((cf & IOPARM_DT_HAS_SIZE) != 0 && dtp->u.p.advance_status != ADVANCE_NO)
8713 -       generate_error (&dtp->common, ERROR_MISSING_OPTION,
8714 -                       "SIZE specification requires an ADVANCE specification of NO");
8715 -
8716 +       {
8717 +         generate_error (&dtp->common, ERROR_MISSING_OPTION,
8718 +                         "SIZE specification requires an ADVANCE specification of NO");
8719 +         return;
8720 +       }
8721      }
8722    else
8723      {                          /* Write constraints.  */
8724        if ((cf & IOPARM_END) != 0)
8725 -       generate_error (&dtp->common, ERROR_OPTION_CONFLICT,
8726 -                       "END specification cannot appear in a write statement");
8727 +       {
8728 +         generate_error (&dtp->common, ERROR_OPTION_CONFLICT,
8729 +                         "END specification cannot appear in a write statement");
8730 +         return;
8731 +       }
8732  
8733        if ((cf & IOPARM_EOR) != 0)
8734 -       generate_error (&dtp->common, ERROR_OPTION_CONFLICT,
8735 -                       "EOR specification cannot appear in a write statement");
8736 +       {
8737 +         generate_error (&dtp->common, ERROR_OPTION_CONFLICT,
8738 +                         "EOR specification cannot appear in a write statement");
8739 +         return;
8740 +       }
8741  
8742        if ((cf & IOPARM_DT_HAS_SIZE) != 0)
8743 -       generate_error (&dtp->common, ERROR_OPTION_CONFLICT,
8744 -                       "SIZE specification cannot appear in a write statement");
8745 +       {
8746 +         generate_error (&dtp->common, ERROR_OPTION_CONFLICT,
8747 +                         "SIZE specification cannot appear in a write statement");
8748 +         return;
8749 +       }
8750      }
8751  
8752    if (dtp->u.p.advance_status == ADVANCE_UNSPECIFIED)
8753      dtp->u.p.advance_status = ADVANCE_YES;
8754 -  if ((dtp->common.flags & IOPARM_LIBRETURN_MASK) != IOPARM_LIBRETURN_OK)
8755 -    return;
8756  
8757    /* Sanity checks on the record number.  */
8758    if ((cf & IOPARM_DT_HAS_REC) != 0)
8759 Index: libgfortran/io/format.c
8760 ===================================================================
8761 --- libgfortran/io/format.c     (.../tags/gcc_4_2_0_release)    (revision 125292)
8762 +++ libgfortran/io/format.c     (.../branches/gcc-4_2-branch)   (revision 125292)
8763 @@ -860,10 +860,11 @@
8764      case FMT_SLASH:
8765        get_fnode (fmt, &head, &tail, FMT_SLASH);
8766        tail->repeat = 1;
8767 +      goto optional_comma;
8768  
8769 -      /* Fall Through */
8770 -
8771      case FMT_COLON:
8772 +      get_fnode (fmt, &head, &tail, FMT_COLON);
8773 +      tail->repeat = 1;
8774        goto optional_comma;
8775  
8776      case FMT_END:
8777 Index: boehm-gc/darwin_stop_world.c
8778 ===================================================================
8779 --- boehm-gc/darwin_stop_world.c        (.../tags/gcc_4_2_0_release)    (revision 125292)
8780 +++ boehm-gc/darwin_stop_world.c        (.../branches/gcc-4_2-branch)   (revision 125292)
8781 @@ -10,7 +10,7 @@
8782     be allocated, is called the red zone. This area as shown in Figure 3-2 may
8783     be used for any purpose as long as a new stack frame does not need to be
8784     added to the stack."
8785 -   
8786 +
8787     Page 50: "If a leaf procedure's red zone usage would exceed 224 bytes, then
8788     it must set up a stack frame just like routines that call other routines."
8789  */
8790 @@ -20,48 +20,6 @@
8791  # define PPC_RED_ZONE_SIZE 320
8792  #endif
8793  
8794 -/* Try to work out the right way to access thread state structure members.
8795 -   The structure has changed its definition in different Darwin versions.  */
8796 -#if defined(__ppc__)
8797 -# define THREAD_STATE ppc_thread_state_t
8798 -# if defined (HAS_PPC_THREAD_STATE_R0)
8799 -#  define THREAD_FLD(x) x
8800 -# elif defined (HAS_PPC_THREAD_STATE___R0)
8801 -#  define THREAD_FLD(x) __ ## x
8802 -# else
8803 -#  error can not work out how to access fields of ppc_thread_state_t
8804 -# endif
8805 -#elif defined(__ppc64__)
8806 -# define THREAD_STATE ppc_thread_state64_t
8807 -# if defined (HAS_PPC_THREAD_STATE64_R0)
8808 -#  define THREAD_FLD(x) x
8809 -# elif defined (HAS_PPC_THREAD_STATE64___R0)
8810 -#  define THREAD_FLD(x) __ ## x
8811 -# else
8812 -#  error can not work out how to access fields of ppc_thread_state64_t
8813 -# endif
8814 -#elif defined(__i386__)
8815 -# define THREAD_STATE i386_thread_state_t
8816 -# if defined (HAS_I386_THREAD_STATE_EAX)
8817 -#  define THREAD_FLD(x) x
8818 -# elif defined (HAS_I386_THREAD_STATE___EAX)
8819 -#  define THREAD_FLD(x) __ ## x
8820 -# else
8821 -#  error can not work out how to access fields of i386_thread_state_t
8822 -# endif
8823 -#elif defined(__x86_64__)
8824 -# define THREAD_STATE i386_thread_state_t
8825 -# if defined (HAS_I386_THREAD_STATE_EAX)
8826 -#  define THREAD_FLD(x) x
8827 -# elif defined (HAS_I386_THREAD_STATE___EAX)
8828 -#  define THREAD_FLD(x) __ ## x
8829 -# else
8830 -#  error can not work out how to access fields of i386_thread_state_t
8831 -# endif
8832 -#else
8833 -# error unknown architecture
8834 -#endif
8835 -
8836  typedef struct StackFrame {
8837    unsigned long        savedSP;
8838    unsigned long        savedCR;
8839 @@ -115,8 +73,8 @@
8840    GC_thread p;
8841    pthread_t me;
8842    ptr_t lo, hi;
8843 -  THREAD_STATE state;
8844 -  mach_msg_type_number_t thread_state_count = MACHINE_THREAD_STATE_COUNT;
8845 +  GC_THREAD_STATE_T state;
8846 +  mach_msg_type_number_t thread_state_count = GC_MACH_THREAD_STATE_COUNT;
8847    
8848    me = pthread_self();
8849    if (!GC_thr_initialized) GC_thr_init();
8850 @@ -128,11 +86,8 @@
8851         lo = GC_approx_sp();
8852        } else {
8853         /* Get the thread state (registers, etc) */
8854 -       r = thread_get_state(
8855 -                            p->stop_info.mach_thread,
8856 -                            MACHINE_THREAD_STATE,
8857 -                            (natural_t*)&state,
8858 -                            &thread_state_count);
8859 +       r = thread_get_state(p->stop_info.mach_thread, GC_MACH_THREAD_STATE,
8860 +                            (natural_t*)&state, &thread_state_count);
8861         if(r != KERN_SUCCESS) ABORT("thread_get_state failed");
8862  
8863  #if defined(I386)
8864 @@ -144,7 +99,33 @@
8865         GC_push_one(state . THREAD_FLD (edx)); 
8866         GC_push_one(state . THREAD_FLD (edi)); 
8867         GC_push_one(state . THREAD_FLD (esi)); 
8868 -       GC_push_one(state . THREAD_FLD (ebp)); 
8869 +       GC_push_one(state . THREAD_FLD (ebp));
8870 +
8871 +#elif defined(X86_64)
8872 +       lo = (void*)state . THREAD_FLD (rsp);
8873 +
8874 +       GC_push_one(state . THREAD_FLD (rax));
8875 +       GC_push_one(state . THREAD_FLD (rbx));
8876 +       GC_push_one(state . THREAD_FLD (rcx));
8877 +       GC_push_one(state . THREAD_FLD (rdx));
8878 +       GC_push_one(state . THREAD_FLD (rdi));
8879 +       GC_push_one(state . THREAD_FLD (rsi));
8880 +       GC_push_one(state . THREAD_FLD (rbp));
8881 +       GC_push_one(state . THREAD_FLD (rsp));
8882 +       GC_push_one(state . THREAD_FLD (r8));
8883 +       GC_push_one(state . THREAD_FLD (r9));
8884 +       GC_push_one(state . THREAD_FLD (r10));
8885 +       GC_push_one(state . THREAD_FLD (r11));
8886 +       GC_push_one(state . THREAD_FLD (r12));
8887 +       GC_push_one(state . THREAD_FLD (r13));
8888 +       GC_push_one(state . THREAD_FLD (r14));
8889 +       GC_push_one(state . THREAD_FLD (r15));
8890 +       GC_push_one(state . THREAD_FLD (rip));
8891 +       GC_push_one(state . THREAD_FLD (rflags));
8892 +       GC_push_one(state . THREAD_FLD (cs));
8893 +       GC_push_one(state . THREAD_FLD (fs));
8894 +       GC_push_one(state . THREAD_FLD (gs));
8895 +
8896  #elif defined(POWERPC)
8897         lo = (void*)(state . THREAD_FLD (r1) - PPC_RED_ZONE_SIZE);
8898          
8899 @@ -221,9 +202,9 @@
8900         hi = (ptr_t)FindTopOfStack(0);
8901        } else {
8902  #     if defined(__ppc__) || defined(__ppc64__)
8903 -       THREAD_STATE info;
8904 +       GC_THREAD_STATE_T info;
8905         mach_msg_type_number_t outCount = THREAD_STATE_MAX;
8906 -       r = thread_get_state(thread, MACHINE_THREAD_STATE,
8907 +       r = thread_get_state(thread, GC_MACH_THREAD_STATE,
8908                              (natural_t *)&info, &outCount);
8909         if(r != KERN_SUCCESS) ABORT("task_get_state failed");
8910  
8911 @@ -264,10 +245,10 @@
8912  #      else
8913         /* FIXME: Remove after testing: */
8914         WARN("This is completely untested and likely will not work\n", 0);
8915 -       THREAD_STATE info;
8916 +       GC_THREAD_STATE_T info;
8917         mach_msg_type_number_t outCount = THREAD_STATE_MAX;
8918 -       r = thread_get_state(thread, MACHINE_THREAD_STATE,
8919 -                            (natural_t *)&info, &outCount);
8920 +       r = thread_get_state(thread, GC_MACH_THREAD_STATE, (natural_t *)&info,
8921 +                            &outCount);
8922         if(r != KERN_SUCCESS) ABORT("task_get_state failed");
8923  
8924         lo = (void*)info . THREAD_FLD (esp);
8925 Index: boehm-gc/Makefile.in
8926 ===================================================================
8927 --- boehm-gc/Makefile.in        (.../tags/gcc_4_2_0_release)    (revision 125292)
8928 +++ boehm-gc/Makefile.in        (.../branches/gcc-4_2-branch)   (revision 125292)
8929 @@ -224,6 +224,7 @@
8930  build_vendor = @build_vendor@
8931  datadir = @datadir@
8932  exec_prefix = @exec_prefix@
8933 +extra_ldflags_libgc = @extra_ldflags_libgc@
8934  host = @host@
8935  host_alias = @host_alias@
8936  host_cpu = @host_cpu@
8937 @@ -280,7 +281,7 @@
8938  # linuxthread semaphore functions get linked:
8939  libgcjgc_la_LIBADD = @addobjs@ $(THREADLIBS) $(UNWINDLIBS)
8940  libgcjgc_la_DEPENDENCIES = @addobjs@
8941 -libgcjgc_la_LDFLAGS = -version-info 1:2:0 -rpath $(toolexeclibdir)
8942 +libgcjgc_la_LDFLAGS = $(extra_ldflags_libgc) -version-info 1:2:0 -rpath $(toolexeclibdir)
8943  libgcjgc_convenience_la_LIBADD = @addobjs@
8944  libgcjgc_convenience_la_DEPENDENCIES = @addobjs@
8945  AM_CXXFLAGS = @GC_CFLAGS@
8946 Index: boehm-gc/configure.ac
8947 ===================================================================
8948 --- boehm-gc/configure.ac       (.../tags/gcc_4_2_0_release)    (revision 125292)
8949 +++ boehm-gc/configure.ac       (.../branches/gcc-4_2-branch)   (revision 125292)
8950 @@ -248,33 +248,46 @@
8951  case "$host" in
8952    powerpc*-*-darwin*)
8953      AC_CHECK_MEMBER(ppc_thread_state_t.r0,
8954 -      AC_DEFINE(HAS_PPC_THREAD_STATE_R0,,[ppc_thread_state_t has field r0]),,
8955 +      AC_DEFINE(HAS_PPC_THREAD_STATE_R0,1,
8956 +       [ppc_thread_state_t has field r0]),,
8957        [#include <mach/thread_status.h>])
8958      AC_CHECK_MEMBER(ppc_thread_state_t.__r0,
8959 -      AC_DEFINE(HAS_PPC_THREAD_STATE___R0,,dnl
8960 -        [ppc_thread_state_t has field __r0]),,
8961 +      AC_DEFINE(HAS_PPC_THREAD_STATE___R0,1,dnl
8962 +       [ppc_thread_state_t has field __r0]),,
8963        [#include <mach/thread_status.h>])
8964      AC_CHECK_MEMBER(ppc_thread_state64_t.r0,
8965 -      AC_DEFINE(HAS_PPC_THREAD_STATE64_R0,,dnl
8966 -        [ppc_thread_state64_t has field r0]),,
8967 +      AC_DEFINE(HAS_PPC_THREAD_STATE64_R0,1,dnl
8968 +       [ppc_thread_state64_t has field r0]),,
8969        [#include <mach/thread_status.h>])
8970      AC_CHECK_MEMBER(ppc_thread_state64_t.__r0,
8971 -      AC_DEFINE(HAS_PPC_THREAD_STATE64___R0,,dnl
8972 -        [ppc_thread_state64_t has field __r0]),,
8973 +      AC_DEFINE(HAS_PPC_THREAD_STATE64___R0,1,dnl
8974 +       [ppc_thread_state64_t has field __r0]),,
8975        [#include <mach/thread_status.h>])
8976      ;;
8977    i?86*-*-darwin*)
8978 -    AC_CHECK_MEMBER(i386_thread_state_t.eax,
8979 -      AC_DEFINE(HAS_I386_THREAD_STATE_EAX,,dnl
8980 -        [i386_thread_state_t has field eax]),,
8981 +    AC_CHECK_MEMBER(x86_thread_state32_t.eax,
8982 +      AC_DEFINE(HAS_X86_THREAD_STATE32_EAX,1,dnl
8983 +       [x86_thread_state32_t has field eax]),,
8984        [#include <sys/cdefs.h>
8985 -#include <mach/thread_status.h>])
8986 -    AC_CHECK_MEMBER(i386_thread_state_t.__eax,
8987 -      AC_DEFINE(HAS_I386_THREAD_STATE___EAX,,dnl
8988 -        [i386_thread_state_t has field __eax]),,
8989 +      #include <mach/thread_status.h>])
8990 +    AC_CHECK_MEMBER(x86_thread_state32_t.__eax,
8991 +      AC_DEFINE(HAS_X86_THREAD_STATE32___EAX,1,dnl
8992 +       [x86_thread_state32_t has field __eax]),,
8993        [#include <sys/cdefs.h>
8994 -#include <mach/thread_status.h>])
8995 +      #include <mach/thread_status.h>])
8996      ;;
8997 +  x86_64-*-darwin*)
8998 +    AC_CHECK_MEMBER(x86_thread_state64_t.rax,
8999 +      AC_DEFINE(HAS_X86_THREAD_STATE64_RAX,1,dnl
9000 +       [x86_thread_state64_t has field rax]),,
9001 +      [#include <sys/cdefs.h>
9002 +      #include <mach/thread_status.h>])
9003 +    AC_CHECK_MEMBER(x86_thread_state64_t.__rax,
9004 +      AC_DEFINE(HAS_X86_THREAD_STATE64___RAX,1,dnl
9005 +       [x86_thread_state64_t has field __rax]),,
9006 +      [#include <sys/cdefs.h>
9007 +      #include <mach/thread_status.h>])
9008 +     ;;
9009    *) ;;
9010  esac
9011  
9012 @@ -287,6 +300,14 @@
9013      ;;
9014  esac
9015  
9016 +# extra LD Flags which are required for targets
9017 +case "${host}" in
9018 +  *-*-darwin*)
9019 +    extra_ldflags_libgc=-Wl,-single_module
9020 +    ;;
9021 +esac
9022 +AC_SUBST(extra_ldflags_libgc)
9023 +
9024  AC_SUBST(EXTRA_TEST_LIBS)
9025  
9026  target_all=libgcjgc.la
9027 Index: boehm-gc/include/Makefile.in
9028 ===================================================================
9029 --- boehm-gc/include/Makefile.in        (.../tags/gcc_4_2_0_release)    (revision 125292)
9030 +++ boehm-gc/include/Makefile.in        (.../branches/gcc-4_2-branch)   (revision 125292)
9031 @@ -149,6 +149,7 @@
9032  build_vendor = @build_vendor@
9033  datadir = @datadir@
9034  exec_prefix = @exec_prefix@
9035 +extra_ldflags_libgc = @extra_ldflags_libgc@
9036  host = @host@
9037  host_alias = @host_alias@
9038  host_cpu = @host_cpu@
9039 Index: boehm-gc/include/gc_config.h.in
9040 ===================================================================
9041 --- boehm-gc/include/gc_config.h.in     (.../tags/gcc_4_2_0_release)    (revision 125292)
9042 +++ boehm-gc/include/gc_config.h.in     (.../branches/gcc-4_2-branch)   (revision 125292)
9043 @@ -54,12 +54,6 @@
9044  /* support for win32 threads */
9045  #undef GC_WIN32_THREADS
9046  
9047 -/* i386_thread_state_t has field eax */
9048 -#undef HAS_I386_THREAD_STATE_EAX
9049 -
9050 -/* i386_thread_state_t has field __eax */
9051 -#undef HAS_I386_THREAD_STATE___EAX
9052 -
9053  /* ppc_thread_state64_t has field r0 */
9054  #undef HAS_PPC_THREAD_STATE64_R0
9055  
9056 @@ -72,6 +66,18 @@
9057  /* ppc_thread_state_t has field __r0 */
9058  #undef HAS_PPC_THREAD_STATE___R0
9059  
9060 +/* x86_thread_state32_t has field eax */
9061 +#undef HAS_X86_THREAD_STATE32_EAX
9062 +
9063 +/* x86_thread_state32_t has field __eax */
9064 +#undef HAS_X86_THREAD_STATE32___EAX
9065 +
9066 +/* x86_thread_state64_t has field rax */
9067 +#undef HAS_X86_THREAD_STATE64_RAX
9068 +
9069 +/* x86_thread_state64_t has field __rax */
9070 +#undef HAS_X86_THREAD_STATE64___RAX
9071 +
9072  /* Define to 1 if you have the <inttypes.h> header file. */
9073  #undef HAVE_INTTYPES_H
9074  
9075 Index: boehm-gc/include/private/gc_priv.h
9076 ===================================================================
9077 --- boehm-gc/include/private/gc_priv.h  (.../tags/gcc_4_2_0_release)    (revision 125292)
9078 +++ boehm-gc/include/private/gc_priv.h  (.../branches/gcc-4_2-branch)   (revision 125292)
9079 @@ -286,6 +286,53 @@
9080  #endif
9081  
9082  
9083 +#if defined(DARWIN)
9084 +#      if defined(POWERPC)
9085 +#              if CPP_WORDSZ == 32
9086 +#                define GC_THREAD_STATE_T ppc_thread_state_t
9087 +#                define GC_MACH_THREAD_STATE PPC_THREAD_STATE
9088 +#                define GC_MACH_THREAD_STATE_COUNT PPC_THREAD_STATE_COUNT
9089 +#                define GC_MACH_HEADER mach_header
9090 +#                define GC_MACH_SECTION section
9091 +#              else
9092 +#                define GC_THREAD_STATE_T ppc_thread_state64_t
9093 +#                define GC_MACH_THREAD_STATE PPC_THREAD_STATE64
9094 +#                define GC_MACH_THREAD_STATE_COUNT PPC_THREAD_STATE64_COUNT
9095 +#                define GC_MACH_HEADER mach_header_64
9096 +#                define GC_MACH_SECTION section_64
9097 +#              endif
9098 +#      elif defined(I386) || defined(X86_64)
9099 +#              if CPP_WORDSZ == 32
9100 +#                define GC_THREAD_STATE_T x86_thread_state32_t
9101 +#                define GC_MACH_THREAD_STATE x86_THREAD_STATE32
9102 +#                define GC_MACH_THREAD_STATE_COUNT x86_THREAD_STATE32_COUNT
9103 +#                define GC_MACH_HEADER mach_header
9104 +#                define GC_MACH_SECTION section
9105 +#              else
9106 +#                define GC_THREAD_STATE_T x86_thread_state64_t
9107 +#                define GC_MACH_THREAD_STATE x86_THREAD_STATE64
9108 +#                define GC_MACH_THREAD_STATE_COUNT x86_THREAD_STATE64_COUNT
9109 +#                define GC_MACH_HEADER mach_header_64
9110 +#                define GC_MACH_SECTION section_64
9111 +#              endif
9112 +#      else
9113 +#              error define GC_THREAD_STATE_T
9114 +#              define GC_MACH_THREAD_STATE MACHINE_THREAD_STATE
9115 +#              define GC_MACH_THREAD_STATE_COUNT MACHINE_THREAD_STATE_COUNT
9116 +#      endif
9117 +/* Try to work out the right way to access thread state structure members.
9118 +   The structure has changed its definition in different Darwin versions.
9119 +   This now defaults to the (older) names without __, thus hopefully,
9120 +   not breaking any existing Makefile.direct builds.  */
9121 +#      if defined (HAS_PPC_THREAD_STATE___R0) \
9122 +        || defined (HAS_PPC_THREAD_STATE64___R0) \
9123 +        || defined (HAS_X86_THREAD_STATE32___EAX) \
9124 +        || defined (HAS_X86_THREAD_STATE64___RAX)
9125 +#        define THREAD_FLD(x) __ ## x
9126 +#      else
9127 +#        define THREAD_FLD(x) x
9128 +#      endif
9129 +#endif
9130  /*********************************/
9131  /*                               */
9132  /* OS interface routines        */
9133 @@ -468,6 +515,53 @@
9134  #   define GETENV(name) 0
9135  #endif
9136  
9137 +#if defined(DARWIN)
9138 +#      if defined(POWERPC)
9139 +#              if CPP_WORDSZ == 32
9140 +#                define GC_THREAD_STATE_T ppc_thread_state_t
9141 +#                define GC_MACH_THREAD_STATE PPC_THREAD_STATE
9142 +#                define GC_MACH_THREAD_STATE_COUNT PPC_THREAD_STATE_COUNT
9143 +#                define GC_MACH_HEADER mach_header
9144 +#                define GC_MACH_SECTION section
9145 +#              else
9146 +#                define GC_THREAD_STATE_T ppc_thread_state64_t
9147 +#                define GC_MACH_THREAD_STATE PPC_THREAD_STATE64
9148 +#                define GC_MACH_THREAD_STATE_COUNT PPC_THREAD_STATE64_COUNT
9149 +#                define GC_MACH_HEADER mach_header_64
9150 +#                define GC_MACH_SECTION section_64
9151 +#              endif
9152 +#      elif defined(I386) || defined(X86_64)
9153 +#              if CPP_WORDSZ == 32
9154 +#                define GC_THREAD_STATE_T x86_thread_state32_t
9155 +#                define GC_MACH_THREAD_STATE x86_THREAD_STATE32
9156 +#                define GC_MACH_THREAD_STATE_COUNT x86_THREAD_STATE32_COUNT
9157 +#                define GC_MACH_HEADER mach_header
9158 +#                define GC_MACH_SECTION section
9159 +#              else
9160 +#                define GC_THREAD_STATE_T x86_thread_state64_t
9161 +#                define GC_MACH_THREAD_STATE x86_THREAD_STATE64
9162 +#                define GC_MACH_THREAD_STATE_COUNT x86_THREAD_STATE64_COUNT
9163 +#                define GC_MACH_HEADER mach_header_64
9164 +#                define GC_MACH_SECTION section_64
9165 +#              endif
9166 +#      else
9167 +#              error define GC_THREAD_STATE_T
9168 +#              define GC_MACH_THREAD_STATE MACHINE_THREAD_STATE
9169 +#              define GC_MACH_THREAD_STATE_COUNT MACHINE_THREAD_STATE_COUNT
9170 +#      endif
9171 +/* Try to work out the right way to access thread state structure members.
9172 +   The structure has changed its definition in different Darwin versions.
9173 +   This now defaults to the (older) names without __, thus hopefully,
9174 +   not breaking any existing Makefile.direct builds.  */
9175 +#      if defined (HAS_PPC_THREAD_STATE___R0) \
9176 +        || defined (HAS_PPC_THREAD_STATE64___R0) \
9177 +        || defined (HAS_X86_THREAD_STATE32___EAX) \
9178 +        || defined (HAS_X86_THREAD_STATE64___RAX)
9179 +#        define THREAD_FLD(x) __ ## x
9180 +#      else
9181 +#        define THREAD_FLD(x) x
9182 +#      endif
9183 +#endif
9184  /*********************************/
9185  /*                               */
9186  /* Word-size-dependent defines   */
9187 Index: boehm-gc/include/private/gcconfig.h
9188 ===================================================================
9189 --- boehm-gc/include/private/gcconfig.h (.../tags/gcc_4_2_0_release)    (revision 125292)
9190 +++ boehm-gc/include/private/gcconfig.h (.../branches/gcc-4_2-branch)   (revision 125292)
9191 @@ -302,7 +302,10 @@
9192  #   if defined(__ppc__)  || defined(__ppc64__)
9193  #    define POWERPC
9194  #    define mach_type_known
9195 -#   elif defined(__i386__) || defined(__x86_64)
9196 +#   elif defined(__x86_64__)
9197 +#    define X86_64
9198 +#    define mach_type_known
9199 +#   elif defined(__i386__)
9200  #    define I386
9201  #    define mach_type_known
9202  #   endif
9203 @@ -791,26 +794,29 @@
9204  #     define DATAEND (_end)
9205  #   endif
9206  #   ifdef DARWIN
9207 -#     if defined(__ppc64__) || defined(__x86_64)
9208 +#     define OS_TYPE "DARWIN"
9209 +#     define DYNAMIC_LOADING
9210 +#     if defined(__ppc64__)
9211  #       define ALIGNMENT 8
9212  #       define CPP_WORDSZ 64
9213 +#       define STACKBOTTOM ((ptr_t) 0x7fff5fc00000)
9214 +#       define CACHE_LINE_SIZE 64
9215 +#       ifndef HBLKSIZE
9216 +#         define HBLKSIZE 4096
9217 +#       endif
9218  #     else
9219  #       define ALIGNMENT 4
9220 +#       define STACKBOTTOM ((ptr_t) 0xc0000000)
9221  #     endif
9222 -#     define OS_TYPE "DARWIN"
9223 -#     define DYNAMIC_LOADING
9224        /* XXX: see get_end(3), get_etext() and get_end() should not be used.
9225 -         These aren't used when dyld support is enabled (it is by default) */
9226 +        These aren't used when dyld support is enabled (it is by default) */
9227  #     define DATASTART ((ptr_t) get_etext())
9228  #     define DATAEND   ((ptr_t) get_end())
9229 -#     define STACKBOTTOM ((ptr_t) 0xc0000000)
9230  #     define USE_MMAP
9231  #     define USE_MMAP_ANON
9232  #     define USE_ASM_PUSH_REGS
9233 -      /* This is potentially buggy. It needs more testing. See the comments in
9234 -         os_dep.c.  It relies on threads to track writes. */
9235  #     ifdef GC_DARWIN_THREADS
9236 -/* #       define MPROTECT_VDB -- diabled for now.  May work for some apps. */
9237 +#       define MPROTECT_VDB
9238  #     endif
9239  #     include <unistd.h>
9240  #     define GETPAGESIZE() getpagesize()
9241 @@ -822,7 +828,7 @@
9242           __asm__ __volatile__ ("dcbtst 0,%0" : : "r" ((const void *) (x)))
9243  #     endif
9244        /* There seems to be some issues with trylock hanging on darwin. This
9245 -         should be looked into some more */
9246 +        should be looked into some more */
9247  #     define NO_PTHREAD_TRYLOCK
9248  #   endif
9249  #   ifdef FREEBSD
9250 @@ -1317,23 +1323,21 @@
9251  #     define DARWIN_DONT_PARSE_STACK
9252  #     define DYNAMIC_LOADING
9253        /* XXX: see get_end(3), get_etext() and get_end() should not be used.
9254 -        These aren't used when dyld support is enabled (it is by default) */
9255 +        These aren't used when dyld support is enabled (it is by default) */
9256  #     define DATASTART ((ptr_t) get_etext())
9257  #     define DATAEND   ((ptr_t) get_end())
9258  #     define STACKBOTTOM ((ptr_t) 0xc0000000)
9259  #     define USE_MMAP
9260  #     define USE_MMAP_ANON
9261  #     define USE_ASM_PUSH_REGS
9262 -      /* This is potentially buggy. It needs more testing. See the comments in
9263 -        os_dep.c.  It relies on threads to track writes. */
9264  #     ifdef GC_DARWIN_THREADS
9265 -/* #       define MPROTECT_VDB -- disabled for now.  May work for some apps. */
9266 +#       define MPROTECT_VDB
9267  #     endif
9268  #     include <unistd.h>
9269  #     define GETPAGESIZE() getpagesize()
9270        /* There seems to be some issues with trylock hanging on darwin. This
9271 -         should be looked into some more */
9272 -#      define NO_PTHREAD_TRYLOCK
9273 +        should be looked into some more */
9274 +#     define NO_PTHREAD_TRYLOCK
9275  #   endif /* DARWIN */
9276  # endif
9277  
9278 @@ -1986,6 +1990,26 @@
9279  #          define PREFETCH_FOR_WRITE(x) __builtin_prefetch((x), 1)
9280  #      endif
9281  #   endif
9282 +#   ifdef DARWIN
9283 +#     define OS_TYPE "DARWIN"
9284 +#     define DARWIN_DONT_PARSE_STACK
9285 +#     define DYNAMIC_LOADING
9286 +      /* XXX: see get_end(3), get_etext() and get_end() should not be used.
9287 +        These aren't used when dyld support is enabled (it is by default) */
9288 +#     define DATASTART ((ptr_t) get_etext())
9289 +#     define DATAEND   ((ptr_t) get_end())
9290 +#     define STACKBOTTOM ((ptr_t) 0x7fff5fc00000)
9291 +#     define USE_MMAP
9292 +#     define USE_MMAP_ANON
9293 +#     ifdef GC_DARWIN_THREADS
9294 +#       define MPROTECT_VDB
9295 +#     endif
9296 +#     include <unistd.h>
9297 +#     define GETPAGESIZE() getpagesize()
9298 +      /* There seems to be some issues with trylock hanging on darwin. This
9299 +        should be looked into some more */
9300 +#     define NO_PTHREAD_TRYLOCK
9301 +#   endif
9302  #   ifdef FREEBSD
9303  #      define OS_TYPE "FREEBSD"
9304  #      ifndef GC_FREEBSD_THREADS
9305 Index: boehm-gc/ChangeLog
9306 ===================================================================
9307 --- boehm-gc/ChangeLog  (.../tags/gcc_4_2_0_release)    (revision 125292)
9308 +++ boehm-gc/ChangeLog  (.../branches/gcc-4_2-branch)   (revision 125292)
9309 @@ -1,3 +1,67 @@
9310 +2007-05-22  Andreas Tobler  <a.tobler@schweiz.org>
9311 +
9312 +       * Backport r124870 from main.
9313 +
9314 +       2007-05-20  Andreas Tobler  <a.tobler@schweiz.org>
9315 +
9316 +       * configure.ac: Introduce extra_ldflags_libgc. Use it for Darwin.
9317 +       * configure: Regenerate.
9318 +       * Makefile.am (libgc_la_LDFLAGS): Use extra_ldflags_libgc.
9319 +       * Makefile.in: Regenerate.
9320 +       * include/Makefile.in: Regenerate.
9321 +       * include/private/gcconfig.h: Enable MPROTECT_VDB for all Darwin
9322 +       targets. Remove comments. Prepare ppc64 support for Darwin.
9323 +
9324 +2007-05-19  Andreas Tobler  <a.tobler@schweiz.org>
9325 +
9326 +       * Backport r120684, 120801, 120853, 120874 and 120977 from main.
9327 +
9328 +       2007-01-19  Andreas Tobler  <a.tobler@schweiz.org>
9329 +
9330 +       * os_dep.c (defined(MPROTECT_VDB) && defined(DARWIN)): Moved recently
9331 +       added defines to include/private/gc_priv.h
9332 +       * darwin_stop_world.c: Removed the above defines.
9333 +       (catch_exception_raise): Added THREAD_FLD in exc_state for POWERPC too.
9334 +       * include/private/gc_priv.h: Moved definitions from darwin_stop_world.c
9335 +       and os_dep.c to here. Fixed THREAD definition fixes for ppc64.
9336 +
9337 +       2007-01-17  Mike Stump  <mrs@apple.com>
9338 +
9339 +       * os_dep.c: Fix i686-apple-darwin9 builds.
9340 +
9341 +       2007-01-17  Andreas Tobler  <a.tobler@schweiz.org>
9342 +
9343 +       * include/gc_config.h.in: Regenerate.
9344 +
9345 +       2007-01-15  Andreas Tobler  <a.tobler@schweiz.org>
9346 +
9347 +       * os_dep.c (defined(MPROTECT_VDB) && defined(DARWIN)): Adjust mail
9348 +       reference.
9349 +       (catch_exception_raise): Fix typo in the I386 exc_state.
9350 +
9351 +       2007-01-11  Andreas Tobler  <a.tobler@schweiz.org>
9352 +
9353 +       * configure.ac: Replaced HAS_I386_THREAD_STATE_* with
9354 +       HAS_X86_THREAD_STATE32_* and HAS_X86_THREAD_STATE64_* respectively.
9355 +       * configure: Regenerated.
9356 +       * include/private/gcconfig.h (DARWIN): Added X86_64 define for Darwin.
9357 +       Added base definitions for the X86_64 Darwin port.
9358 +       * include/private/gc_priv.h: Added definitions for Darwin MACH thread
9359 +       operations. Moved existing THREAD_STATE info from darwin_stop_world.c.
9360 +       * darwin_stop_world.c: Removed THREAD_STATE info. Added
9361 +       HAS_X86_THREAD_STATE64___RAX. And replaced HAS_I386_THREAD_STATE___EAX
9362 +       with HAS_X86_THREAD_STATE32___EAX.
9363 +       (GC_push_all_stacks): Use GC_MACH_THREAD_STATE_COUNT. Add code for
9364 +       X86_64 Darwin.
9365 +       * dyn_load.c (GC_dyld_name_for_hdr): Use GC_MACH_HEADER.
9366 +       (GC_dyld_image_add): Use GC_MACH_HEADER and GC_MACH_SECTION.
9367 +       Distinguish between getsectbynamefromheader_64 and
9368 +       getsectbynamefromheader.
9369 +       (GC_dyld_image_remove): Likewise.
9370 +       * os_dep.c (GC_dirty_init): Use GC_MACH_THREAD_STATE.
9371 +       (catch_exception_raise): Introduce exception information for I386 and
9372 +       X86_64 Darwin. Add X86_64 for exc_state.faultvaddr.
9373 +
9374  2007-05-13  Release Manager
9375  
9376         * GCC 4.2.0 released.
9377 Index: boehm-gc/configure
9378 ===================================================================
9379 --- boehm-gc/configure  (.../tags/gcc_4_2_0_release)    (revision 125292)
9380 +++ boehm-gc/configure  (.../branches/gcc-4_2-branch)   (revision 125292)
9381 @@ -309,7 +309,7 @@
9382  # include <unistd.h>
9383  #endif"
9384  
9385 -ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS multi_basedir build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os target_noncanonical mkinstalldirs INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar CC ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE CXX ac_ct_CXX CXXDEPMODE am__fastdepCXX_TRUE am__fastdepCXX_FALSE CFLAGS CXXFLAGS CCAS CCASFLAGS AS ac_ct_AS AR ac_ct_AR RANLIB ac_ct_RANLIB MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT GC_CFLAGS LN_S LIBTOOL CXXCPP CPPFLAGS THREADLIBS POWERPC_DARWIN_TRUE POWERPC_DARWIN_FALSE EXTRA_TEST_LIBS target_all CPLUSPLUS_TRUE CPLUSPLUS_FALSE AM_CPPFLAGS addobjs addincludes addlibs addtests CPP EGREP MY_CFLAGS toolexecdir toolexeclibdir LIBOBJS LTLIBOBJS'
9386 +ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS multi_basedir build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os target_noncanonical mkinstalldirs INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar CC ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE CXX ac_ct_CXX CXXDEPMODE am__fastdepCXX_TRUE am__fastdepCXX_FALSE CFLAGS CXXFLAGS CCAS CCASFLAGS AS ac_ct_AS AR ac_ct_AR RANLIB ac_ct_RANLIB MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT GC_CFLAGS LN_S LIBTOOL CXXCPP CPPFLAGS THREADLIBS POWERPC_DARWIN_TRUE POWERPC_DARWIN_FALSE extra_ldflags_libgc EXTRA_TEST_LIBS target_all CPLUSPLUS_TRUE CPLUSPLUS_FALSE AM_CPPFLAGS addobjs addincludes addlibs addtests CPP EGREP MY_CFLAGS toolexecdir toolexeclibdir LIBOBJS LTLIBOBJS'
9387  ac_subst_files=''
9388  
9389  # Initialize some variables set by options.
9390 @@ -5741,7 +5741,7 @@
9391  if test $ac_cv_member_ppc_thread_state_t_r0 = yes; then
9392  
9393  cat >>confdefs.h <<\_ACEOF
9394 -#define HAS_PPC_THREAD_STATE_R0
9395 +#define HAS_PPC_THREAD_STATE_R0 1
9396  _ACEOF
9397  
9398  fi
9399 @@ -5852,7 +5852,7 @@
9400  if test $ac_cv_member_ppc_thread_state_t___r0 = yes; then
9401  
9402  cat >>confdefs.h <<\_ACEOF
9403 -#define HAS_PPC_THREAD_STATE___R0
9404 +#define HAS_PPC_THREAD_STATE___R0 1
9405  _ACEOF
9406  
9407  fi
9408 @@ -5963,7 +5963,7 @@
9409  if test $ac_cv_member_ppc_thread_state64_t_r0 = yes; then
9410  
9411  cat >>confdefs.h <<\_ACEOF
9412 -#define HAS_PPC_THREAD_STATE64_R0
9413 +#define HAS_PPC_THREAD_STATE64_R0 1
9414  _ACEOF
9415  
9416  fi
9417 @@ -6074,16 +6074,16 @@
9418  if test $ac_cv_member_ppc_thread_state64_t___r0 = yes; then
9419  
9420  cat >>confdefs.h <<\_ACEOF
9421 -#define HAS_PPC_THREAD_STATE64___R0
9422 +#define HAS_PPC_THREAD_STATE64___R0 1
9423  _ACEOF
9424  
9425  fi
9426  
9427      ;;
9428    i?86*-*-darwin*)
9429 -    echo "$as_me:$LINENO: checking for i386_thread_state_t.eax" >&5
9430 -echo $ECHO_N "checking for i386_thread_state_t.eax... $ECHO_C" >&6
9431 -if test "${ac_cv_member_i386_thread_state_t_eax+set}" = set; then
9432 +    echo "$as_me:$LINENO: checking for x86_thread_state32_t.eax" >&5
9433 +echo $ECHO_N "checking for x86_thread_state32_t.eax... $ECHO_C" >&6
9434 +if test "${ac_cv_member_x86_thread_state32_t_eax+set}" = set; then
9435    echo $ECHO_N "(cached) $ECHO_C" >&6
9436  else
9437    cat >conftest.$ac_ext <<_ACEOF
9438 @@ -6093,12 +6093,12 @@
9439  cat >>conftest.$ac_ext <<_ACEOF
9440  /* end confdefs.h.  */
9441  #include <sys/cdefs.h>
9442 -#include <mach/thread_status.h>
9443 +      #include <mach/thread_status.h>
9444  
9445  int
9446  main ()
9447  {
9448 -static i386_thread_state_t ac_aggr;
9449 +static x86_thread_state32_t ac_aggr;
9450  if (ac_aggr.eax)
9451  return 0;
9452    ;
9453 @@ -6127,7 +6127,7 @@
9454    ac_status=$?
9455    echo "$as_me:$LINENO: \$? = $ac_status" >&5
9456    (exit $ac_status); }; }; then
9457 -  ac_cv_member_i386_thread_state_t_eax=yes
9458 +  ac_cv_member_x86_thread_state32_t_eax=yes
9459  else
9460    echo "$as_me: failed program was:" >&5
9461  sed 's/^/| /' conftest.$ac_ext >&5
9462 @@ -6139,12 +6139,12 @@
9463  cat >>conftest.$ac_ext <<_ACEOF
9464  /* end confdefs.h.  */
9465  #include <sys/cdefs.h>
9466 -#include <mach/thread_status.h>
9467 +      #include <mach/thread_status.h>
9468  
9469  int
9470  main ()
9471  {
9472 -static i386_thread_state_t ac_aggr;
9473 +static x86_thread_state32_t ac_aggr;
9474  if (sizeof ac_aggr.eax)
9475  return 0;
9476    ;
9477 @@ -6173,30 +6173,30 @@
9478    ac_status=$?
9479    echo "$as_me:$LINENO: \$? = $ac_status" >&5
9480    (exit $ac_status); }; }; then
9481 -  ac_cv_member_i386_thread_state_t_eax=yes
9482 +  ac_cv_member_x86_thread_state32_t_eax=yes
9483  else
9484    echo "$as_me: failed program was:" >&5
9485  sed 's/^/| /' conftest.$ac_ext >&5
9486  
9487 -ac_cv_member_i386_thread_state_t_eax=no
9488 +ac_cv_member_x86_thread_state32_t_eax=no
9489  fi
9490  rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
9491  fi
9492  rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
9493  fi
9494 -echo "$as_me:$LINENO: result: $ac_cv_member_i386_thread_state_t_eax" >&5
9495 -echo "${ECHO_T}$ac_cv_member_i386_thread_state_t_eax" >&6
9496 -if test $ac_cv_member_i386_thread_state_t_eax = yes; then
9497 +echo "$as_me:$LINENO: result: $ac_cv_member_x86_thread_state32_t_eax" >&5
9498 +echo "${ECHO_T}$ac_cv_member_x86_thread_state32_t_eax" >&6
9499 +if test $ac_cv_member_x86_thread_state32_t_eax = yes; then
9500  
9501  cat >>confdefs.h <<\_ACEOF
9502 -#define HAS_I386_THREAD_STATE_EAX
9503 +#define HAS_X86_THREAD_STATE32_EAX 1
9504  _ACEOF
9505  
9506  fi
9507  
9508 -    echo "$as_me:$LINENO: checking for i386_thread_state_t.__eax" >&5
9509 -echo $ECHO_N "checking for i386_thread_state_t.__eax... $ECHO_C" >&6
9510 -if test "${ac_cv_member_i386_thread_state_t___eax+set}" = set; then
9511 +    echo "$as_me:$LINENO: checking for x86_thread_state32_t.__eax" >&5
9512 +echo $ECHO_N "checking for x86_thread_state32_t.__eax... $ECHO_C" >&6
9513 +if test "${ac_cv_member_x86_thread_state32_t___eax+set}" = set; then
9514    echo $ECHO_N "(cached) $ECHO_C" >&6
9515  else
9516    cat >conftest.$ac_ext <<_ACEOF
9517 @@ -6206,12 +6206,12 @@
9518  cat >>conftest.$ac_ext <<_ACEOF
9519  /* end confdefs.h.  */
9520  #include <sys/cdefs.h>
9521 -#include <mach/thread_status.h>
9522 +      #include <mach/thread_status.h>
9523  
9524  int
9525  main ()
9526  {
9527 -static i386_thread_state_t ac_aggr;
9528 +static x86_thread_state32_t ac_aggr;
9529  if (ac_aggr.__eax)
9530  return 0;
9531    ;
9532 @@ -6240,7 +6240,7 @@
9533    ac_status=$?
9534    echo "$as_me:$LINENO: \$? = $ac_status" >&5
9535    (exit $ac_status); }; }; then
9536 -  ac_cv_member_i386_thread_state_t___eax=yes
9537 +  ac_cv_member_x86_thread_state32_t___eax=yes
9538  else
9539    echo "$as_me: failed program was:" >&5
9540  sed 's/^/| /' conftest.$ac_ext >&5
9541 @@ -6252,12 +6252,12 @@
9542  cat >>conftest.$ac_ext <<_ACEOF
9543  /* end confdefs.h.  */
9544  #include <sys/cdefs.h>
9545 -#include <mach/thread_status.h>
9546 +      #include <mach/thread_status.h>
9547  
9548  int
9549  main ()
9550  {
9551 -static i386_thread_state_t ac_aggr;
9552 +static x86_thread_state32_t ac_aggr;
9553  if (sizeof ac_aggr.__eax)
9554  return 0;
9555    ;
9556 @@ -6286,28 +6286,256 @@
9557    ac_status=$?
9558    echo "$as_me:$LINENO: \$? = $ac_status" >&5
9559    (exit $ac_status); }; }; then
9560 -  ac_cv_member_i386_thread_state_t___eax=yes
9561 +  ac_cv_member_x86_thread_state32_t___eax=yes
9562  else
9563    echo "$as_me: failed program was:" >&5
9564  sed 's/^/| /' conftest.$ac_ext >&5
9565  
9566 -ac_cv_member_i386_thread_state_t___eax=no
9567 +ac_cv_member_x86_thread_state32_t___eax=no
9568  fi
9569  rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
9570  fi
9571  rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
9572  fi
9573 -echo "$as_me:$LINENO: result: $ac_cv_member_i386_thread_state_t___eax" >&5
9574 -echo "${ECHO_T}$ac_cv_member_i386_thread_state_t___eax" >&6
9575 -if test $ac_cv_member_i386_thread_state_t___eax = yes; then
9576 +echo "$as_me:$LINENO: result: $ac_cv_member_x86_thread_state32_t___eax" >&5
9577 +echo "${ECHO_T}$ac_cv_member_x86_thread_state32_t___eax" >&6
9578 +if test $ac_cv_member_x86_thread_state32_t___eax = yes; then
9579  
9580  cat >>confdefs.h <<\_ACEOF
9581 -#define HAS_I386_THREAD_STATE___EAX
9582 +#define HAS_X86_THREAD_STATE32___EAX 1
9583  _ACEOF
9584  
9585  fi
9586  
9587      ;;
9588 +  x86_64-*-darwin*)
9589 +    echo "$as_me:$LINENO: checking for x86_thread_state64_t.rax" >&5
9590 +echo $ECHO_N "checking for x86_thread_state64_t.rax... $ECHO_C" >&6
9591 +if test "${ac_cv_member_x86_thread_state64_t_rax+set}" = set; then
9592 +  echo $ECHO_N "(cached) $ECHO_C" >&6
9593 +else
9594 +  cat >conftest.$ac_ext <<_ACEOF
9595 +/* confdefs.h.  */
9596 +_ACEOF
9597 +cat confdefs.h >>conftest.$ac_ext
9598 +cat >>conftest.$ac_ext <<_ACEOF
9599 +/* end confdefs.h.  */
9600 +#include <sys/cdefs.h>
9601 +      #include <mach/thread_status.h>
9602 +
9603 +int
9604 +main ()
9605 +{
9606 +static x86_thread_state64_t ac_aggr;
9607 +if (ac_aggr.rax)
9608 +return 0;
9609 +  ;
9610 +  return 0;
9611 +}
9612 +_ACEOF
9613 +rm -f conftest.$ac_objext
9614 +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
9615 +  (eval $ac_compile) 2>conftest.er1
9616 +  ac_status=$?
9617 +  grep -v '^ *+' conftest.er1 >conftest.err
9618 +  rm -f conftest.er1
9619 +  cat conftest.err >&5
9620 +  echo "$as_me:$LINENO: \$? = $ac_status" >&5
9621 +  (exit $ac_status); } &&
9622 +        { ac_try='test -z "$ac_c_werror_flag"
9623 +                        || test ! -s conftest.err'
9624 +  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
9625 +  (eval $ac_try) 2>&5
9626 +  ac_status=$?
9627 +  echo "$as_me:$LINENO: \$? = $ac_status" >&5
9628 +  (exit $ac_status); }; } &&
9629 +        { ac_try='test -s conftest.$ac_objext'
9630 +  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
9631 +  (eval $ac_try) 2>&5
9632 +  ac_status=$?
9633 +  echo "$as_me:$LINENO: \$? = $ac_status" >&5
9634 +  (exit $ac_status); }; }; then
9635 +  ac_cv_member_x86_thread_state64_t_rax=yes
9636 +else
9637 +  echo "$as_me: failed program was:" >&5
9638 +sed 's/^/| /' conftest.$ac_ext >&5
9639 +
9640 +cat >conftest.$ac_ext <<_ACEOF
9641 +/* confdefs.h.  */
9642 +_ACEOF
9643 +cat confdefs.h >>conftest.$ac_ext
9644 +cat >>conftest.$ac_ext <<_ACEOF
9645 +/* end confdefs.h.  */
9646 +#include <sys/cdefs.h>
9647 +      #include <mach/thread_status.h>
9648 +
9649 +int
9650 +main ()
9651 +{
9652 +static x86_thread_state64_t ac_aggr;
9653 +if (sizeof ac_aggr.rax)
9654 +return 0;
9655 +  ;
9656 +  return 0;
9657 +}
9658 +_ACEOF
9659 +rm -f conftest.$ac_objext
9660 +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
9661 +  (eval $ac_compile) 2>conftest.er1
9662 +  ac_status=$?
9663 +  grep -v '^ *+' conftest.er1 >conftest.err
9664 +  rm -f conftest.er1
9665 +  cat conftest.err >&5
9666 +  echo "$as_me:$LINENO: \$? = $ac_status" >&5
9667 +  (exit $ac_status); } &&
9668 +        { ac_try='test -z "$ac_c_werror_flag"
9669 +                        || test ! -s conftest.err'
9670 +  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
9671 +  (eval $ac_try) 2>&5
9672 +  ac_status=$?
9673 +  echo "$as_me:$LINENO: \$? = $ac_status" >&5
9674 +  (exit $ac_status); }; } &&
9675 +        { ac_try='test -s conftest.$ac_objext'
9676 +  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
9677 +  (eval $ac_try) 2>&5
9678 +  ac_status=$?
9679 +  echo "$as_me:$LINENO: \$? = $ac_status" >&5
9680 +  (exit $ac_status); }; }; then
9681 +  ac_cv_member_x86_thread_state64_t_rax=yes
9682 +else
9683 +  echo "$as_me: failed program was:" >&5
9684 +sed 's/^/| /' conftest.$ac_ext >&5
9685 +
9686 +ac_cv_member_x86_thread_state64_t_rax=no
9687 +fi
9688 +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
9689 +fi
9690 +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
9691 +fi
9692 +echo "$as_me:$LINENO: result: $ac_cv_member_x86_thread_state64_t_rax" >&5
9693 +echo "${ECHO_T}$ac_cv_member_x86_thread_state64_t_rax" >&6
9694 +if test $ac_cv_member_x86_thread_state64_t_rax = yes; then
9695 +
9696 +cat >>confdefs.h <<\_ACEOF
9697 +#define HAS_X86_THREAD_STATE64_RAX 1
9698 +_ACEOF
9699 +
9700 +fi
9701 +
9702 +    echo "$as_me:$LINENO: checking for x86_thread_state64_t.__rax" >&5
9703 +echo $ECHO_N "checking for x86_thread_state64_t.__rax... $ECHO_C" >&6
9704 +if test "${ac_cv_member_x86_thread_state64_t___rax+set}" = set; then
9705 +  echo $ECHO_N "(cached) $ECHO_C" >&6
9706 +else
9707 +  cat >conftest.$ac_ext <<_ACEOF
9708 +/* confdefs.h.  */
9709 +_ACEOF
9710 +cat confdefs.h >>conftest.$ac_ext
9711 +cat >>conftest.$ac_ext <<_ACEOF
9712 +/* end confdefs.h.  */
9713 +#include <sys/cdefs.h>
9714 +      #include <mach/thread_status.h>
9715 +
9716 +int
9717 +main ()
9718 +{
9719 +static x86_thread_state64_t ac_aggr;
9720 +if (ac_aggr.__rax)
9721 +return 0;
9722 +  ;
9723 +  return 0;
9724 +}
9725 +_ACEOF
9726 +rm -f conftest.$ac_objext
9727 +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
9728 +  (eval $ac_compile) 2>conftest.er1
9729 +  ac_status=$?
9730 +  grep -v '^ *+' conftest.er1 >conftest.err
9731 +  rm -f conftest.er1
9732 +  cat conftest.err >&5
9733 +  echo "$as_me:$LINENO: \$? = $ac_status" >&5
9734 +  (exit $ac_status); } &&
9735 +        { ac_try='test -z "$ac_c_werror_flag"
9736 +                        || test ! -s conftest.err'
9737 +  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
9738 +  (eval $ac_try) 2>&5
9739 +  ac_status=$?
9740 +  echo "$as_me:$LINENO: \$? = $ac_status" >&5
9741 +  (exit $ac_status); }; } &&
9742 +        { ac_try='test -s conftest.$ac_objext'
9743 +  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
9744 +  (eval $ac_try) 2>&5
9745 +  ac_status=$?
9746 +  echo "$as_me:$LINENO: \$? = $ac_status" >&5
9747 +  (exit $ac_status); }; }; then
9748 +  ac_cv_member_x86_thread_state64_t___rax=yes
9749 +else
9750 +  echo "$as_me: failed program was:" >&5
9751 +sed 's/^/| /' conftest.$ac_ext >&5
9752 +
9753 +cat >conftest.$ac_ext <<_ACEOF
9754 +/* confdefs.h.  */
9755 +_ACEOF
9756 +cat confdefs.h >>conftest.$ac_ext
9757 +cat >>conftest.$ac_ext <<_ACEOF
9758 +/* end confdefs.h.  */
9759 +#include <sys/cdefs.h>
9760 +      #include <mach/thread_status.h>
9761 +
9762 +int
9763 +main ()
9764 +{
9765 +static x86_thread_state64_t ac_aggr;
9766 +if (sizeof ac_aggr.__rax)
9767 +return 0;
9768 +  ;
9769 +  return 0;
9770 +}
9771 +_ACEOF
9772 +rm -f conftest.$ac_objext
9773 +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
9774 +  (eval $ac_compile) 2>conftest.er1
9775 +  ac_status=$?
9776 +  grep -v '^ *+' conftest.er1 >conftest.err
9777 +  rm -f conftest.er1
9778 +  cat conftest.err >&5
9779 +  echo "$as_me:$LINENO: \$? = $ac_status" >&5
9780 +  (exit $ac_status); } &&
9781 +        { ac_try='test -z "$ac_c_werror_flag"
9782 +                        || test ! -s conftest.err'
9783 +  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
9784 +  (eval $ac_try) 2>&5
9785 +  ac_status=$?
9786 +  echo "$as_me:$LINENO: \$? = $ac_status" >&5
9787 +  (exit $ac_status); }; } &&
9788 +        { ac_try='test -s conftest.$ac_objext'
9789 +  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
9790 +  (eval $ac_try) 2>&5
9791 +  ac_status=$?
9792 +  echo "$as_me:$LINENO: \$? = $ac_status" >&5
9793 +  (exit $ac_status); }; }; then
9794 +  ac_cv_member_x86_thread_state64_t___rax=yes
9795 +else
9796 +  echo "$as_me: failed program was:" >&5
9797 +sed 's/^/| /' conftest.$ac_ext >&5
9798 +
9799 +ac_cv_member_x86_thread_state64_t___rax=no
9800 +fi
9801 +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
9802 +fi
9803 +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
9804 +fi
9805 +echo "$as_me:$LINENO: result: $ac_cv_member_x86_thread_state64_t___rax" >&5
9806 +echo "${ECHO_T}$ac_cv_member_x86_thread_state64_t___rax" >&6
9807 +if test $ac_cv_member_x86_thread_state64_t___rax = yes; then
9808 +
9809 +cat >>confdefs.h <<\_ACEOF
9810 +#define HAS_X86_THREAD_STATE64___RAX 1
9811 +_ACEOF
9812 +
9813 +fi
9814 +
9815 +     ;;
9816    *) ;;
9817  esac
9818  
9819 @@ -6392,8 +6620,16 @@
9820      ;;
9821  esac
9822  
9823 +# extra LD Flags which are required for targets
9824 +case "${host}" in
9825 +  *-*-darwin*)
9826 +    extra_ldflags_libgc=-Wl,-single_module
9827 +    ;;
9828 +esac
9829  
9830  
9831 +
9832 +
9833  target_all=libgcjgc.la
9834  
9835  
9836 @@ -8246,6 +8482,7 @@
9837  s,@THREADLIBS@,$THREADLIBS,;t t
9838  s,@POWERPC_DARWIN_TRUE@,$POWERPC_DARWIN_TRUE,;t t
9839  s,@POWERPC_DARWIN_FALSE@,$POWERPC_DARWIN_FALSE,;t t
9840 +s,@extra_ldflags_libgc@,$extra_ldflags_libgc,;t t
9841  s,@EXTRA_TEST_LIBS@,$EXTRA_TEST_LIBS,;t t
9842  s,@target_all@,$target_all,;t t
9843  s,@CPLUSPLUS_TRUE@,$CPLUSPLUS_TRUE,;t t
9844 Index: boehm-gc/os_dep.c
9845 ===================================================================
9846 --- boehm-gc/os_dep.c   (.../tags/gcc_4_2_0_release)    (revision 125292)
9847 +++ boehm-gc/os_dep.c   (.../branches/gcc-4_2-branch)   (revision 125292)
9848 @@ -3371,7 +3371,7 @@
9849        1. Apple's mach/xnu documentation
9850        2. Timothy J. Wood's "Mach Exception Handlers 101" post to the
9851           omnigroup's macosx-dev list. 
9852 -         www.omnigroup.com/mailman/archive/macosx-dev/2000-June/002030.html
9853 +         www.omnigroup.com/mailman/archive/macosx-dev/2000-June/014178.html
9854        3. macosx-nat.c from Apple's GDB source code.
9855  */
9856     
9857 @@ -3683,7 +3683,7 @@
9858          mask,
9859          GC_ports.exception,
9860          EXCEPTION_DEFAULT,
9861 -        MACHINE_THREAD_STATE
9862 +        GC_MACH_THREAD_STATE
9863      );
9864      if(r != KERN_SUCCESS) ABORT("task_set_exception_ports failed");
9865  
9866 @@ -3802,10 +3802,16 @@
9867          mach_msg_type_number_t exc_state_count = PPC_EXCEPTION_STATE64_COUNT;
9868          ppc_exception_state64_t exc_state;
9869  #     endif
9870 -#   elif defined(I386)
9871 -        thread_state_flavor_t flavor = i386_EXCEPTION_STATE;
9872 -        mach_msg_type_number_t exc_state_count = i386_EXCEPTION_STATE_COUNT;
9873 -        i386_exception_state_t exc_state;
9874 +#   elif defined(I386) || defined(X86_64)
9875 +#     if CPP_WORDSZ == 32
9876 +       thread_state_flavor_t flavor = x86_EXCEPTION_STATE32;
9877 +       mach_msg_type_number_t exc_state_count = x86_EXCEPTION_STATE32_COUNT;
9878 +       x86_exception_state32_t exc_state;
9879 +#     else
9880 +       thread_state_flavor_t flavor = x86_EXCEPTION_STATE64;
9881 +       mach_msg_type_number_t exc_state_count = x86_EXCEPTION_STATE64_COUNT;
9882 +       x86_exception_state64_t exc_state;
9883 +#     endif
9884  #   else
9885  #      error FIXME for non-ppc darwin
9886  #   endif
9887 @@ -3838,9 +3844,9 @@
9888      
9889      /* This is the address that caused the fault */
9890  #if defined(POWERPC)
9891 -    addr = (char*) exc_state.dar;
9892 -#elif defined (I386)
9893 -    addr = (char*) exc_state.faultvaddr;
9894 +    addr = (char*) exc_state. THREAD_FLD(dar);
9895 +#elif defined (I386) || defined (X86_64)
9896 +    addr = (char*) exc_state. THREAD_FLD(faultvaddr);
9897  #else
9898  #   error FIXME for non POWERPC/I386
9899  #endif
9900 Index: boehm-gc/Makefile.am
9901 ===================================================================
9902 --- boehm-gc/Makefile.am        (.../tags/gcc_4_2_0_release)    (revision 125292)
9903 +++ boehm-gc/Makefile.am        (.../branches/gcc-4_2-branch)   (revision 125292)
9904 @@ -33,11 +33,13 @@
9905  rs6000_mach_dep.s sparc_mach_dep.S sparc_netbsd_mach_dep.s \
9906  sparc_sunos4_mach_dep.s ia64_save_regs_in_stack.s
9907  
9908 +extra_ldflags_libgc = @extra_ldflags_libgc@
9909 +
9910  # Include THREADLIBS here to ensure that the correct versions of
9911  # linuxthread semaphore functions get linked:
9912  libgcjgc_la_LIBADD = @addobjs@ $(THREADLIBS) $(UNWINDLIBS)
9913  libgcjgc_la_DEPENDENCIES = @addobjs@
9914 -libgcjgc_la_LDFLAGS = -version-info 1:2:0 -rpath $(toolexeclibdir)
9915 +libgcjgc_la_LDFLAGS = $(extra_ldflags_libgc) -version-info 1:2:0 -rpath $(toolexeclibdir)
9916  
9917  libgcjgc_convenience_la_LIBADD = @addobjs@
9918  libgcjgc_convenience_la_DEPENDENCIES = @addobjs@
9919 Index: boehm-gc/dyn_load.c
9920 ===================================================================
9921 --- boehm-gc/dyn_load.c (.../tags/gcc_4_2_0_release)    (revision 125292)
9922 +++ boehm-gc/dyn_load.c (.../branches/gcc-4_2-branch)   (revision 125292)
9923 @@ -1152,7 +1152,7 @@
9924  };
9925      
9926  #ifdef DARWIN_DEBUG
9927 -static const char *GC_dyld_name_for_hdr(struct mach_header *hdr) {
9928 +static const char *GC_dyld_name_for_hdr(const struct GC_MACH_HEADER *hdr) {
9929      unsigned long i,c;
9930      c = _dyld_image_count();
9931      for(i=0;i<c;i++) if(_dyld_get_image_header(i) == hdr)
9932 @@ -1162,12 +1162,17 @@
9933  #endif
9934          
9935  /* This should never be called by a thread holding the lock */
9936 -static void GC_dyld_image_add(struct mach_header* hdr, unsigned long slide) {
9937 +static void GC_dyld_image_add(const struct GC_MACH_HEADER *hdr, intptr_t slide)
9938 +{
9939      unsigned long start,end,i;
9940 -    const struct section *sec;
9941 +    const struct GC_MACH_SECTION *sec;
9942      if (GC_no_dls) return;
9943      for(i=0;i<sizeof(GC_dyld_sections)/sizeof(GC_dyld_sections[0]);i++) {
9944 -        sec = getsectbynamefromheader(
9945 +#   if defined (__LP64__)
9946 +      sec = getsectbynamefromheader_64(
9947 +#   else
9948 +      sec = getsectbynamefromheader(
9949 +#   endif
9950              hdr,GC_dyld_sections[i].seg,GC_dyld_sections[i].sect);
9951          if(sec == NULL || sec->size == 0) continue;
9952          start = slide + sec->addr;
9953 @@ -1184,11 +1189,16 @@
9954  }
9955  
9956  /* This should never be called by a thread holding the lock */
9957 -static void GC_dyld_image_remove(struct mach_header* hdr, unsigned long slide) {
9958 +static void GC_dyld_image_remove(const struct GC_MACH_HEADER *hdr,
9959 +                                intptr_t slide) {
9960      unsigned long start,end,i;
9961 -    const struct section *sec;
9962 +    const struct GC_MACH_SECTION *sec;
9963      for(i=0;i<sizeof(GC_dyld_sections)/sizeof(GC_dyld_sections[0]);i++) {
9964 -        sec = getsectbynamefromheader(
9965 +#   if defined (__LP64__)
9966 +      sec = getsectbynamefromheader_64(
9967 +#   else
9968 +      sec = getsectbynamefromheader(
9969 +#   endif
9970              hdr,GC_dyld_sections[i].seg,GC_dyld_sections[i].sect);
9971          if(sec == NULL || sec->size == 0) continue;
9972          start = slide + sec->addr;
9973 Index: configure.in
9974 ===================================================================
9975 --- configure.in        (.../tags/gcc_4_2_0_release)    (revision 125292)
9976 +++ configure.in        (.../branches/gcc-4_2-branch)   (revision 125292)
9977 @@ -2419,7 +2419,13 @@
9978    # Pass -fkeep-inline-functions for stage 1 if the GCC version supports it.
9979    CFLAGS="$CFLAGS -fkeep-inline-functions"
9980    AC_MSG_CHECKING([whether -fkeep-inline-functions is supported])
9981 -  AC_TRY_COMPILE(,,
9982 +  AC_TRY_COMPILE([
9983 +#if (__GNUC__ < 3) \
9984 +    || (__GNUC__ == 3 && (__GNUC_MINOR__ < 3 \
9985 +                         || (__GNUC_MINOR__ == 3 && __GNUC_PATCHLEVEL__ < 1)))
9986 +#error http://gcc.gnu.org/PR29382
9987 +#endif
9988 +    ],,
9989      [AC_MSG_RESULT([yes]); stage1_cflags="$stage1_cflags -fkeep-inline-functions"],
9990      [AC_MSG_RESULT([no])])
9991  
9992 Index: ChangeLog
9993 ===================================================================
9994 --- ChangeLog   (.../tags/gcc_4_2_0_release)    (revision 125292)
9995 +++ ChangeLog   (.../branches/gcc-4_2-branch)   (revision 125292)
9996 @@ -1,3 +1,9 @@
9997 +2007-05-30  Jakub Jelinek  <jakub@redhat.com>
9998 +
9999 +       PR bootstrap/29382
10000 +       * configure.in: Don't use -fkeep-inline-functions for GCC < 3.3.1.
10001 +       * configure: Rebuilt.
10002 +
10003  2007-05-13  Release Manager
10004  
10005         * GCC 4.2.0 released.
10006 Index: libjava/java/lang/natClassLoader.cc
10007 ===================================================================
10008 --- libjava/java/lang/natClassLoader.cc (.../tags/gcc_4_2_0_release)    (revision 125292)
10009 +++ libjava/java/lang/natClassLoader.cc (.../branches/gcc-4_2-branch)   (revision 125292)
10010 @@ -235,6 +235,15 @@
10011  
10012    new_class->engine = &_Jv_soleIndirectCompiledEngine;
10013  
10014 +  /* FIXME:  Way back before the dawn of time, we overloaded the
10015 +     SYNTHETIC class access modifier to mean INTERPRETED.  This was a
10016 +     Bad Thing, but it didn't matter then because classes were never
10017 +     marked synthetic.  However, it is possible to redeem the
10018 +     situation: _Jv_NewClassFromInitializer is only called from
10019 +     compiled classes, so we clear the INTERPRETED flag.  This is a
10020 +     kludge!  */
10021 +  new_class->accflags &= ~java::lang::reflect::Modifier::INTERPRETED;
10022 +
10023    if (_Jv_CheckABIVersion ((unsigned long) new_class->next_or_version))
10024      (*_Jv_RegisterClassHook) (new_class);
10025    
10026 Index: libjava/ChangeLog
10027 ===================================================================
10028 --- libjava/ChangeLog   (.../tags/gcc_4_2_0_release)    (revision 125292)
10029 +++ libjava/ChangeLog   (.../branches/gcc-4_2-branch)   (revision 125292)
10030 @@ -1,3 +1,8 @@
10031 +2007-05-31  Andrew Haley  <aph@redhat.com>
10032 +
10033 +       * java/lang/natClassLoader.cc (_Jv_NewClassFromInitializer): Clear
10034 +       INTERPRETED access modifier.
10035 +
10036  2007-05-13  Release Manager
10037  
10038         * GCC 4.2.0 released.
10039 Index: maintainer-scripts/ChangeLog
10040 ===================================================================
10041 --- maintainer-scripts/ChangeLog        (.../tags/gcc_4_2_0_release)    (revision 125292)
10042 +++ maintainer-scripts/ChangeLog        (.../branches/gcc-4_2-branch)   (revision 125292)
10043 @@ -1,3 +1,7 @@
10044 +2007-05-28  Mark Mitchell  <mark@codesourcery.com>
10045 +
10046 +       * gcc_release: Adjust placement of release candidates.
10047 +
10048  2007-05-13  Release Manager
10049  
10050         * GCC 4.2.0 released.
10051 Index: maintainer-scripts/gcc_release
10052 ===================================================================
10053 --- maintainer-scripts/gcc_release      (.../tags/gcc_4_2_0_release)    (revision 125292)
10054 +++ maintainer-scripts/gcc_release      (.../branches/gcc-4_2-branch)   (revision 125292)
10055 @@ -699,10 +699,10 @@
10056    # and minor release numbers.
10057    SVNBRANCH="branches/gcc-${RELEASE_MAJOR}_${RELEASE_MINOR}-branch"
10058  
10059 -  # If this is not a final release, set various parameters acordingly.
10060 +  # If this is not a final release, set various parameters accordingly.
10061    if [ ${FINAL} -ne 1 ]; then
10062 -    RELEASE="${RELEASE}-${DATE}"
10063 -    FTP_PATH="${FTP_PATH}/prerelease-${RELEASE}/"
10064 +    RELEASE="${RELEASE}-RC-${DATE}"
10065 +    FTP_PATH="${SNAPSHOTS_DIR}/${RELEASE}"
10066    else
10067      FTP_PATH="${FTP_PATH}/releases/gcc-${RELEASE}/"
10068    fi
This page took 0.890816 seconds and 4 git commands to generate.