comparison gcc/tree-dfa.c @ 132:d34655255c78

update gcc-8.2
author mir3636
date Thu, 25 Oct 2018 10:21:07 +0900
parents 84e7813d76e9
children 1830386684a0
comparison
equal deleted inserted replaced
130:e108057fa461 132:d34655255c78
1 /* Data flow functions for trees. 1 /* Data flow functions for trees.
2 Copyright (C) 2001-2017 Free Software Foundation, Inc. 2 Copyright (C) 2001-2018 Free Software Foundation, Inc.
3 Contributed by Diego Novillo <dnovillo@redhat.com> 3 Contributed by Diego Novillo <dnovillo@redhat.com>
4 4
5 This file is part of GCC. 5 This file is part of GCC.
6 6
7 GCC is free software; you can redistribute it and/or modify 7 GCC is free software; you can redistribute it and/or modify
375 *PSIZE or *PMAX_SIZE is -1, they could not be determined. If *PSIZE 375 *PSIZE or *PMAX_SIZE is -1, they could not be determined. If *PSIZE
376 and *PMAX_SIZE are equal, the access is non-variable. If *PREVERSE is 376 and *PMAX_SIZE are equal, the access is non-variable. If *PREVERSE is
377 true, the storage order of the reference is reversed. */ 377 true, the storage order of the reference is reversed. */
378 378
379 tree 379 tree
380 get_ref_base_and_extent (tree exp, HOST_WIDE_INT *poffset, 380 get_ref_base_and_extent (tree exp, poly_int64_pod *poffset,
381 HOST_WIDE_INT *psize, 381 poly_int64_pod *psize,
382 HOST_WIDE_INT *pmax_size, 382 poly_int64_pod *pmax_size,
383 bool *preverse) 383 bool *preverse)
384 { 384 {
385 offset_int bitsize = -1; 385 poly_offset_int bitsize = -1;
386 offset_int maxsize; 386 poly_offset_int maxsize;
387 tree size_tree = NULL_TREE; 387 tree size_tree = NULL_TREE;
388 offset_int bit_offset = 0; 388 poly_offset_int bit_offset = 0;
389 bool seen_variable_array_ref = false; 389 bool seen_variable_array_ref = false;
390 390
391 /* First get the final access size and the storage order from just the 391 /* First get the final access size and the storage order from just the
392 outermost expression. */ 392 outermost expression. */
393 if (TREE_CODE (exp) == COMPONENT_REF) 393 if (TREE_CODE (exp) == COMPONENT_REF)
398 { 398 {
399 machine_mode mode = TYPE_MODE (TREE_TYPE (exp)); 399 machine_mode mode = TYPE_MODE (TREE_TYPE (exp));
400 if (mode == BLKmode) 400 if (mode == BLKmode)
401 size_tree = TYPE_SIZE (TREE_TYPE (exp)); 401 size_tree = TYPE_SIZE (TREE_TYPE (exp));
402 else 402 else
403 bitsize = int (GET_MODE_BITSIZE (mode)); 403 bitsize = GET_MODE_BITSIZE (mode);
404 } 404 }
405 if (size_tree != NULL_TREE 405 if (size_tree != NULL_TREE
406 && TREE_CODE (size_tree) == INTEGER_CST) 406 && poly_int_tree_p (size_tree))
407 bitsize = wi::to_offset (size_tree); 407 bitsize = wi::to_poly_offset (size_tree);
408 408
409 *preverse = reverse_storage_order_for_component_p (exp); 409 *preverse = reverse_storage_order_for_component_p (exp);
410 410
411 /* Initially, maxsize is the same as the accessed element size. 411 /* Initially, maxsize is the same as the accessed element size.
412 In the following it will only grow (or become -1). */ 412 In the following it will only grow (or become -1). */
417 while (1) 417 while (1)
418 { 418 {
419 switch (TREE_CODE (exp)) 419 switch (TREE_CODE (exp))
420 { 420 {
421 case BIT_FIELD_REF: 421 case BIT_FIELD_REF:
422 bit_offset += wi::to_offset (TREE_OPERAND (exp, 2)); 422 bit_offset += wi::to_poly_offset (TREE_OPERAND (exp, 2));
423 break; 423 break;
424 424
425 case COMPONENT_REF: 425 case COMPONENT_REF:
426 { 426 {
427 tree field = TREE_OPERAND (exp, 1); 427 tree field = TREE_OPERAND (exp, 1);
428 tree this_offset = component_ref_field_offset (exp); 428 tree this_offset = component_ref_field_offset (exp);
429 429
430 if (this_offset && TREE_CODE (this_offset) == INTEGER_CST) 430 if (this_offset && poly_int_tree_p (this_offset))
431 { 431 {
432 offset_int woffset = (wi::to_offset (this_offset) 432 poly_offset_int woffset = (wi::to_poly_offset (this_offset)
433 << LOG2_BITS_PER_UNIT); 433 << LOG2_BITS_PER_UNIT);
434 woffset += wi::to_offset (DECL_FIELD_BIT_OFFSET (field)); 434 woffset += wi::to_offset (DECL_FIELD_BIT_OFFSET (field));
435 bit_offset += woffset; 435 bit_offset += woffset;
436 436
437 /* If we had seen a variable array ref already and we just 437 /* If we had seen a variable array ref already and we just
438 referenced the last field of a struct or a union member 438 referenced the last field of a struct or a union member
439 then we have to adjust maxsize by the padding at the end 439 then we have to adjust maxsize by the padding at the end
440 of our field. */ 440 of our field. */
441 if (seen_variable_array_ref && maxsize != -1) 441 if (seen_variable_array_ref)
442 { 442 {
443 tree stype = TREE_TYPE (TREE_OPERAND (exp, 0)); 443 tree stype = TREE_TYPE (TREE_OPERAND (exp, 0));
444 tree next = DECL_CHAIN (field); 444 tree next = DECL_CHAIN (field);
445 while (next && TREE_CODE (next) != FIELD_DECL) 445 while (next && TREE_CODE (next) != FIELD_DECL)
446 next = DECL_CHAIN (next); 446 next = DECL_CHAIN (next);
448 || TREE_CODE (stype) != RECORD_TYPE) 448 || TREE_CODE (stype) != RECORD_TYPE)
449 { 449 {
450 tree fsize = DECL_SIZE_UNIT (field); 450 tree fsize = DECL_SIZE_UNIT (field);
451 tree ssize = TYPE_SIZE_UNIT (stype); 451 tree ssize = TYPE_SIZE_UNIT (stype);
452 if (fsize == NULL 452 if (fsize == NULL
453 || TREE_CODE (fsize) != INTEGER_CST 453 || !poly_int_tree_p (fsize)
454 || ssize == NULL 454 || ssize == NULL
455 || TREE_CODE (ssize) != INTEGER_CST) 455 || !poly_int_tree_p (ssize))
456 maxsize = -1; 456 maxsize = -1;
457 else 457 else if (known_size_p (maxsize))
458 { 458 {
459 offset_int tem = (wi::to_offset (ssize) 459 poly_offset_int tem
460 - wi::to_offset (fsize)); 460 = (wi::to_poly_offset (ssize)
461 - wi::to_poly_offset (fsize));
461 tem <<= LOG2_BITS_PER_UNIT; 462 tem <<= LOG2_BITS_PER_UNIT;
462 tem -= woffset; 463 tem -= woffset;
463 maxsize += tem; 464 maxsize += tem;
464 } 465 }
465 } 466 }
467 /* An component ref with an adjacent field up in the
468 structure hierarchy constrains the size of any variable
469 array ref lower in the access hierarchy. */
470 else
471 seen_variable_array_ref = false;
466 } 472 }
467 } 473 }
468 else 474 else
469 { 475 {
470 tree csize = TYPE_SIZE (TREE_TYPE (TREE_OPERAND (exp, 0))); 476 tree csize = TYPE_SIZE (TREE_TYPE (TREE_OPERAND (exp, 0)));
471 /* We need to adjust maxsize to the whole structure bitsize. 477 /* We need to adjust maxsize to the whole structure bitsize.
472 But we can subtract any constant offset seen so far, 478 But we can subtract any constant offset seen so far,
473 because that would get us out of the structure otherwise. */ 479 because that would get us out of the structure otherwise. */
474 if (maxsize != -1 480 if (known_size_p (maxsize)
475 && csize 481 && csize
476 && TREE_CODE (csize) == INTEGER_CST) 482 && poly_int_tree_p (csize))
477 maxsize = wi::to_offset (csize) - bit_offset; 483 maxsize = wi::to_poly_offset (csize) - bit_offset;
478 else 484 else
479 maxsize = -1; 485 maxsize = -1;
480 } 486 }
481 } 487 }
482 break; 488 break;
486 { 492 {
487 tree index = TREE_OPERAND (exp, 1); 493 tree index = TREE_OPERAND (exp, 1);
488 tree low_bound, unit_size; 494 tree low_bound, unit_size;
489 495
490 /* If the resulting bit-offset is constant, track it. */ 496 /* If the resulting bit-offset is constant, track it. */
491 if (TREE_CODE (index) == INTEGER_CST 497 if (poly_int_tree_p (index)
492 && (low_bound = array_ref_low_bound (exp), 498 && (low_bound = array_ref_low_bound (exp),
493 TREE_CODE (low_bound) == INTEGER_CST) 499 poly_int_tree_p (low_bound))
494 && (unit_size = array_ref_element_size (exp), 500 && (unit_size = array_ref_element_size (exp),
495 TREE_CODE (unit_size) == INTEGER_CST)) 501 TREE_CODE (unit_size) == INTEGER_CST))
496 { 502 {
497 offset_int woffset 503 poly_offset_int woffset
498 = wi::sext (wi::to_offset (index) - wi::to_offset (low_bound), 504 = wi::sext (wi::to_poly_offset (index)
505 - wi::to_poly_offset (low_bound),
499 TYPE_PRECISION (TREE_TYPE (index))); 506 TYPE_PRECISION (TREE_TYPE (index)));
500 woffset *= wi::to_offset (unit_size); 507 woffset *= wi::to_offset (unit_size);
501 woffset <<= LOG2_BITS_PER_UNIT; 508 woffset <<= LOG2_BITS_PER_UNIT;
502 bit_offset += woffset; 509 bit_offset += woffset;
503 510
510 { 517 {
511 tree asize = TYPE_SIZE (TREE_TYPE (TREE_OPERAND (exp, 0))); 518 tree asize = TYPE_SIZE (TREE_TYPE (TREE_OPERAND (exp, 0)));
512 /* We need to adjust maxsize to the whole array bitsize. 519 /* We need to adjust maxsize to the whole array bitsize.
513 But we can subtract any constant offset seen so far, 520 But we can subtract any constant offset seen so far,
514 because that would get us outside of the array otherwise. */ 521 because that would get us outside of the array otherwise. */
515 if (maxsize != -1 522 if (known_size_p (maxsize)
516 && asize 523 && asize
517 && TREE_CODE (asize) == INTEGER_CST) 524 && poly_int_tree_p (asize))
518 maxsize = wi::to_offset (asize) - bit_offset; 525 maxsize = wi::to_poly_offset (asize) - bit_offset;
519 else 526 else
520 maxsize = -1; 527 maxsize = -1;
521 528
522 /* Remember that we have seen an array ref with a variable 529 /* Remember that we have seen an array ref with a variable
523 index. */ 530 index. */
524 seen_variable_array_ref = true; 531 seen_variable_array_ref = true;
532
533 wide_int min, max;
534 if (TREE_CODE (index) == SSA_NAME
535 && (low_bound = array_ref_low_bound (exp),
536 poly_int_tree_p (low_bound))
537 && (unit_size = array_ref_element_size (exp),
538 TREE_CODE (unit_size) == INTEGER_CST)
539 && get_range_info (index, &min, &max) == VR_RANGE)
540 {
541 poly_offset_int lbound = wi::to_poly_offset (low_bound);
542 /* Try to constrain maxsize with range information. */
543 offset_int omax
544 = offset_int::from (max, TYPE_SIGN (TREE_TYPE (index)));
545 if (known_lt (lbound, omax))
546 {
547 poly_offset_int rmaxsize;
548 rmaxsize = (omax - lbound + 1)
549 * wi::to_offset (unit_size) << LOG2_BITS_PER_UNIT;
550 if (!known_size_p (maxsize)
551 || known_lt (rmaxsize, maxsize))
552 {
553 /* If we know an upper bound below the declared
554 one this is no longer variable. */
555 if (known_size_p (maxsize))
556 seen_variable_array_ref = false;
557 maxsize = rmaxsize;
558 }
559 }
560 /* Try to adjust bit_offset with range information. */
561 offset_int omin
562 = offset_int::from (min, TYPE_SIGN (TREE_TYPE (index)));
563 if (known_le (lbound, omin))
564 {
565 poly_offset_int woffset
566 = wi::sext (omin - lbound,
567 TYPE_PRECISION (TREE_TYPE (index)));
568 woffset *= wi::to_offset (unit_size);
569 woffset <<= LOG2_BITS_PER_UNIT;
570 bit_offset += woffset;
571 if (known_size_p (maxsize))
572 maxsize -= woffset;
573 }
574 }
525 } 575 }
526 } 576 }
527 break; 577 break;
528 578
529 case REALPART_EXPR: 579 case REALPART_EXPR:
558 the array. The simplest way to conservatively deal with this 608 the array. The simplest way to conservatively deal with this
559 is to punt in the case that offset + maxsize reaches the 609 is to punt in the case that offset + maxsize reaches the
560 base type boundary. This needs to include possible trailing 610 base type boundary. This needs to include possible trailing
561 padding that is there for alignment purposes. */ 611 padding that is there for alignment purposes. */
562 if (seen_variable_array_ref 612 if (seen_variable_array_ref
563 && maxsize != -1 613 && known_size_p (maxsize)
564 && (TYPE_SIZE (TREE_TYPE (exp)) == NULL_TREE 614 && (TYPE_SIZE (TREE_TYPE (exp)) == NULL_TREE
565 || TREE_CODE (TYPE_SIZE (TREE_TYPE (exp))) != INTEGER_CST 615 || !poly_int_tree_p (TYPE_SIZE (TREE_TYPE (exp)))
566 || (bit_offset + maxsize 616 || (maybe_eq
567 == wi::to_offset (TYPE_SIZE (TREE_TYPE (exp)))))) 617 (bit_offset + maxsize,
618 wi::to_poly_offset (TYPE_SIZE (TREE_TYPE (exp)))))))
568 maxsize = -1; 619 maxsize = -1;
569 620
570 /* Hand back the decl for MEM[&decl, off]. */ 621 /* Hand back the decl for MEM[&decl, off]. */
571 if (TREE_CODE (TREE_OPERAND (exp, 0)) == ADDR_EXPR) 622 if (TREE_CODE (TREE_OPERAND (exp, 0)) == ADDR_EXPR)
572 { 623 {
573 if (integer_zerop (TREE_OPERAND (exp, 1))) 624 if (integer_zerop (TREE_OPERAND (exp, 1)))
574 exp = TREE_OPERAND (TREE_OPERAND (exp, 0), 0); 625 exp = TREE_OPERAND (TREE_OPERAND (exp, 0), 0);
575 else 626 else
576 { 627 {
577 offset_int off = mem_ref_offset (exp); 628 poly_offset_int off = mem_ref_offset (exp);
578 off <<= LOG2_BITS_PER_UNIT; 629 off <<= LOG2_BITS_PER_UNIT;
579 off += bit_offset; 630 off += bit_offset;
580 if (wi::fits_shwi_p (off)) 631 poly_int64 off_hwi;
632 if (off.to_shwi (&off_hwi))
581 { 633 {
582 bit_offset = off; 634 bit_offset = off_hwi;
583 exp = TREE_OPERAND (TREE_OPERAND (exp, 0), 0); 635 exp = TREE_OPERAND (TREE_OPERAND (exp, 0), 0);
584 } 636 }
585 } 637 }
586 } 638 }
587 goto done; 639 goto done;
592 644
593 exp = TREE_OPERAND (exp, 0); 645 exp = TREE_OPERAND (exp, 0);
594 } 646 }
595 647
596 done: 648 done:
597 if (!wi::fits_shwi_p (bitsize) || wi::neg_p (bitsize)) 649 if (!bitsize.to_shwi (psize) || maybe_lt (*psize, 0))
598 { 650 {
599 *poffset = 0; 651 *poffset = 0;
600 *psize = -1; 652 *psize = -1;
601 *pmax_size = -1; 653 *pmax_size = -1;
602 654
603 return exp; 655 return exp;
604 } 656 }
605 657
606 *psize = bitsize.to_shwi (); 658 /* ??? Due to negative offsets in ARRAY_REF we can end up with
607 659 negative bit_offset here. We might want to store a zero offset
608 if (!wi::fits_shwi_p (bit_offset)) 660 in this case. */
661 if (!bit_offset.to_shwi (poffset))
609 { 662 {
610 *poffset = 0; 663 *poffset = 0;
611 *pmax_size = -1; 664 *pmax_size = -1;
612 665
613 return exp; 666 return exp;
615 668
616 /* In case of a decl or constant base object we can do better. */ 669 /* In case of a decl or constant base object we can do better. */
617 670
618 if (DECL_P (exp)) 671 if (DECL_P (exp))
619 { 672 {
620 if (flag_unconstrained_commons && VAR_P (exp) && DECL_COMMON (exp)) 673 if (VAR_P (exp)
674 && ((flag_unconstrained_commons && DECL_COMMON (exp))
675 || (DECL_EXTERNAL (exp) && seen_variable_array_ref)))
621 { 676 {
622 tree sz_tree = TYPE_SIZE (TREE_TYPE (exp)); 677 tree sz_tree = TYPE_SIZE (TREE_TYPE (exp));
623 /* If size is unknown, or we have read to the end, assume there 678 /* If size is unknown, or we have read to the end, assume there
624 may be more to the structure than we are told. */ 679 may be more to the structure than we are told. */
625 if (TREE_CODE (TREE_TYPE (exp)) == ARRAY_TYPE 680 if (TREE_CODE (TREE_TYPE (exp)) == ARRAY_TYPE
626 || (seen_variable_array_ref 681 || (seen_variable_array_ref
627 && (sz_tree == NULL_TREE 682 && (sz_tree == NULL_TREE
628 || TREE_CODE (sz_tree) != INTEGER_CST 683 || !poly_int_tree_p (sz_tree)
629 || (bit_offset + maxsize == wi::to_offset (sz_tree))))) 684 || maybe_eq (bit_offset + maxsize,
685 wi::to_poly_offset (sz_tree)))))
630 maxsize = -1; 686 maxsize = -1;
631 } 687 }
632 /* If maxsize is unknown adjust it according to the size of the 688 /* If maxsize is unknown adjust it according to the size of the
633 base decl. */ 689 base decl. */
634 else if (maxsize == -1 690 else if (!known_size_p (maxsize)
635 && DECL_SIZE (exp) 691 && DECL_SIZE (exp)
636 && TREE_CODE (DECL_SIZE (exp)) == INTEGER_CST) 692 && poly_int_tree_p (DECL_SIZE (exp)))
637 maxsize = wi::to_offset (DECL_SIZE (exp)) - bit_offset; 693 maxsize = wi::to_poly_offset (DECL_SIZE (exp)) - bit_offset;
638 } 694 }
639 else if (CONSTANT_CLASS_P (exp)) 695 else if (CONSTANT_CLASS_P (exp))
640 { 696 {
641 /* If maxsize is unknown adjust it according to the size of the 697 /* If maxsize is unknown adjust it according to the size of the
642 base type constant. */ 698 base type constant. */
643 if (maxsize == -1 699 if (!known_size_p (maxsize)
644 && TYPE_SIZE (TREE_TYPE (exp)) 700 && TYPE_SIZE (TREE_TYPE (exp))
645 && TREE_CODE (TYPE_SIZE (TREE_TYPE (exp))) == INTEGER_CST) 701 && poly_int_tree_p (TYPE_SIZE (TREE_TYPE (exp))))
646 maxsize = (wi::to_offset (TYPE_SIZE (TREE_TYPE (exp))) 702 maxsize = (wi::to_poly_offset (TYPE_SIZE (TREE_TYPE (exp)))
647 - bit_offset); 703 - bit_offset);
648 } 704 }
649 705
650 /* ??? Due to negative offsets in ARRAY_REF we can end up with 706 if (!maxsize.to_shwi (pmax_size)
651 negative bit_offset here. We might want to store a zero offset 707 || maybe_lt (*pmax_size, 0)
652 in this case. */ 708 || !endpoint_representable_p (*poffset, *pmax_size))
653 *poffset = bit_offset.to_shwi ();
654 if (!wi::fits_shwi_p (maxsize) || wi::neg_p (maxsize))
655 *pmax_size = -1; 709 *pmax_size = -1;
656 else
657 {
658 *pmax_size = maxsize.to_shwi ();
659 if (*poffset > HOST_WIDE_INT_MAX - *pmax_size)
660 *pmax_size = -1;
661 }
662 710
663 /* Punt if *POFFSET + *PSIZE overflows in HOST_WIDE_INT, the callers don't 711 /* Punt if *POFFSET + *PSIZE overflows in HOST_WIDE_INT, the callers don't
664 check for such overflows individually and assume it works. */ 712 check for such overflows individually and assume it works. */
665 if (*psize != -1 && *poffset > HOST_WIDE_INT_MAX - *psize) 713 if (!endpoint_representable_p (*poffset, *psize))
666 { 714 {
667 *poffset = 0; 715 *poffset = 0;
668 *psize = -1; 716 *psize = -1;
669 *pmax_size = -1; 717 *pmax_size = -1;
670 718
671 return exp; 719 return exp;
672 } 720 }
673 721
674 return exp; 722 return exp;
723 }
724
725 /* Like get_ref_base_and_extent, but for cases in which we only care
726 about constant-width accesses at constant offsets. Return null
727 if the access is anything else. */
728
729 tree
730 get_ref_base_and_extent_hwi (tree exp, HOST_WIDE_INT *poffset,
731 HOST_WIDE_INT *psize, bool *preverse)
732 {
733 poly_int64 offset, size, max_size;
734 HOST_WIDE_INT const_offset, const_size;
735 bool reverse;
736 tree decl = get_ref_base_and_extent (exp, &offset, &size, &max_size,
737 &reverse);
738 if (!offset.is_constant (&const_offset)
739 || !size.is_constant (&const_size)
740 || const_offset < 0
741 || !known_size_p (max_size)
742 || maybe_ne (max_size, const_size))
743 return NULL_TREE;
744
745 *poffset = const_offset;
746 *psize = const_size;
747 *preverse = reverse;
748 return decl;
675 } 749 }
676 750
677 /* Returns the base object and a constant BITS_PER_UNIT offset in *POFFSET that 751 /* Returns the base object and a constant BITS_PER_UNIT offset in *POFFSET that
678 denotes the starting address of the memory access EXP. 752 denotes the starting address of the memory access EXP.
679 Returns NULL_TREE if the offset is not constant or any component 753 Returns NULL_TREE if the offset is not constant or any component
680 is not BITS_PER_UNIT-aligned. 754 is not BITS_PER_UNIT-aligned.
681 VALUEIZE if non-NULL is used to valueize SSA names. It should return 755 VALUEIZE if non-NULL is used to valueize SSA names. It should return
682 its argument or a constant if the argument is known to be constant. */ 756 its argument or a constant if the argument is known to be constant. */
683 757
684 tree 758 tree
685 get_addr_base_and_unit_offset_1 (tree exp, HOST_WIDE_INT *poffset, 759 get_addr_base_and_unit_offset_1 (tree exp, poly_int64_pod *poffset,
686 tree (*valueize) (tree)) 760 tree (*valueize) (tree))
687 { 761 {
688 HOST_WIDE_INT byte_offset = 0; 762 poly_int64 byte_offset = 0;
689 763
690 /* Compute cumulative byte-offset for nested component-refs and array-refs, 764 /* Compute cumulative byte-offset for nested component-refs and array-refs,
691 and find the ultimate containing object. */ 765 and find the ultimate containing object. */
692 while (1) 766 while (1)
693 { 767 {
694 switch (TREE_CODE (exp)) 768 switch (TREE_CODE (exp))
695 { 769 {
696 case BIT_FIELD_REF: 770 case BIT_FIELD_REF:
697 { 771 {
698 HOST_WIDE_INT this_off = TREE_INT_CST_LOW (TREE_OPERAND (exp, 2)); 772 poly_int64 this_byte_offset;
699 if (this_off % BITS_PER_UNIT) 773 poly_uint64 this_bit_offset;
774 if (!poly_int_tree_p (TREE_OPERAND (exp, 2), &this_bit_offset)
775 || !multiple_p (this_bit_offset, BITS_PER_UNIT,
776 &this_byte_offset))
700 return NULL_TREE; 777 return NULL_TREE;
701 byte_offset += this_off / BITS_PER_UNIT; 778 byte_offset += this_byte_offset;
702 } 779 }
703 break; 780 break;
704 781
705 case COMPONENT_REF: 782 case COMPONENT_REF:
706 { 783 {
707 tree field = TREE_OPERAND (exp, 1); 784 tree field = TREE_OPERAND (exp, 1);
708 tree this_offset = component_ref_field_offset (exp); 785 tree this_offset = component_ref_field_offset (exp);
709 HOST_WIDE_INT hthis_offset; 786 poly_int64 hthis_offset;
710 787
711 if (!this_offset 788 if (!this_offset
712 || TREE_CODE (this_offset) != INTEGER_CST 789 || !poly_int_tree_p (this_offset, &hthis_offset)
713 || (TREE_INT_CST_LOW (DECL_FIELD_BIT_OFFSET (field)) 790 || (TREE_INT_CST_LOW (DECL_FIELD_BIT_OFFSET (field))
714 % BITS_PER_UNIT)) 791 % BITS_PER_UNIT))
715 return NULL_TREE; 792 return NULL_TREE;
716 793
717 hthis_offset = TREE_INT_CST_LOW (this_offset);
718 hthis_offset += (TREE_INT_CST_LOW (DECL_FIELD_BIT_OFFSET (field)) 794 hthis_offset += (TREE_INT_CST_LOW (DECL_FIELD_BIT_OFFSET (field))
719 / BITS_PER_UNIT); 795 / BITS_PER_UNIT);
720 byte_offset += hthis_offset; 796 byte_offset += hthis_offset;
721 } 797 }
722 break; 798 break;
730 if (valueize 806 if (valueize
731 && TREE_CODE (index) == SSA_NAME) 807 && TREE_CODE (index) == SSA_NAME)
732 index = (*valueize) (index); 808 index = (*valueize) (index);
733 809
734 /* If the resulting bit-offset is constant, track it. */ 810 /* If the resulting bit-offset is constant, track it. */
735 if (TREE_CODE (index) == INTEGER_CST 811 if (poly_int_tree_p (index)
736 && (low_bound = array_ref_low_bound (exp), 812 && (low_bound = array_ref_low_bound (exp),
737 TREE_CODE (low_bound) == INTEGER_CST) 813 poly_int_tree_p (low_bound))
738 && (unit_size = array_ref_element_size (exp), 814 && (unit_size = array_ref_element_size (exp),
739 TREE_CODE (unit_size) == INTEGER_CST)) 815 TREE_CODE (unit_size) == INTEGER_CST))
740 { 816 {
741 offset_int woffset 817 poly_offset_int woffset
742 = wi::sext (wi::to_offset (index) - wi::to_offset (low_bound), 818 = wi::sext (wi::to_poly_offset (index)
819 - wi::to_poly_offset (low_bound),
743 TYPE_PRECISION (TREE_TYPE (index))); 820 TYPE_PRECISION (TREE_TYPE (index)));
744 woffset *= wi::to_offset (unit_size); 821 woffset *= wi::to_offset (unit_size);
745 byte_offset += woffset.to_shwi (); 822 byte_offset += woffset.force_shwi ();
746 } 823 }
747 else 824 else
748 return NULL_TREE; 825 return NULL_TREE;
749 } 826 }
750 break; 827 break;
769 /* Hand back the decl for MEM[&decl, off]. */ 846 /* Hand back the decl for MEM[&decl, off]. */
770 if (TREE_CODE (base) == ADDR_EXPR) 847 if (TREE_CODE (base) == ADDR_EXPR)
771 { 848 {
772 if (!integer_zerop (TREE_OPERAND (exp, 1))) 849 if (!integer_zerop (TREE_OPERAND (exp, 1)))
773 { 850 {
774 offset_int off = mem_ref_offset (exp); 851 poly_offset_int off = mem_ref_offset (exp);
775 byte_offset += off.to_short_addr (); 852 byte_offset += off.force_shwi ();
776 } 853 }
777 exp = TREE_OPERAND (base, 0); 854 exp = TREE_OPERAND (base, 0);
778 } 855 }
779 goto done; 856 goto done;
780 } 857 }
791 { 868 {
792 if (TMR_INDEX (exp) || TMR_INDEX2 (exp)) 869 if (TMR_INDEX (exp) || TMR_INDEX2 (exp))
793 return NULL_TREE; 870 return NULL_TREE;
794 if (!integer_zerop (TMR_OFFSET (exp))) 871 if (!integer_zerop (TMR_OFFSET (exp)))
795 { 872 {
796 offset_int off = mem_ref_offset (exp); 873 poly_offset_int off = mem_ref_offset (exp);
797 byte_offset += off.to_short_addr (); 874 byte_offset += off.force_shwi ();
798 } 875 }
799 exp = TREE_OPERAND (base, 0); 876 exp = TREE_OPERAND (base, 0);
800 } 877 }
801 goto done; 878 goto done;
802 } 879 }
817 denotes the starting address of the memory access EXP. 894 denotes the starting address of the memory access EXP.
818 Returns NULL_TREE if the offset is not constant or any component 895 Returns NULL_TREE if the offset is not constant or any component
819 is not BITS_PER_UNIT-aligned. */ 896 is not BITS_PER_UNIT-aligned. */
820 897
821 tree 898 tree
822 get_addr_base_and_unit_offset (tree exp, HOST_WIDE_INT *poffset) 899 get_addr_base_and_unit_offset (tree exp, poly_int64_pod *poffset)
823 { 900 {
824 return get_addr_base_and_unit_offset_1 (exp, poffset, NULL); 901 return get_addr_base_and_unit_offset_1 (exp, poffset, NULL);
825 } 902 }
826 903
827 /* Returns true if STMT references an SSA_NAME that has 904 /* Returns true if STMT references an SSA_NAME that has
913 FILE is the dump file where to output the list and FLAGS is as in 990 FILE is the dump file where to output the list and FLAGS is as in
914 print_generic_expr. */ 991 print_generic_expr. */
915 void 992 void
916 dump_enumerated_decls (FILE *file, dump_flags_t flags) 993 dump_enumerated_decls (FILE *file, dump_flags_t flags)
917 { 994 {
995 if (!cfun->cfg)
996 return;
997
918 basic_block bb; 998 basic_block bb;
919 struct walk_stmt_info wi; 999 struct walk_stmt_info wi;
920 auto_vec<numbered_tree, 40> decl_list; 1000 auto_vec<numbered_tree, 40> decl_list;
921 1001
922 memset (&wi, '\0', sizeof (wi)); 1002 memset (&wi, '\0', sizeof (wi));