comparison gcc/coverage.c @ 67:f6334be47118

update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
author nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
date Tue, 22 Mar 2011 17:18:12 +0900
parents b7f97abdc517
children 04ced10e8804
comparison
equal deleted inserted replaced
65:65488c3d617d 67:f6334be47118
1 /* Read and write coverage files, and associated functionality. 1 /* Read and write coverage files, and associated functionality.
2 Copyright (C) 1990, 1991, 1992, 1993, 1994, 1996, 1997, 1998, 1999, 2 Copyright (C) 1990, 1991, 1992, 1993, 1994, 1996, 1997, 1998, 1999,
3 2000, 2001, 2003, 2004, 2005, 2007, 2008 Free Software Foundation, 3 2000, 2001, 2003, 2004, 2005, 2007, 2008, 2009, 2010
4 Inc. 4 Free Software Foundation, Inc.
5 Contributed by James E. Wilson, UC Berkeley/Cygnus Support; 5 Contributed by James E. Wilson, UC Berkeley/Cygnus Support;
6 based on some ideas from Dain Samples of UC Berkeley. 6 based on some ideas from Dain Samples of UC Berkeley.
7 Further mangling by Bob Manson, Cygnus Support. 7 Further mangling by Bob Manson, Cygnus Support.
8 Further mangled by Nathan Sidwell, CodeSourcery 8 Further mangled by Nathan Sidwell, CodeSourcery
9 9
35 #include "flags.h" 35 #include "flags.h"
36 #include "output.h" 36 #include "output.h"
37 #include "regs.h" 37 #include "regs.h"
38 #include "expr.h" 38 #include "expr.h"
39 #include "function.h" 39 #include "function.h"
40 #include "basic-block.h"
40 #include "toplev.h" 41 #include "toplev.h"
41 #include "tm_p.h" 42 #include "tm_p.h"
42 #include "ggc.h" 43 #include "ggc.h"
43 #include "coverage.h" 44 #include "coverage.h"
44 #include "langhooks.h" 45 #include "langhooks.h"
45 #include "hashtab.h" 46 #include "hashtab.h"
46 #include "tree-iterator.h" 47 #include "tree-iterator.h"
47 #include "cgraph.h" 48 #include "cgraph.h"
48 #include "tree-pass.h" 49 #include "tree-pass.h"
49 #include "diagnostic.h" 50 #include "diagnostic-core.h"
50 #include "intl.h" 51 #include "intl.h"
51 52
52 #include "gcov-io.c" 53 #include "gcov-io.c"
53 54
54 struct function_list 55 struct function_list
100 /* Hash table of count data. */ 101 /* Hash table of count data. */
101 static htab_t counts_hash = NULL; 102 static htab_t counts_hash = NULL;
102 103
103 /* Trees representing the counter table arrays. */ 104 /* Trees representing the counter table arrays. */
104 static GTY(()) tree tree_ctr_tables[GCOV_COUNTERS]; 105 static GTY(()) tree tree_ctr_tables[GCOV_COUNTERS];
105
106 /* The names of the counter tables. Not used if we're
107 generating counters at tree level. */
108 static GTY(()) rtx ctr_labels[GCOV_COUNTERS];
109 106
110 /* The names of merge functions for counters. */ 107 /* The names of merge functions for counters. */
111 static const char *const ctr_merge_functions[GCOV_COUNTERS] = GCOV_MERGE_FUNCTIONS; 108 static const char *const ctr_merge_functions[GCOV_COUNTERS] = GCOV_MERGE_FUNCTIONS;
112 static const char *const ctr_names[GCOV_COUNTERS] = GCOV_COUNTER_NAMES; 109 static const char *const ctr_names[GCOV_COUNTERS] = GCOV_COUNTER_NAMES;
113 110
373 entry->checksum, checksum); 370 entry->checksum, checksum);
374 else 371 else
375 inform (input_location, "number of counters is %d instead of %d", 372 inform (input_location, "number of counters is %d instead of %d",
376 entry->summary.num, expected); 373 entry->summary.num, expected);
377 374
378 if (!(errorcount || sorrycount) 375 if (!seen_error ()
379 && !warned++) 376 && !warned++)
380 { 377 {
381 inform (input_location, "coverage mismatch ignored"); 378 inform (input_location, "coverage mismatch ignored");
382 inform (input_location, flag_guess_branch_prob 379 inform (input_location, flag_guess_branch_prob
383 ? G_("execution counts estimated") 380 ? G_("execution counts estimated")
645 FIELD_DECL, NULL_TREE, get_gcov_unsigned_t ()); 642 FIELD_DECL, NULL_TREE, get_gcov_unsigned_t ());
646 643
647 /* checksum */ 644 /* checksum */
648 field = build_decl (BUILTINS_LOCATION, 645 field = build_decl (BUILTINS_LOCATION,
649 FIELD_DECL, NULL_TREE, get_gcov_unsigned_t ()); 646 FIELD_DECL, NULL_TREE, get_gcov_unsigned_t ());
650 TREE_CHAIN (field) = fields; 647 DECL_CHAIN (field) = fields;
651 fields = field; 648 fields = field;
652 649
653 array_type = build_int_cst (NULL_TREE, counters - 1); 650 array_type = build_int_cst (NULL_TREE, counters - 1);
654 array_type = build_index_type (array_type); 651 array_type = build_index_type (array_type);
655 array_type = build_array_type (get_gcov_unsigned_t (), array_type); 652 array_type = build_array_type (get_gcov_unsigned_t (), array_type);
656 653
657 /* counters */ 654 /* counters */
658 field = build_decl (BUILTINS_LOCATION, 655 field = build_decl (BUILTINS_LOCATION,
659 FIELD_DECL, NULL_TREE, array_type); 656 FIELD_DECL, NULL_TREE, array_type);
660 TREE_CHAIN (field) = fields; 657 DECL_CHAIN (field) = fields;
661 fields = field; 658 fields = field;
662 659
663 finish_builtin_struct (type, "__gcov_fn_info", fields, NULL_TREE); 660 finish_builtin_struct (type, "__gcov_fn_info", fields, NULL_TREE);
664 661
665 return type; 662 return type;
679 676
680 /* ident */ 677 /* ident */
681 CONSTRUCTOR_APPEND_ELT (v1, fields, 678 CONSTRUCTOR_APPEND_ELT (v1, fields,
682 build_int_cstu (get_gcov_unsigned_t (), 679 build_int_cstu (get_gcov_unsigned_t (),
683 function->ident)); 680 function->ident));
684 fields = TREE_CHAIN (fields); 681 fields = DECL_CHAIN (fields);
685 682
686 /* checksum */ 683 /* checksum */
687 CONSTRUCTOR_APPEND_ELT (v1, fields, 684 CONSTRUCTOR_APPEND_ELT (v1, fields,
688 build_int_cstu (get_gcov_unsigned_t (), 685 build_int_cstu (get_gcov_unsigned_t (),
689 function->checksum)); 686 function->checksum));
690 fields = TREE_CHAIN (fields); 687 fields = DECL_CHAIN (fields);
691 688
692 /* counters */ 689 /* counters */
693 for (ix = 0; ix != GCOV_COUNTERS; ix++) 690 for (ix = 0; ix != GCOV_COUNTERS; ix++)
694 if (prg_ctr_mask & (1 << ix)) 691 if (prg_ctr_mask & (1 << ix))
695 CONSTRUCTOR_APPEND_ELT (v2, NULL, 692 CONSTRUCTOR_APPEND_ELT (v2, NULL,
713 tree gcov_merge_fn_type; 710 tree gcov_merge_fn_type;
714 711
715 /* counters */ 712 /* counters */
716 field = build_decl (BUILTINS_LOCATION, 713 field = build_decl (BUILTINS_LOCATION,
717 FIELD_DECL, NULL_TREE, get_gcov_unsigned_t ()); 714 FIELD_DECL, NULL_TREE, get_gcov_unsigned_t ());
718 TREE_CHAIN (field) = fields; 715 DECL_CHAIN (field) = fields;
719 fields = field; 716 fields = field;
720 717
721 /* values */ 718 /* values */
722 field = build_decl (BUILTINS_LOCATION, 719 field = build_decl (BUILTINS_LOCATION,
723 FIELD_DECL, NULL_TREE, gcov_ptr_type); 720 FIELD_DECL, NULL_TREE, gcov_ptr_type);
724 TREE_CHAIN (field) = fields; 721 DECL_CHAIN (field) = fields;
725 fields = field; 722 fields = field;
726 723
727 /* merge */ 724 /* merge */
728 gcov_merge_fn_type = 725 gcov_merge_fn_type =
729 build_function_type_list (void_type_node, 726 build_function_type_list (void_type_node,
730 gcov_ptr_type, get_gcov_unsigned_t (), 727 gcov_ptr_type, get_gcov_unsigned_t (),
731 NULL_TREE); 728 NULL_TREE);
732 field = build_decl (BUILTINS_LOCATION, 729 field = build_decl (BUILTINS_LOCATION,
733 FIELD_DECL, NULL_TREE, 730 FIELD_DECL, NULL_TREE,
734 build_pointer_type (gcov_merge_fn_type)); 731 build_pointer_type (gcov_merge_fn_type));
735 TREE_CHAIN (field) = fields; 732 DECL_CHAIN (field) = fields;
736 fields = field; 733 fields = field;
737 734
738 finish_builtin_struct (type, "__gcov_ctr_info", fields, NULL_TREE); 735 finish_builtin_struct (type, "__gcov_ctr_info", fields, NULL_TREE);
739 736
740 return type; 737 return type;
753 750
754 /* counters */ 751 /* counters */
755 CONSTRUCTOR_APPEND_ELT (v, fields, 752 CONSTRUCTOR_APPEND_ELT (v, fields,
756 build_int_cstu (get_gcov_unsigned_t (), 753 build_int_cstu (get_gcov_unsigned_t (),
757 prg_n_ctrs[counter])); 754 prg_n_ctrs[counter]));
758 fields = TREE_CHAIN (fields); 755 fields = DECL_CHAIN (fields);
759 756
760 if (prg_n_ctrs[counter]) 757 if (prg_n_ctrs[counter])
761 { 758 {
762 tree array_type; 759 tree array_type;
763 760
776 build1 (ADDR_EXPR, TREE_TYPE (fields), 773 build1 (ADDR_EXPR, TREE_TYPE (fields),
777 tree_ctr_tables[counter])); 774 tree_ctr_tables[counter]));
778 } 775 }
779 else 776 else
780 CONSTRUCTOR_APPEND_ELT (v, fields, null_pointer_node); 777 CONSTRUCTOR_APPEND_ELT (v, fields, null_pointer_node);
781 fields = TREE_CHAIN (fields); 778 fields = DECL_CHAIN (fields);
782 779
783 fn = build_decl (BUILTINS_LOCATION, 780 fn = build_decl (BUILTINS_LOCATION,
784 FUNCTION_DECL, 781 FUNCTION_DECL,
785 get_identifier (ctr_merge_functions[counter]), 782 get_identifier (ctr_merge_functions[counter]),
786 TREE_TYPE (TREE_TYPE (fields))); 783 TREE_TYPE (TREE_TYPE (fields)));
823 const_type = build_qualified_type (type, TYPE_QUAL_CONST); 820 const_type = build_qualified_type (type, TYPE_QUAL_CONST);
824 821
825 /* Version ident */ 822 /* Version ident */
826 field = build_decl (BUILTINS_LOCATION, 823 field = build_decl (BUILTINS_LOCATION,
827 FIELD_DECL, NULL_TREE, get_gcov_unsigned_t ()); 824 FIELD_DECL, NULL_TREE, get_gcov_unsigned_t ());
828 TREE_CHAIN (field) = fields; 825 DECL_CHAIN (field) = fields;
829 fields = field; 826 fields = field;
830 CONSTRUCTOR_APPEND_ELT (v1, field, 827 CONSTRUCTOR_APPEND_ELT (v1, field,
831 build_int_cstu (TREE_TYPE (field), GCOV_VERSION)); 828 build_int_cstu (TREE_TYPE (field), GCOV_VERSION));
832 829
833 /* next -- NULL */ 830 /* next -- NULL */
834 field = build_decl (BUILTINS_LOCATION, 831 field = build_decl (BUILTINS_LOCATION,
835 FIELD_DECL, NULL_TREE, build_pointer_type (const_type)); 832 FIELD_DECL, NULL_TREE, build_pointer_type (const_type));
836 TREE_CHAIN (field) = fields; 833 DECL_CHAIN (field) = fields;
837 fields = field; 834 fields = field;
838 CONSTRUCTOR_APPEND_ELT (v1, field, null_pointer_node); 835 CONSTRUCTOR_APPEND_ELT (v1, field, null_pointer_node);
839 836
840 /* stamp */ 837 /* stamp */
841 field = build_decl (BUILTINS_LOCATION, 838 field = build_decl (BUILTINS_LOCATION,
842 FIELD_DECL, NULL_TREE, get_gcov_unsigned_t ()); 839 FIELD_DECL, NULL_TREE, get_gcov_unsigned_t ());
843 TREE_CHAIN (field) = fields; 840 DECL_CHAIN (field) = fields;
844 fields = field; 841 fields = field;
845 CONSTRUCTOR_APPEND_ELT (v1, field, 842 CONSTRUCTOR_APPEND_ELT (v1, field,
846 build_int_cstu (TREE_TYPE (field), local_tick)); 843 build_int_cstu (TREE_TYPE (field), local_tick));
847 844
848 /* Filename */ 845 /* Filename */
849 string_type = build_pointer_type (build_qualified_type (char_type_node, 846 string_type = build_pointer_type (build_qualified_type (char_type_node,
850 TYPE_QUAL_CONST)); 847 TYPE_QUAL_CONST));
851 field = build_decl (BUILTINS_LOCATION, 848 field = build_decl (BUILTINS_LOCATION,
852 FIELD_DECL, NULL_TREE, string_type); 849 FIELD_DECL, NULL_TREE, string_type);
853 TREE_CHAIN (field) = fields; 850 DECL_CHAIN (field) = fields;
854 fields = field; 851 fields = field;
855 da_file_name_len = strlen (da_file_name); 852 da_file_name_len = strlen (da_file_name);
856 filename_string = build_string (da_file_name_len + 1, da_file_name); 853 filename_string = build_string (da_file_name_len + 1, da_file_name);
857 TREE_TYPE (filename_string) = build_array_type 854 TREE_TYPE (filename_string) = build_array_type
858 (char_type_node, build_index_type 855 (char_type_node, build_index_type
882 fn_info_value = null_pointer_node; 879 fn_info_value = null_pointer_node;
883 880
884 /* number of functions */ 881 /* number of functions */
885 field = build_decl (BUILTINS_LOCATION, 882 field = build_decl (BUILTINS_LOCATION,
886 FIELD_DECL, NULL_TREE, get_gcov_unsigned_t ()); 883 FIELD_DECL, NULL_TREE, get_gcov_unsigned_t ());
887 TREE_CHAIN (field) = fields; 884 DECL_CHAIN (field) = fields;
888 fields = field; 885 fields = field;
889 CONSTRUCTOR_APPEND_ELT (v1, field, 886 CONSTRUCTOR_APPEND_ELT (v1, field,
890 build_int_cstu (get_gcov_unsigned_t (), n_fns)); 887 build_int_cstu (get_gcov_unsigned_t (), n_fns));
891 888
892 /* fn_info table */ 889 /* fn_info table */
893 field = build_decl (BUILTINS_LOCATION, 890 field = build_decl (BUILTINS_LOCATION,
894 FIELD_DECL, NULL_TREE, fn_info_ptr_type); 891 FIELD_DECL, NULL_TREE, fn_info_ptr_type);
895 TREE_CHAIN (field) = fields; 892 DECL_CHAIN (field) = fields;
896 fields = field; 893 fields = field;
897 CONSTRUCTOR_APPEND_ELT (v1, field, fn_info_value); 894 CONSTRUCTOR_APPEND_ELT (v1, field, fn_info_value);
898 895
899 /* counter_mask */ 896 /* counter_mask */
900 field = build_decl (BUILTINS_LOCATION, 897 field = build_decl (BUILTINS_LOCATION,
901 FIELD_DECL, NULL_TREE, get_gcov_unsigned_t ()); 898 FIELD_DECL, NULL_TREE, get_gcov_unsigned_t ());
902 TREE_CHAIN (field) = fields; 899 DECL_CHAIN (field) = fields;
903 fields = field; 900 fields = field;
904 CONSTRUCTOR_APPEND_ELT (v1, field, 901 CONSTRUCTOR_APPEND_ELT (v1, field,
905 build_int_cstu (get_gcov_unsigned_t (), 902 build_int_cstu (get_gcov_unsigned_t (),
906 prg_ctr_mask)); 903 prg_ctr_mask));
907 904
917 build_ctr_info_value (ix, ctr_info_type)); 914 build_ctr_info_value (ix, ctr_info_type));
918 ctr_info_value = build_constructor (ctr_info_ary_type, v2); 915 ctr_info_value = build_constructor (ctr_info_ary_type, v2);
919 916
920 field = build_decl (BUILTINS_LOCATION, 917 field = build_decl (BUILTINS_LOCATION,
921 FIELD_DECL, NULL_TREE, ctr_info_ary_type); 918 FIELD_DECL, NULL_TREE, ctr_info_ary_type);
922 TREE_CHAIN (field) = fields; 919 DECL_CHAIN (field) = fields;
923 fields = field; 920 fields = field;
924 CONSTRUCTOR_APPEND_ELT (v1, field, ctr_info_value); 921 CONSTRUCTOR_APPEND_ELT (v1, field, ctr_info_value);
925 922
926 finish_builtin_struct (type, "__gcov_info", fields, NULL_TREE); 923 finish_builtin_struct (type, "__gcov_info", fields, NULL_TREE);
927 924