LCOV - code coverage report
Current view: top level - gcc/lto - lto-lang.cc (source / functions) Coverage Total Hit
Test: gcc.info Lines: 69.9 % 485 339
Test Date: 2024-04-13 14:00:49 Functions: 80.0 % 40 32
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: - 0 0

             Branch data     Line data    Source code
       1                 :             : /* Language-dependent hooks for LTO.
       2                 :             :    Copyright (C) 2009-2024 Free Software Foundation, Inc.
       3                 :             :    Contributed by CodeSourcery, Inc.
       4                 :             : 
       5                 :             : This file is part of GCC.
       6                 :             : 
       7                 :             : GCC is free software; you can redistribute it and/or modify it under
       8                 :             : the terms of the GNU General Public License as published by the Free
       9                 :             : Software Foundation; either version 3, or (at your option) any later
      10                 :             : version.
      11                 :             : 
      12                 :             : GCC is distributed in the hope that it will be useful, but WITHOUT ANY
      13                 :             : WARRANTY; without even the implied warranty of MERCHANTABILITY or
      14                 :             : FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
      15                 :             : for more details.
      16                 :             : 
      17                 :             : You should have received a copy of the GNU General Public License
      18                 :             : along with GCC; see the file COPYING3.  If not see
      19                 :             : <http://www.gnu.org/licenses/>.  */
      20                 :             : 
      21                 :             : #include "config.h"
      22                 :             : #include "system.h"
      23                 :             : #include "coretypes.h"
      24                 :             : #include "target.h"
      25                 :             : #include "function.h"
      26                 :             : #include "basic-block.h"
      27                 :             : #include "tree.h"
      28                 :             : #include "gimple.h"
      29                 :             : #include "stringpool.h"
      30                 :             : #include "diagnostic-core.h"
      31                 :             : #include "stor-layout.h"
      32                 :             : #include "langhooks.h"
      33                 :             : #include "langhooks-def.h"
      34                 :             : #include "debug.h"
      35                 :             : #include "lto-tree.h"
      36                 :             : #include "lto.h"
      37                 :             : #include "lto-common.h"
      38                 :             : #include "stringpool.h"
      39                 :             : #include "attribs.h"
      40                 :             : 
      41                 :             : /* LTO specific dumps.  */
      42                 :             : int lto_link_dump_id, decl_merge_dump_id, partition_dump_id;
      43                 :             : 
      44                 :             : static tree handle_noreturn_attribute (tree *, tree, tree, int, bool *);
      45                 :             : static tree handle_leaf_attribute (tree *, tree, tree, int, bool *);
      46                 :             : static tree handle_const_attribute (tree *, tree, tree, int, bool *);
      47                 :             : static tree handle_malloc_attribute (tree *, tree, tree, int, bool *);
      48                 :             : static tree handle_pure_attribute (tree *, tree, tree, int, bool *);
      49                 :             : static tree handle_novops_attribute (tree *, tree, tree, int, bool *);
      50                 :             : static tree handle_nonnull_attribute (tree *, tree, tree, int, bool *);
      51                 :             : static tree handle_nothrow_attribute (tree *, tree, tree, int, bool *);
      52                 :             : static tree handle_sentinel_attribute (tree *, tree, tree, int, bool *);
      53                 :             : static tree handle_type_generic_attribute (tree *, tree, tree, int, bool *);
      54                 :             : static tree handle_transaction_pure_attribute (tree *, tree, tree, int, bool *);
      55                 :             : static tree handle_returns_twice_attribute (tree *, tree, tree, int, bool *);
      56                 :             : static tree handle_patchable_function_entry_attribute (tree *, tree, tree,
      57                 :             :                                                        int, bool *);
      58                 :             : static tree ignore_attribute (tree *, tree, tree, int, bool *);
      59                 :             : 
      60                 :             : static tree handle_format_attribute (tree *, tree, tree, int, bool *);
      61                 :             : static tree handle_fnspec_attribute (tree *, tree, tree, int, bool *);
      62                 :             : static tree handle_format_arg_attribute (tree *, tree, tree, int, bool *);
      63                 :             : 
      64                 :             : /* Helper to define attribute exclusions.  */
      65                 :             : #define ATTR_EXCL(name, function, type, variable)       \
      66                 :             :   { name, function, type, variable }
      67                 :             : 
      68                 :             : /* Define attributes that are mutually exclusive with one another.  */
      69                 :             : static const struct attribute_spec::exclusions attr_noreturn_exclusions[] =
      70                 :             : {
      71                 :             :   ATTR_EXCL ("noreturn", true, true, true),
      72                 :             :   ATTR_EXCL ("alloc_align", true, true, true),
      73                 :             :   ATTR_EXCL ("alloc_size", true, true, true),
      74                 :             :   ATTR_EXCL ("const", true, true, true),
      75                 :             :   ATTR_EXCL ("malloc", true, true, true),
      76                 :             :   ATTR_EXCL ("pure", true, true, true),
      77                 :             :   ATTR_EXCL ("returns_twice", true, true, true),
      78                 :             :   ATTR_EXCL ("warn_unused_result", true, true, true),
      79                 :             :   ATTR_EXCL (NULL, false, false, false),
      80                 :             : };
      81                 :             : 
      82                 :             : static const struct attribute_spec::exclusions attr_returns_twice_exclusions[] =
      83                 :             : {
      84                 :             :   ATTR_EXCL ("noreturn", true, true, true),
      85                 :             :   ATTR_EXCL (NULL, false, false, false),
      86                 :             : };
      87                 :             : 
      88                 :             : static const struct attribute_spec::exclusions attr_const_pure_exclusions[] =
      89                 :             : {
      90                 :             :   ATTR_EXCL ("const", true, true, true),
      91                 :             :   ATTR_EXCL ("noreturn", true, true, true),
      92                 :             :   ATTR_EXCL ("pure", true, true, true),
      93                 :             :   ATTR_EXCL (NULL, false, false, false)
      94                 :             : };
      95                 :             : 
      96                 :             : /* Table of machine-independent attributes supported in GIMPLE.  */
      97                 :             : static const attribute_spec lto_gnu_attributes[] =
      98                 :             : {
      99                 :             :   /* { name, min_len, max_len, decl_req, type_req, fn_type_req,
     100                 :             :        affects_type_identity, handler, exclude } */
     101                 :             :   { "noreturn",               0, 0, true,  false, false, false,
     102                 :             :                               handle_noreturn_attribute,
     103                 :             :                               attr_noreturn_exclusions },
     104                 :             :   { "leaf",                 0, 0, true,  false, false, false,
     105                 :             :                               handle_leaf_attribute, NULL },
     106                 :             :   /* The same comments as for noreturn attributes apply to const ones.  */
     107                 :             :   { "const",                  0, 0, true,  false, false, false,
     108                 :             :                               handle_const_attribute,
     109                 :             :                               attr_const_pure_exclusions },
     110                 :             :   { "malloc",                 0, 0, true,  false, false, false,
     111                 :             :                               handle_malloc_attribute, NULL },
     112                 :             :   { "pure",                   0, 0, true,  false, false, false,
     113                 :             :                               handle_pure_attribute,
     114                 :             :                               attr_const_pure_exclusions },
     115                 :             :   { "no vops",                0, 0, true,  false, false, false,
     116                 :             :                               handle_novops_attribute, NULL },
     117                 :             :   { "nonnull",                0, -1, false, true, true, false,
     118                 :             :                               handle_nonnull_attribute, NULL },
     119                 :             :   { "nothrow",                0, 0, true,  false, false, false,
     120                 :             :                               handle_nothrow_attribute, NULL },
     121                 :             :   { "patchable_function_entry", 1, 2, true, false, false, false,
     122                 :             :                               handle_patchable_function_entry_attribute,
     123                 :             :                               NULL },
     124                 :             :   { "returns_twice",          0, 0, true,  false, false, false,
     125                 :             :                               handle_returns_twice_attribute,
     126                 :             :                               attr_returns_twice_exclusions },
     127                 :             :   { "sentinel",               0, 1, false, true, true, false,
     128                 :             :                               handle_sentinel_attribute, NULL },
     129                 :             :   { "type generic",           0, 0, false, true, true, false,
     130                 :             :                               handle_type_generic_attribute, NULL },
     131                 :             :   { "fn spec",                      1, 1, false, true, true, false,
     132                 :             :                               handle_fnspec_attribute, NULL },
     133                 :             :   { "transaction_pure",             0, 0, false, true, true, false,
     134                 :             :                               handle_transaction_pure_attribute, NULL },
     135                 :             :   /* For internal use only.  The leading '*' both prevents its usage in
     136                 :             :      source code and signals that it may be overridden by machine tables.  */
     137                 :             :   { "*tm regparm",            0, 0, false, true, true, false,
     138                 :             :                               ignore_attribute, NULL }
     139                 :             : };
     140                 :             : 
     141                 :             : static const scoped_attribute_specs lto_gnu_attribute_table =
     142                 :             : {
     143                 :             :   "gnu", { lto_gnu_attributes }
     144                 :             : };
     145                 :             : 
     146                 :             : /* Give the specifications for the format attributes, used by C and all
     147                 :             :    descendants.  */
     148                 :             : 
     149                 :             : static const attribute_spec lto_format_attributes[] =
     150                 :             : {
     151                 :             :   /* { name, min_len, max_len, decl_req, type_req, fn_type_req,
     152                 :             :        affects_type_identity, handler, exclude } */
     153                 :             :   { "format",                 3, 3, false, true,  true, false,
     154                 :             :                               handle_format_attribute, NULL },
     155                 :             :   { "format_arg",             1, 1, false, true,  true, false,
     156                 :             :                               handle_format_arg_attribute, NULL },
     157                 :             : };
     158                 :             : 
     159                 :             : static const scoped_attribute_specs lto_format_attribute_table =
     160                 :             : {
     161                 :             :   "gnu", { lto_format_attributes }
     162                 :             : };
     163                 :             : 
     164                 :             : static const scoped_attribute_specs *const lto_attribute_table[] =
     165                 :             : {
     166                 :             :   &lto_gnu_attribute_table,
     167                 :             :   &lto_format_attribute_table
     168                 :             : };
     169                 :             : 
     170                 :             : enum built_in_attribute
     171                 :             : {
     172                 :             : #define DEF_ATTR_NULL_TREE(ENUM) ENUM,
     173                 :             : #define DEF_ATTR_INT(ENUM, VALUE) ENUM,
     174                 :             : #define DEF_ATTR_STRING(ENUM, VALUE) ENUM,
     175                 :             : #define DEF_ATTR_IDENT(ENUM, STRING) ENUM,
     176                 :             : #define DEF_ATTR_TREE_LIST(ENUM, PURPOSE, VALUE, CHAIN) ENUM,
     177                 :             : #include "builtin-attrs.def"
     178                 :             : #undef DEF_ATTR_NULL_TREE
     179                 :             : #undef DEF_ATTR_INT
     180                 :             : #undef DEF_ATTR_STRING
     181                 :             : #undef DEF_ATTR_IDENT
     182                 :             : #undef DEF_ATTR_TREE_LIST
     183                 :             :   ATTR_LAST
     184                 :             : };
     185                 :             : 
     186                 :             : static GTY(()) tree built_in_attributes[(int) ATTR_LAST];
     187                 :             : 
     188                 :             : /* Builtin types.  */
     189                 :             : 
     190                 :             : enum lto_builtin_type
     191                 :             : {
     192                 :             : #define DEF_PRIMITIVE_TYPE(NAME, VALUE) NAME,
     193                 :             : #define DEF_FUNCTION_TYPE_0(NAME, RETURN) NAME,
     194                 :             : #define DEF_FUNCTION_TYPE_1(NAME, RETURN, ARG1) NAME,
     195                 :             : #define DEF_FUNCTION_TYPE_2(NAME, RETURN, ARG1, ARG2) NAME,
     196                 :             : #define DEF_FUNCTION_TYPE_3(NAME, RETURN, ARG1, ARG2, ARG3) NAME,
     197                 :             : #define DEF_FUNCTION_TYPE_4(NAME, RETURN, ARG1, ARG2, ARG3, ARG4) NAME,
     198                 :             : #define DEF_FUNCTION_TYPE_5(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5) NAME,
     199                 :             : #define DEF_FUNCTION_TYPE_6(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
     200                 :             :                             ARG6) NAME,
     201                 :             : #define DEF_FUNCTION_TYPE_7(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
     202                 :             :                             ARG6, ARG7) NAME,
     203                 :             : #define DEF_FUNCTION_TYPE_8(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
     204                 :             :                             ARG6, ARG7, ARG8) NAME,
     205                 :             : #define DEF_FUNCTION_TYPE_9(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
     206                 :             :                             ARG6, ARG7, ARG8, ARG9) NAME,
     207                 :             : #define DEF_FUNCTION_TYPE_10(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
     208                 :             :                              ARG6, ARG7, ARG8, ARG9, ARG10) NAME,
     209                 :             : #define DEF_FUNCTION_TYPE_11(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
     210                 :             :                              ARG6, ARG7, ARG8, ARG9, ARG10, ARG11) NAME,
     211                 :             : #define DEF_FUNCTION_TYPE_VAR_0(NAME, RETURN) NAME,
     212                 :             : #define DEF_FUNCTION_TYPE_VAR_1(NAME, RETURN, ARG1) NAME,
     213                 :             : #define DEF_FUNCTION_TYPE_VAR_2(NAME, RETURN, ARG1, ARG2) NAME,
     214                 :             : #define DEF_FUNCTION_TYPE_VAR_3(NAME, RETURN, ARG1, ARG2, ARG3) NAME,
     215                 :             : #define DEF_FUNCTION_TYPE_VAR_4(NAME, RETURN, ARG1, ARG2, ARG3, ARG4) NAME,
     216                 :             : #define DEF_FUNCTION_TYPE_VAR_5(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG6) \
     217                 :             :                                 NAME,
     218                 :             : #define DEF_FUNCTION_TYPE_VAR_6(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
     219                 :             :                                  ARG6) NAME,
     220                 :             : #define DEF_FUNCTION_TYPE_VAR_7(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
     221                 :             :                                 ARG6, ARG7) NAME,
     222                 :             : #define DEF_POINTER_TYPE(NAME, TYPE) NAME,
     223                 :             : #include "builtin-types.def"
     224                 :             : #undef DEF_PRIMITIVE_TYPE
     225                 :             : #undef DEF_FUNCTION_TYPE_0
     226                 :             : #undef DEF_FUNCTION_TYPE_1
     227                 :             : #undef DEF_FUNCTION_TYPE_2
     228                 :             : #undef DEF_FUNCTION_TYPE_3
     229                 :             : #undef DEF_FUNCTION_TYPE_4
     230                 :             : #undef DEF_FUNCTION_TYPE_5
     231                 :             : #undef DEF_FUNCTION_TYPE_6
     232                 :             : #undef DEF_FUNCTION_TYPE_7
     233                 :             : #undef DEF_FUNCTION_TYPE_8
     234                 :             : #undef DEF_FUNCTION_TYPE_9
     235                 :             : #undef DEF_FUNCTION_TYPE_10
     236                 :             : #undef DEF_FUNCTION_TYPE_11
     237                 :             : #undef DEF_FUNCTION_TYPE_VAR_0
     238                 :             : #undef DEF_FUNCTION_TYPE_VAR_1
     239                 :             : #undef DEF_FUNCTION_TYPE_VAR_2
     240                 :             : #undef DEF_FUNCTION_TYPE_VAR_3
     241                 :             : #undef DEF_FUNCTION_TYPE_VAR_4
     242                 :             : #undef DEF_FUNCTION_TYPE_VAR_5
     243                 :             : #undef DEF_FUNCTION_TYPE_VAR_6
     244                 :             : #undef DEF_FUNCTION_TYPE_VAR_7
     245                 :             : #undef DEF_POINTER_TYPE
     246                 :             :   BT_LAST
     247                 :             : };
     248                 :             : 
     249                 :             : typedef enum lto_builtin_type builtin_type;
     250                 :             : 
     251                 :             : static GTY(()) tree builtin_types[(int) BT_LAST + 1];
     252                 :             : 
     253                 :             : static GTY(()) tree string_type_node;
     254                 :             : static GTY(()) tree const_string_type_node;
     255                 :             : static GTY(()) tree wint_type_node;
     256                 :             : static GTY(()) tree intmax_type_node;
     257                 :             : static GTY(()) tree uintmax_type_node;
     258                 :             : static GTY(()) tree signed_size_type_node;
     259                 :             : 
     260                 :             : /* Flags needed to process builtins.def.  */
     261                 :             : int flag_isoc94;
     262                 :             : int flag_isoc99;
     263                 :             : int flag_isoc11;
     264                 :             : int flag_isoc23;
     265                 :             : 
     266                 :             : /* Attribute handlers.  */
     267                 :             : 
     268                 :             : /* Handle a "noreturn" attribute; arguments as in
     269                 :             :    struct attribute_spec.handler.  */
     270                 :             : 
     271                 :             : static tree
     272                 :      390639 : handle_noreturn_attribute (tree *node, tree ARG_UNUSED (name),
     273                 :             :                            tree ARG_UNUSED (args), int ARG_UNUSED (flags),
     274                 :             :                            bool * ARG_UNUSED (no_add_attrs))
     275                 :             : {
     276                 :      390639 :   tree type = TREE_TYPE (*node);
     277                 :             : 
     278                 :      390639 :   if (TREE_CODE (*node) == FUNCTION_DECL)
     279                 :      390639 :     TREE_THIS_VOLATILE (*node) = 1;
     280                 :           0 :   else if (TREE_CODE (type) == POINTER_TYPE
     281                 :           0 :            && TREE_CODE (TREE_TYPE (type)) == FUNCTION_TYPE)
     282                 :           0 :     TREE_TYPE (*node)
     283                 :           0 :       = build_pointer_type
     284                 :           0 :         (build_type_variant (TREE_TYPE (type),
     285                 :             :                              TYPE_READONLY (TREE_TYPE (type)), 1));
     286                 :             :   else
     287                 :           0 :     gcc_unreachable ();
     288                 :             : 
     289                 :      390639 :   return NULL_TREE;
     290                 :             : }
     291                 :             : 
     292                 :             : /* Handle a "leaf" attribute; arguments as in
     293                 :             :    struct attribute_spec.handler.  */
     294                 :             : 
     295                 :             : static tree
     296                 :    36686295 : handle_leaf_attribute (tree *node, tree name,
     297                 :             :                        tree ARG_UNUSED (args),
     298                 :             :                        int ARG_UNUSED (flags), bool *no_add_attrs)
     299                 :             : {
     300                 :    36686295 :   if (TREE_CODE (*node) != FUNCTION_DECL)
     301                 :             :     {
     302                 :           0 :       warning (OPT_Wattributes, "%qE attribute ignored", name);
     303                 :           0 :       *no_add_attrs = true;
     304                 :             :     }
     305                 :    36686295 :   if (!TREE_PUBLIC (*node))
     306                 :             :     {
     307                 :           0 :       warning (OPT_Wattributes, "%qE attribute has no effect on unit local functions", name);
     308                 :           0 :       *no_add_attrs = true;
     309                 :             :     }
     310                 :             : 
     311                 :    36686295 :   return NULL_TREE;
     312                 :             : }
     313                 :             : 
     314                 :             : /* Handle a "const" attribute; arguments as in
     315                 :             :    struct attribute_spec.handler.  */
     316                 :             : 
     317                 :             : static tree
     318                 :    15342962 : handle_const_attribute (tree *node, tree ARG_UNUSED (name),
     319                 :             :                         tree ARG_UNUSED (args), int ARG_UNUSED (flags),
     320                 :             :                         bool * ARG_UNUSED (no_add_attrs))
     321                 :             : {
     322                 :    15342962 :   if (TREE_CODE (*node) != FUNCTION_DECL
     323                 :    15342962 :       || !fndecl_built_in_p (*node))
     324                 :           0 :     inform (UNKNOWN_LOCATION, "%s:%s: %E: %E", __FILE__, __func__, *node, name);
     325                 :             : 
     326                 :    15342962 :   tree type = TREE_TYPE (*node);
     327                 :             : 
     328                 :             :   /* See FIXME comment on noreturn in c_common_attribute_table.  */
     329                 :    15342962 :   if (TREE_CODE (*node) == FUNCTION_DECL)
     330                 :    15342962 :     TREE_READONLY (*node) = 1;
     331                 :           0 :   else if (TREE_CODE (type) == POINTER_TYPE
     332                 :           0 :            && TREE_CODE (TREE_TYPE (type)) == FUNCTION_TYPE)
     333                 :           0 :     TREE_TYPE (*node)
     334                 :           0 :       = build_pointer_type
     335                 :           0 :         (build_type_variant (TREE_TYPE (type), 1,
     336                 :             :                              TREE_THIS_VOLATILE (TREE_TYPE (type))));
     337                 :             :   else
     338                 :           0 :     gcc_unreachable ();
     339                 :             : 
     340                 :    15342962 :   return NULL_TREE;
     341                 :             : }
     342                 :             : 
     343                 :             : 
     344                 :             : /* Handle a "malloc" attribute; arguments as in
     345                 :             :    struct attribute_spec.handler.  */
     346                 :             : 
     347                 :             : static tree
     348                 :      261247 : handle_malloc_attribute (tree *node, tree ARG_UNUSED (name),
     349                 :             :                          tree ARG_UNUSED (args), int ARG_UNUSED (flags),
     350                 :             :                          bool * ARG_UNUSED (no_add_attrs))
     351                 :             : {
     352                 :      261247 :   if (TREE_CODE (*node) == FUNCTION_DECL
     353                 :      261247 :       && POINTER_TYPE_P (TREE_TYPE (TREE_TYPE (*node))))
     354                 :      261247 :     DECL_IS_MALLOC (*node) = 1;
     355                 :             :   else
     356                 :           0 :     gcc_unreachable ();
     357                 :             : 
     358                 :      261247 :   return NULL_TREE;
     359                 :             : }
     360                 :             : 
     361                 :             : 
     362                 :             : /* Handle a "pure" attribute; arguments as in
     363                 :             :    struct attribute_spec.handler.  */
     364                 :             : 
     365                 :             : static tree
     366                 :     1987356 : handle_pure_attribute (tree *node, tree ARG_UNUSED (name),
     367                 :             :                        tree ARG_UNUSED (args), int ARG_UNUSED (flags),
     368                 :             :                        bool * ARG_UNUSED (no_add_attrs))
     369                 :             : {
     370                 :     1987356 :   if (TREE_CODE (*node) == FUNCTION_DECL)
     371                 :     1987356 :     DECL_PURE_P (*node) = 1;
     372                 :             :   else
     373                 :           0 :     gcc_unreachable ();
     374                 :             : 
     375                 :     1987356 :   return NULL_TREE;
     376                 :             : }
     377                 :             : 
     378                 :             : 
     379                 :             : /* Handle a "no vops" attribute; arguments as in
     380                 :             :    struct attribute_spec.handler.  */
     381                 :             : 
     382                 :             : static tree
     383                 :      173984 : handle_novops_attribute (tree *node, tree ARG_UNUSED (name),
     384                 :             :                          tree ARG_UNUSED (args), int ARG_UNUSED (flags),
     385                 :             :                          bool *ARG_UNUSED (no_add_attrs))
     386                 :             : {
     387                 :      173984 :   gcc_assert (TREE_CODE (*node) == FUNCTION_DECL);
     388                 :      173984 :   DECL_IS_NOVOPS (*node) = 1;
     389                 :      173984 :   return NULL_TREE;
     390                 :             : }
     391                 :             : 
     392                 :             : 
     393                 :             : /* Helper for nonnull attribute handling; fetch the operand number
     394                 :             :    from the attribute argument list.  */
     395                 :             : 
     396                 :             : static bool
     397                 :     1652848 : get_nonnull_operand (tree arg_num_expr, unsigned HOST_WIDE_INT *valp)
     398                 :             : {
     399                 :             :   /* Verify the arg number is a constant.  */
     400                 :     1652848 :   if (!tree_fits_uhwi_p (arg_num_expr))
     401                 :             :     return false;
     402                 :             : 
     403                 :     1652848 :   *valp = TREE_INT_CST_LOW (arg_num_expr);
     404                 :     1652848 :   return true;
     405                 :             : }
     406                 :             : 
     407                 :             : /* Handle the "nonnull" attribute.  */
     408                 :             : 
     409                 :             : static tree
     410                 :     4806308 : handle_nonnull_attribute (tree *node, tree ARG_UNUSED (name),
     411                 :             :                           tree args, int ARG_UNUSED (flags),
     412                 :             :                           bool * ARG_UNUSED (no_add_attrs))
     413                 :             : {
     414                 :     4806308 :   tree type = *node;
     415                 :             : 
     416                 :             :   /* If no arguments are specified, all pointer arguments should be
     417                 :             :      non-null.  Verify a full prototype is given so that the arguments
     418                 :             :      will have the correct types when we actually check them later.
     419                 :             :      Avoid diagnosing type-generic built-ins since those have no
     420                 :             :      prototype.  */
     421                 :     4806308 :   if (!args)
     422                 :             :     {
     423                 :     3544924 :       gcc_assert (prototype_p (type)
     424                 :             :                   || !TYPE_ATTRIBUTES (type)
     425                 :             :                   || lookup_attribute ("type generic", TYPE_ATTRIBUTES (type)));
     426                 :             : 
     427                 :     3544924 :       return NULL_TREE;
     428                 :             :     }
     429                 :             : 
     430                 :             :   /* Argument list specified.  Verify that each argument number references
     431                 :             :      a pointer argument.  */
     432                 :     2914232 :   for (; args; args = TREE_CHAIN (args))
     433                 :             :     {
     434                 :     1652848 :       tree argument;
     435                 :     1652848 :       unsigned HOST_WIDE_INT arg_num = 0, ck_num;
     436                 :             : 
     437                 :     1652848 :       if (!get_nonnull_operand (TREE_VALUE (args), &arg_num))
     438                 :           0 :         gcc_unreachable ();
     439                 :             : 
     440                 :     1652848 :       argument = TYPE_ARG_TYPES (type);
     441                 :     1652848 :       if (argument)
     442                 :             :         {
     443                 :     1696344 :           for (ck_num = 1; ; ck_num++)
     444                 :             :             {
     445                 :     3349192 :               if (!argument || ck_num == arg_num)
     446                 :             :                 break;
     447                 :     1696344 :               argument = TREE_CHAIN (argument);
     448                 :             :             }
     449                 :             : 
     450                 :     1652848 :           gcc_assert (argument
     451                 :             :                       && TREE_CODE (TREE_VALUE (argument)) == POINTER_TYPE);
     452                 :             :         }
     453                 :             :     }
     454                 :             : 
     455                 :             :   return NULL_TREE;
     456                 :             : }
     457                 :             : 
     458                 :             : 
     459                 :             : /* Handle a "nothrow" attribute; arguments as in
     460                 :             :    struct attribute_spec.handler.  */
     461                 :             : 
     462                 :             : static tree
     463                 :    37896323 : handle_nothrow_attribute (tree *node, tree ARG_UNUSED (name),
     464                 :             :                           tree ARG_UNUSED (args), int ARG_UNUSED (flags),
     465                 :             :                           bool * ARG_UNUSED (no_add_attrs))
     466                 :             : {
     467                 :    37896323 :   if (TREE_CODE (*node) == FUNCTION_DECL)
     468                 :    37896323 :     TREE_NOTHROW (*node) = 1;
     469                 :             :   else
     470                 :           0 :     gcc_unreachable ();
     471                 :             : 
     472                 :    37896323 :   return NULL_TREE;
     473                 :             : }
     474                 :             : 
     475                 :             : 
     476                 :             : /* Handle a "sentinel" attribute.  */
     477                 :             : 
     478                 :             : static tree
     479                 :      130488 : handle_sentinel_attribute (tree *node, tree ARG_UNUSED (name), tree args,
     480                 :             :                            int ARG_UNUSED (flags),
     481                 :             :                            bool * ARG_UNUSED (no_add_attrs))
     482                 :             : {
     483                 :      130488 :   gcc_assert (stdarg_p (*node));
     484                 :             : 
     485                 :      130488 :   if (args)
     486                 :             :     {
     487                 :       43496 :       tree position = TREE_VALUE (args);
     488                 :       43496 :       gcc_assert (TREE_CODE (position) == INTEGER_CST);
     489                 :       43496 :       if (tree_int_cst_lt (position, integer_zero_node))
     490                 :           0 :         gcc_unreachable ();
     491                 :             :     }
     492                 :             : 
     493                 :      130488 :   return NULL_TREE;
     494                 :             : }
     495                 :             : 
     496                 :             : /* Handle a "type_generic" attribute.  */
     497                 :             : 
     498                 :             : static tree
     499                 :      674188 : handle_type_generic_attribute (tree *node, tree ARG_UNUSED (name),
     500                 :             :                                tree ARG_UNUSED (args), int ARG_UNUSED (flags),
     501                 :             :                                bool * ARG_UNUSED (no_add_attrs))
     502                 :             : {
     503                 :             :   /* Ensure we have a function type.  */
     504                 :      674188 :   gcc_assert (TREE_CODE (*node) == FUNCTION_TYPE);
     505                 :             :   
     506                 :             :   /* Ensure we have a variadic function.  */
     507                 :      674188 :   gcc_assert (!prototype_p (*node) || stdarg_p (*node));
     508                 :             : 
     509                 :      674188 :   return NULL_TREE;
     510                 :             : }
     511                 :             : 
     512                 :             : /* Handle a "transaction_pure" attribute.  */
     513                 :             : 
     514                 :             : static tree
     515                 :      262804 : handle_transaction_pure_attribute (tree *node, tree ARG_UNUSED (name),
     516                 :             :                                    tree ARG_UNUSED (args),
     517                 :             :                                    int ARG_UNUSED (flags),
     518                 :             :                                    bool * ARG_UNUSED (no_add_attrs))
     519                 :             : {
     520                 :             :   /* Ensure we have a function type.  */
     521                 :      262804 :   gcc_assert (TREE_CODE (*node) == FUNCTION_TYPE);
     522                 :             : 
     523                 :      262804 :   return NULL_TREE;
     524                 :             : }
     525                 :             : 
     526                 :             : /* Handle a "returns_twice" attribute.  */
     527                 :             : 
     528                 :             : static tree
     529                 :       21750 : handle_returns_twice_attribute (tree *node, tree ARG_UNUSED (name),
     530                 :             :                                 tree ARG_UNUSED (args),
     531                 :             :                                 int ARG_UNUSED (flags),
     532                 :             :                                 bool * ARG_UNUSED (no_add_attrs))
     533                 :             : {
     534                 :       21750 :   gcc_assert (TREE_CODE (*node) == FUNCTION_DECL);
     535                 :             : 
     536                 :       21750 :   DECL_IS_RETURNS_TWICE (*node) = 1;
     537                 :             : 
     538                 :       21750 :   return NULL_TREE;
     539                 :             : }
     540                 :             : 
     541                 :             : static tree
     542                 :           0 : handle_patchable_function_entry_attribute (tree *, tree, tree, int, bool *)
     543                 :             : {
     544                 :             :   /* Nothing to be done here.  */
     545                 :           0 :   return NULL_TREE;
     546                 :             : }
     547                 :             : 
     548                 :             : /* Ignore the given attribute.  Used when this attribute may be usefully
     549                 :             :    overridden by the target, but is not used generically.  */
     550                 :             : 
     551                 :             : static tree
     552                 :           0 : ignore_attribute (tree * ARG_UNUSED (node), tree ARG_UNUSED (name),
     553                 :             :                   tree ARG_UNUSED (args), int ARG_UNUSED (flags),
     554                 :             :                   bool *no_add_attrs)
     555                 :             : {
     556                 :           0 :   *no_add_attrs = true;
     557                 :           0 :   return NULL_TREE;
     558                 :             : }
     559                 :             : 
     560                 :             : /* Handle a "format" attribute; arguments as in
     561                 :             :    struct attribute_spec.handler.  */
     562                 :             : 
     563                 :             : static tree
     564                 :     1130896 : handle_format_attribute (tree * ARG_UNUSED (node), tree ARG_UNUSED (name),
     565                 :             :                          tree ARG_UNUSED (args), int ARG_UNUSED (flags),
     566                 :             :                          bool *no_add_attrs)
     567                 :             : {
     568                 :     1130896 :   *no_add_attrs = true;
     569                 :     1130896 :   return NULL_TREE;
     570                 :             : }
     571                 :             : 
     572                 :             : 
     573                 :             : /* Handle a "format_arg" attribute; arguments as in
     574                 :             :    struct attribute_spec.handler.  */
     575                 :             : 
     576                 :             : tree
     577                 :      130488 : handle_format_arg_attribute (tree * ARG_UNUSED (node), tree ARG_UNUSED (name),
     578                 :             :                              tree ARG_UNUSED (args), int ARG_UNUSED (flags),
     579                 :             :                              bool *no_add_attrs)
     580                 :             : {
     581                 :      130488 :   *no_add_attrs = true;
     582                 :      130488 :   return NULL_TREE;
     583                 :             : }
     584                 :             : 
     585                 :             : 
     586                 :             : /* Handle a "fn spec" attribute; arguments as in
     587                 :             :    struct attribute_spec.handler.  */
     588                 :             : 
     589                 :             : static tree
     590                 :    10011912 : handle_fnspec_attribute (tree *node ATTRIBUTE_UNUSED, tree ARG_UNUSED (name),
     591                 :             :                          tree args, int ARG_UNUSED (flags),
     592                 :             :                          bool *no_add_attrs ATTRIBUTE_UNUSED)
     593                 :             : {
     594                 :    20023824 :   gcc_assert (args
     595                 :             :               && TREE_CODE (TREE_VALUE (args)) == STRING_CST
     596                 :             :               && !TREE_CHAIN (args));
     597                 :    10011912 :   return NULL_TREE;
     598                 :             : }
     599                 :             : 
     600                 :             : /* Cribbed from c-common.cc.  */
     601                 :             : 
     602                 :             : static void
     603                 :    10547780 : def_fn_type (builtin_type def, builtin_type ret, bool var, int n, ...)
     604                 :             : {
     605                 :    10547780 :   tree t;
     606                 :    10547780 :   tree *args = XALLOCAVEC (tree, n);
     607                 :    10547780 :   va_list list;
     608                 :    10547780 :   int i;
     609                 :    10547780 :   bool err = false;
     610                 :             : 
     611                 :    10547780 :   va_start (list, n);
     612                 :    33731148 :   for (i = 0; i < n; ++i)
     613                 :             :     {
     614                 :    23183368 :       builtin_type a = (builtin_type) va_arg (list, int);
     615                 :    23183368 :       t = builtin_types[a];
     616                 :    23183368 :       if (t == error_mark_node)
     617                 :      434960 :         err = true;
     618                 :    23183368 :       args[i] = t;
     619                 :             :     }
     620                 :    10547780 :   va_end (list);
     621                 :             : 
     622                 :    10547780 :   t = builtin_types[ret];
     623                 :    10547780 :   if (err)
     624                 :      304472 :     t = error_mark_node;
     625                 :    10547780 :   if (t == error_mark_node)
     626                 :             :     ;
     627                 :    10199812 :   else if (var)
     628                 :      652440 :     t = build_varargs_function_type_array (t, n, args);
     629                 :             :   else
     630                 :     9547372 :     t = build_function_type_array (t, n, args);
     631                 :             : 
     632                 :    10547780 :   builtin_types[def] = t;
     633                 :    10547780 : }
     634                 :             : 
     635                 :             : /* Used to help initialize the builtin-types.def table.  When a type of
     636                 :             :    the correct size doesn't exist, use error_mark_node instead of NULL.
     637                 :             :    The later results in segfaults even when a decl using the type doesn't
     638                 :             :    get invoked.  */
     639                 :             : 
     640                 :             : static tree
     641                 :      108740 : builtin_type_for_size (int size, bool unsignedp)
     642                 :             : {
     643                 :      108740 :   tree type = lang_hooks.types.type_for_size (size, unsignedp);
     644                 :      108740 :   return type ? type : error_mark_node;
     645                 :             : }
     646                 :             : 
     647                 :             : /* Support for DEF_BUILTIN.  */
     648                 :             : 
     649                 :             : static void
     650                 :    30789753 : def_builtin_1 (enum built_in_function fncode, const char *name,
     651                 :             :                enum built_in_class fnclass, tree fntype, tree libtype,
     652                 :             :                bool both_p, bool fallback_p, bool nonansi_p,
     653                 :             :                tree fnattrs, bool implicit_p)
     654                 :             : {
     655                 :    30789753 :   tree decl;
     656                 :    30789753 :   const char *libname;
     657                 :             : 
     658                 :    30789753 :   if (fntype == error_mark_node)
     659                 :             :     return;
     660                 :             : 
     661                 :    29071661 :   libname = name + strlen ("__builtin_");
     662                 :    37619765 :   decl = add_builtin_function (name, fntype, fncode, fnclass,
     663                 :             :                                (fallback_p ? libname : NULL),
     664                 :             :                                fnattrs);
     665                 :             : 
     666                 :    29071661 :   if (both_p
     667                 :    10547469 :       && !flag_no_builtin
     668                 :    10547469 :       && !(nonansi_p && flag_no_nonansi_builtin))
     669                 :    10547469 :     add_builtin_function (libname, libtype, fncode, fnclass,
     670                 :             :                           NULL, fnattrs);
     671                 :             : 
     672                 :    29071661 :   set_builtin_decl (fncode, decl, implicit_p);
     673                 :             : }
     674                 :             : 
     675                 :             : 
     676                 :             : /* Initialize the attribute table for all the supported builtins.  */
     677                 :             : 
     678                 :             : static void
     679                 :       21748 : lto_init_attributes (void)
     680                 :             : {
     681                 :             :   /* Fill in the built_in_attributes array.  */
     682                 :             : #define DEF_ATTR_NULL_TREE(ENUM)                                \
     683                 :             :   built_in_attributes[(int) ENUM] = NULL_TREE;
     684                 :             : #define DEF_ATTR_INT(ENUM, VALUE)                               \
     685                 :             :   built_in_attributes[(int) ENUM] = build_int_cst (NULL_TREE, VALUE);
     686                 :             : #define DEF_ATTR_STRING(ENUM, VALUE)                            \
     687                 :             :   built_in_attributes[(int) ENUM] = build_string (strlen (VALUE), VALUE);
     688                 :             : #define DEF_ATTR_IDENT(ENUM, STRING)                            \
     689                 :             :   built_in_attributes[(int) ENUM] = get_identifier (STRING);
     690                 :             : #define DEF_ATTR_TREE_LIST(ENUM, PURPOSE, VALUE, CHAIN) \
     691                 :             :   built_in_attributes[(int) ENUM]                       \
     692                 :             :     = tree_cons (built_in_attributes[(int) PURPOSE],    \
     693                 :             :                  built_in_attributes[(int) VALUE],      \
     694                 :             :                  built_in_attributes[(int) CHAIN]);
     695                 :             : #include "builtin-attrs.def"
     696                 :             : #undef DEF_ATTR_NULL_TREE
     697                 :             : #undef DEF_ATTR_INT
     698                 :             : #undef DEF_ATTR_STRING
     699                 :             : #undef DEF_ATTR_IDENT
     700                 :             : #undef DEF_ATTR_TREE_LIST
     701                 :       21748 : }
     702                 :             : 
     703                 :             : /* Create builtin types and functions.  VA_LIST_REF_TYPE_NODE and
     704                 :             :    VA_LIST_ARG_TYPE_NODE are used in builtin-types.def.  */
     705                 :             : 
     706                 :             : static void
     707                 :       21748 : lto_define_builtins (tree va_list_ref_type_node ATTRIBUTE_UNUSED,
     708                 :             :                      tree va_list_arg_type_node ATTRIBUTE_UNUSED)
     709                 :             : {
     710                 :             : #define DEF_PRIMITIVE_TYPE(ENUM, VALUE) \
     711                 :             :   builtin_types[ENUM] = VALUE;
     712                 :             : #define DEF_FUNCTION_TYPE_0(ENUM, RETURN) \
     713                 :             :   def_fn_type (ENUM, RETURN, 0, 0);
     714                 :             : #define DEF_FUNCTION_TYPE_1(ENUM, RETURN, ARG1) \
     715                 :             :   def_fn_type (ENUM, RETURN, 0, 1, ARG1);
     716                 :             : #define DEF_FUNCTION_TYPE_2(ENUM, RETURN, ARG1, ARG2) \
     717                 :             :   def_fn_type (ENUM, RETURN, 0, 2, ARG1, ARG2);
     718                 :             : #define DEF_FUNCTION_TYPE_3(ENUM, RETURN, ARG1, ARG2, ARG3) \
     719                 :             :   def_fn_type (ENUM, RETURN, 0, 3, ARG1, ARG2, ARG3);
     720                 :             : #define DEF_FUNCTION_TYPE_4(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4) \
     721                 :             :   def_fn_type (ENUM, RETURN, 0, 4, ARG1, ARG2, ARG3, ARG4);
     722                 :             : #define DEF_FUNCTION_TYPE_5(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5) \
     723                 :             :   def_fn_type (ENUM, RETURN, 0, 5, ARG1, ARG2, ARG3, ARG4, ARG5);
     724                 :             : #define DEF_FUNCTION_TYPE_6(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
     725                 :             :                             ARG6)                                       \
     726                 :             :   def_fn_type (ENUM, RETURN, 0, 6, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6);
     727                 :             : #define DEF_FUNCTION_TYPE_7(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
     728                 :             :                             ARG6, ARG7)                                 \
     729                 :             :   def_fn_type (ENUM, RETURN, 0, 7, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, ARG7);
     730                 :             : #define DEF_FUNCTION_TYPE_8(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
     731                 :             :                             ARG6, ARG7, ARG8)                           \
     732                 :             :   def_fn_type (ENUM, RETURN, 0, 8, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6,  \
     733                 :             :                ARG7, ARG8);
     734                 :             : #define DEF_FUNCTION_TYPE_9(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
     735                 :             :                             ARG6, ARG7, ARG8, ARG9)                     \
     736                 :             :   def_fn_type (ENUM, RETURN, 0, 9, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6,  \
     737                 :             :                ARG7, ARG8, ARG9);
     738                 :             : #define DEF_FUNCTION_TYPE_10(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
     739                 :             :                              ARG6, ARG7, ARG8, ARG9, ARG10)              \
     740                 :             :   def_fn_type (ENUM, RETURN, 0, 10, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6,  \
     741                 :             :                ARG7, ARG8, ARG9, ARG10);
     742                 :             : #define DEF_FUNCTION_TYPE_11(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
     743                 :             :                              ARG6, ARG7, ARG8, ARG9, ARG10, ARG11)       \
     744                 :             :   def_fn_type (ENUM, RETURN, 0, 11, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6,  \
     745                 :             :                ARG7, ARG8, ARG9, ARG10, ARG11);
     746                 :             : #define DEF_FUNCTION_TYPE_VAR_0(ENUM, RETURN) \
     747                 :             :   def_fn_type (ENUM, RETURN, 1, 0);
     748                 :             : #define DEF_FUNCTION_TYPE_VAR_1(ENUM, RETURN, ARG1) \
     749                 :             :   def_fn_type (ENUM, RETURN, 1, 1, ARG1);
     750                 :             : #define DEF_FUNCTION_TYPE_VAR_2(ENUM, RETURN, ARG1, ARG2) \
     751                 :             :   def_fn_type (ENUM, RETURN, 1, 2, ARG1, ARG2);
     752                 :             : #define DEF_FUNCTION_TYPE_VAR_3(ENUM, RETURN, ARG1, ARG2, ARG3) \
     753                 :             :   def_fn_type (ENUM, RETURN, 1, 3, ARG1, ARG2, ARG3);
     754                 :             : #define DEF_FUNCTION_TYPE_VAR_4(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4) \
     755                 :             :   def_fn_type (ENUM, RETURN, 1, 4, ARG1, ARG2, ARG3, ARG4);
     756                 :             : #define DEF_FUNCTION_TYPE_VAR_5(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5) \
     757                 :             :   def_fn_type (ENUM, RETURN, 1, 5, ARG1, ARG2, ARG3, ARG4, ARG5);
     758                 :             : #define DEF_FUNCTION_TYPE_VAR_6(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
     759                 :             :                                  ARG6)  \
     760                 :             :   def_fn_type (ENUM, RETURN, 1, 6, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6);
     761                 :             : #define DEF_FUNCTION_TYPE_VAR_7(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
     762                 :             :                                 ARG6, ARG7)                             \
     763                 :             :   def_fn_type (ENUM, RETURN, 1, 7, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, ARG7);
     764                 :             : #define DEF_POINTER_TYPE(ENUM, TYPE) \
     765                 :             :   builtin_types[(int) ENUM] = build_pointer_type (builtin_types[(int) TYPE]);
     766                 :             : 
     767                 :             : #include "builtin-types.def"
     768                 :             : 
     769                 :             : #undef DEF_PRIMITIVE_TYPE
     770                 :             : #undef DEF_FUNCTION_TYPE_0
     771                 :             : #undef DEF_FUNCTION_TYPE_1
     772                 :             : #undef DEF_FUNCTION_TYPE_2
     773                 :             : #undef DEF_FUNCTION_TYPE_3
     774                 :             : #undef DEF_FUNCTION_TYPE_4
     775                 :             : #undef DEF_FUNCTION_TYPE_5
     776                 :             : #undef DEF_FUNCTION_TYPE_6
     777                 :             : #undef DEF_FUNCTION_TYPE_7
     778                 :             : #undef DEF_FUNCTION_TYPE_8
     779                 :             : #undef DEF_FUNCTION_TYPE_9
     780                 :             : #undef DEF_FUNCTION_TYPE_10
     781                 :             : #undef DEF_FUNCTION_TYPE_11
     782                 :             : #undef DEF_FUNCTION_TYPE_VAR_0
     783                 :             : #undef DEF_FUNCTION_TYPE_VAR_1
     784                 :             : #undef DEF_FUNCTION_TYPE_VAR_2
     785                 :             : #undef DEF_FUNCTION_TYPE_VAR_3
     786                 :             : #undef DEF_FUNCTION_TYPE_VAR_4
     787                 :             : #undef DEF_FUNCTION_TYPE_VAR_5
     788                 :             : #undef DEF_FUNCTION_TYPE_VAR_6
     789                 :             : #undef DEF_FUNCTION_TYPE_VAR_7
     790                 :             : #undef DEF_POINTER_TYPE
     791                 :       21748 :   builtin_types[(int) BT_LAST] = NULL_TREE;
     792                 :             : 
     793                 :       21748 :   lto_init_attributes ();
     794                 :             : 
     795                 :             : #define DEF_BUILTIN(ENUM, NAME, CLASS, TYPE, LIBTYPE, BOTH_P, FALLBACK_P,\
     796                 :             :                     NONANSI_P, ATTRS, IMPLICIT, COND)                   \
     797                 :             :     if (NAME && COND)                                                   \
     798                 :             :       def_builtin_1 (ENUM, NAME, CLASS, builtin_types[(int) TYPE],      \
     799                 :             :                      builtin_types[(int) LIBTYPE], BOTH_P, FALLBACK_P,  \
     800                 :             :                      NONANSI_P, built_in_attributes[(int) ATTRS], IMPLICIT);
     801                 :             : #include "builtins.def"
     802                 :       21748 : }
     803                 :             : 
     804                 :             : static GTY(()) tree registered_builtin_types;
     805                 :             : 
     806                 :             : /* Language hooks.  */
     807                 :             : 
     808                 :             : static bool
     809                 :           0 : lto_complain_wrong_lang_p (const struct cl_option *option ATTRIBUTE_UNUSED)
     810                 :             : {
     811                 :             :   /* The LTO front end inherits all the options from the first front
     812                 :             :      end that was used.  However, not all the original front end
     813                 :             :      options make sense in LTO.
     814                 :             : 
     815                 :             :      A real solution would be to filter this in collect2, but collect2
     816                 :             :      does not have access to all the option attributes to know what to
     817                 :             :      filter.  So, in lto1 we silently accept inherited flags and do
     818                 :             :      nothing about it.  */
     819                 :           0 :   return false;
     820                 :             : }
     821                 :             : 
     822                 :             : static void
     823                 :       21804 : lto_init_options_struct (struct gcc_options *opts)
     824                 :             : {
     825                 :             :   /* By default, C99-like requirements for complex multiply and divide.
     826                 :             :      ???  Until the complex method is encoded in the IL this is the only
     827                 :             :      safe choice.  This will pessimize Fortran code with LTO unless
     828                 :             :      people specify a complex method manually or use -ffast-math.  */
     829                 :       21804 :   opts->x_flag_complex_method = 2;
     830                 :       21804 :   opts->x_flag_default_complex_method = opts->x_flag_complex_method;
     831                 :       21804 : }
     832                 :             : 
     833                 :             : /* Handle command-line option SCODE.  If the option takes an argument, it is
     834                 :             :    stored in ARG, which is otherwise NULL.  VALUE holds either a numerical
     835                 :             :    argument or a binary value indicating whether the positive or negative form
     836                 :             :    of the option was supplied.  */
     837                 :             : 
     838                 :             : const char *resolution_file_name;
     839                 :             : static bool
     840                 :       87832 : lto_handle_option (size_t scode, const char *arg,
     841                 :             :                    HOST_WIDE_INT value ATTRIBUTE_UNUSED,
     842                 :             :                    int kind ATTRIBUTE_UNUSED,
     843                 :             :                    location_t loc ATTRIBUTE_UNUSED,
     844                 :             :                    const struct cl_option_handlers *handlers ATTRIBUTE_UNUSED)
     845                 :             : {
     846                 :       87832 :   enum opt_code code = (enum opt_code) scode;
     847                 :       87832 :   bool result = true;
     848                 :             : 
     849                 :       87832 :   switch (code)
     850                 :             :     {
     851                 :        8682 :     case OPT_fresolution_:
     852                 :        8682 :       resolution_file_name = arg;
     853                 :        8682 :       break;
     854                 :             : 
     855                 :           0 :     case OPT_Wabi:
     856                 :           0 :       warn_psabi = value;
     857                 :           0 :       break;
     858                 :             : 
     859                 :          78 :     case OPT_fwpa:
     860                 :          78 :       flag_wpa = value ? "" : NULL;
     861                 :          78 :       break;
     862                 :             : 
     863                 :             :     default:
     864                 :             :       break;
     865                 :             :     }
     866                 :             : 
     867                 :       87832 :   return result;
     868                 :             : }
     869                 :             : 
     870                 :             : /* Perform post-option processing.  Does additional initialization based on
     871                 :             :    command-line options.  PFILENAME is the main input filename.  Returns false
     872                 :             :    to enable subsequent back-end initialization.  */
     873                 :             : 
     874                 :             : static bool
     875                 :       21748 : lto_post_options (const char **pfilename ATTRIBUTE_UNUSED)
     876                 :             : {
     877                 :             :   /* -fltrans and -fwpa are mutually exclusive.  Check for that here.  */
     878                 :       21748 :   if (flag_wpa && flag_ltrans)
     879                 :           0 :     error ("%<-fwpa%> and %<-fltrans%> are mutually exclusive");
     880                 :             : 
     881                 :       21748 :   if (flag_ltrans)
     882                 :             :     {
     883                 :        9011 :       flag_generate_lto = 0;
     884                 :             : 
     885                 :             :       /* During LTRANS, we are not looking at the whole program, only
     886                 :             :          a subset of the whole callgraph.  */
     887                 :        9011 :       flag_whole_program = 0;
     888                 :             :     }
     889                 :             : 
     890                 :       21748 :   if (flag_wpa)
     891                 :        8654 :     flag_generate_lto = 1;
     892                 :             : 
     893                 :             :   /* Initialize the codegen flags according to the output type.  */
     894                 :       21748 :   switch (flag_lto_linker_output)
     895                 :             :     {
     896                 :          32 :     case LTO_LINKER_OUTPUT_REL: /* .o: incremental link producing LTO IL  */
     897                 :             :       /* Configure compiler same way as normal frontend would do with -flto:
     898                 :             :          this way we read the trees (declarations & types), symbol table,
     899                 :             :          optimization summaries and link them. Subsequently we output new LTO
     900                 :             :          file.  */
     901                 :          32 :       flag_lto = "";
     902                 :          32 :       flag_incremental_link = INCREMENTAL_LINK_LTO;
     903                 :          32 :       flag_whole_program = 0;
     904                 :          32 :       flag_wpa = 0;
     905                 :          32 :       flag_generate_lto = 1;
     906                 :             :       /* It would be cool to produce .o file directly, but our current
     907                 :             :          simple objects does not contain the lto symbol markers.  Go the slow
     908                 :             :          way through the asm file.  */
     909                 :          32 :       lang_hooks.lto.begin_section = lhd_begin_section;
     910                 :          32 :       lang_hooks.lto.append_data = lhd_append_data;
     911                 :          32 :       lang_hooks.lto.end_section = lhd_end_section;
     912                 :          32 :       if (flag_ltrans)
     913                 :           0 :         error ("%<-flinker-output=rel%> and %<-fltrans%> are mutually "
     914                 :             :                "exclusive");
     915                 :             :       break;
     916                 :             : 
     917                 :         250 :     case LTO_LINKER_OUTPUT_NOLTOREL: /* .o: incremental link producing asm  */
     918                 :         250 :       flag_incremental_link = INCREMENTAL_LINK_NOLTO;
     919                 :         250 :       break;
     920                 :             : 
     921                 :             :     case LTO_LINKER_OUTPUT_DYN: /* .so: PID library */
     922                 :             :       /* On some targets, like i386 it makes sense to build PIC library wihout
     923                 :             :          -fpic for performance reasons.  So no need to adjust flags.  */
     924                 :             :       break;
     925                 :             : 
     926                 :           0 :     case LTO_LINKER_OUTPUT_PIE: /* PIE binary */
     927                 :             :       /* If -fPIC or -fPIE was used at compile time, be sure that
     928                 :             :          flag_pie is 2.  */
     929                 :           0 :       flag_pie = MAX (flag_pie, flag_pic);
     930                 :           0 :       flag_pic = flag_pie;
     931                 :           0 :       flag_shlib = 0;
     932                 :           0 :       break;
     933                 :             : 
     934                 :        8514 :     case LTO_LINKER_OUTPUT_EXEC: /* Normal executable */
     935                 :        8514 :       flag_pic = 0;
     936                 :        8514 :       flag_pie = 0;
     937                 :        8514 :       flag_shlib = 0;
     938                 :        8514 :       break;
     939                 :             : 
     940                 :             :     case LTO_LINKER_OUTPUT_UNKNOWN:
     941                 :             :       break;
     942                 :             :     }
     943                 :             : 
     944                 :             :   /* Excess precision other than "fast" requires front-end
     945                 :             :      support.  */
     946                 :       21748 :   if (flag_excess_precision == EXCESS_PRECISION_DEFAULT)
     947                 :       21634 :     flag_excess_precision = EXCESS_PRECISION_FAST;
     948                 :             : 
     949                 :             :   /* When partitioning, we can tear appart STRING_CSTs uses from the same
     950                 :             :      TU into multiple partitions.  Without constant merging the constants
     951                 :             :      might not be equal at runtime.  See PR50199.  */
     952                 :       21748 :   if (!flag_merge_constants)
     953                 :        6700 :     flag_merge_constants = 1;
     954                 :             : 
     955                 :             :   /* Initialize the compiler back end.  */
     956                 :       21748 :   return false;
     957                 :             : }
     958                 :             : 
     959                 :             : /* Return a data type that has machine mode MODE.
     960                 :             :    If the mode is an integer,
     961                 :             :    then UNSIGNEDP selects between signed and unsigned types.
     962                 :             :    If the mode is a fixed-point mode,
     963                 :             :    then UNSIGNEDP selects between saturating and nonsaturating types.  */
     964                 :             : 
     965                 :             : static tree
     966                 :      284997 : lto_type_for_mode (machine_mode mode, int unsigned_p)
     967                 :             : {
     968                 :      284997 :   tree t;
     969                 :      284997 :   int i;
     970                 :             : 
     971                 :      284997 :   if (mode == TYPE_MODE (integer_type_node))
     972                 :        3332 :     return unsigned_p ? unsigned_type_node : integer_type_node;
     973                 :             : 
     974                 :      281665 :   if (mode == TYPE_MODE (signed_char_type_node))
     975                 :         864 :     return unsigned_p ? unsigned_char_type_node : signed_char_type_node;
     976                 :             : 
     977                 :      280801 :   if (mode == TYPE_MODE (short_integer_type_node))
     978                 :        2933 :     return unsigned_p ? short_unsigned_type_node : short_integer_type_node;
     979                 :             : 
     980                 :      277868 :   if (mode == TYPE_MODE (long_integer_type_node))
     981                 :      117472 :     return unsigned_p ? long_unsigned_type_node : long_integer_type_node;
     982                 :             : 
     983                 :      160396 :   if (mode == TYPE_MODE (long_long_integer_type_node))
     984                 :           0 :     return unsigned_p ? long_long_unsigned_type_node : long_long_integer_type_node;
     985                 :             : 
     986                 :      319951 :   for (i = 0; i < NUM_INT_N_ENTS; i ++)
     987                 :      160396 :     if (int_n_enabled_p[i]
     988                 :      160396 :         && mode == int_n_data[i].m)
     989                 :         841 :       return (unsigned_p ? int_n_trees[i].unsigned_type
     990                 :         841 :               : int_n_trees[i].signed_type);
     991                 :             : 
     992                 :      159555 :   if (mode == QImode)
     993                 :           0 :     return unsigned_p ? unsigned_intQI_type_node : intQI_type_node;
     994                 :             : 
     995                 :      159555 :   if (mode == HImode)
     996                 :           0 :     return unsigned_p ? unsigned_intHI_type_node : intHI_type_node;
     997                 :             : 
     998                 :      159555 :   if (mode == SImode)
     999                 :           0 :     return unsigned_p ? unsigned_intSI_type_node : intSI_type_node;
    1000                 :             : 
    1001                 :      159555 :   if (mode == DImode)
    1002                 :           0 :     return unsigned_p ? unsigned_intDI_type_node : intDI_type_node;
    1003                 :             : 
    1004                 :             : #if HOST_BITS_PER_WIDE_INT >= 64
    1005                 :      159555 :   if (mode == TYPE_MODE (intTI_type_node))
    1006                 :           0 :     return unsigned_p ? unsigned_intTI_type_node : intTI_type_node;
    1007                 :             : #endif
    1008                 :             : 
    1009                 :      159555 :   if (float16_type_node && mode == TYPE_MODE (float16_type_node))
    1010                 :         556 :     return float16_type_node;
    1011                 :             : 
    1012                 :      158999 :   if (mode == TYPE_MODE (float_type_node))
    1013                 :        2789 :     return float_type_node;
    1014                 :             : 
    1015                 :      156210 :   if (mode == TYPE_MODE (double_type_node))
    1016                 :        1042 :     return double_type_node;
    1017                 :             : 
    1018                 :      155168 :   if (mode == TYPE_MODE (long_double_type_node))
    1019                 :         548 :     return long_double_type_node;
    1020                 :             : 
    1021                 :     1232620 :   for (i = 0; i < NUM_FLOATN_NX_TYPES; i++)
    1022                 :     1079085 :     if (FLOATN_NX_TYPE_NODE (i) != NULL_TREE
    1023                 :     1079085 :         && mode == TYPE_MODE (FLOATN_NX_TYPE_NODE (i)))
    1024                 :        1085 :       return FLOATN_NX_TYPE_NODE (i);
    1025                 :             : 
    1026                 :      153535 :   if (mode == TYPE_MODE (void_type_node))
    1027                 :           0 :     return void_type_node;
    1028                 :             : 
    1029                 :      153535 :   if (mode == TYPE_MODE (build_pointer_type (char_type_node))
    1030                 :      153535 :       || mode == TYPE_MODE (build_pointer_type (integer_type_node)))
    1031                 :             :     {
    1032                 :           0 :       unsigned int precision
    1033                 :           0 :         = GET_MODE_PRECISION (as_a <scalar_int_mode> (mode));
    1034                 :           0 :       return (unsigned_p
    1035                 :           0 :               ? make_unsigned_type (precision)
    1036                 :           0 :               : make_signed_type (precision));
    1037                 :             :     }
    1038                 :             : 
    1039                 :      153535 :   if (COMPLEX_MODE_P (mode))
    1040                 :             :     {
    1041                 :      130513 :       machine_mode inner_mode;
    1042                 :      130513 :       tree inner_type;
    1043                 :             : 
    1044                 :      130513 :       if (mode == TYPE_MODE (complex_float_type_node))
    1045                 :       21772 :         return complex_float_type_node;
    1046                 :      108741 :       if (mode == TYPE_MODE (complex_double_type_node))
    1047                 :       21748 :         return complex_double_type_node;
    1048                 :       86993 :       if (mode == TYPE_MODE (complex_long_double_type_node))
    1049                 :       21748 :         return complex_long_double_type_node;
    1050                 :             : 
    1051                 :      282725 :       for (i = 0; i < NUM_FLOATN_NX_TYPES; i++)
    1052                 :      260977 :         if (COMPLEX_FLOATN_NX_TYPE_NODE (i) != NULL_TREE
    1053                 :      260977 :             && mode == TYPE_MODE (COMPLEX_FLOATN_NX_TYPE_NODE (i)))
    1054                 :       43497 :           return COMPLEX_FLOATN_NX_TYPE_NODE (i);
    1055                 :             : 
    1056                 :       21748 :       if (mode == TYPE_MODE (complex_integer_type_node) && !unsigned_p)
    1057                 :           0 :         return complex_integer_type_node;
    1058                 :             : 
    1059                 :       21748 :       inner_mode = GET_MODE_INNER (mode);
    1060                 :       21748 :       inner_type = lto_type_for_mode (inner_mode, unsigned_p);
    1061                 :       21748 :       if (inner_type != NULL_TREE)
    1062                 :       21748 :         return build_complex_type (inner_type);
    1063                 :             :     }
    1064                 :       23022 :   else if (GET_MODE_CLASS (mode) == MODE_VECTOR_BOOL
    1065                 :       23022 :            && valid_vector_subparts_p (GET_MODE_NUNITS (mode)))
    1066                 :             :     {
    1067                 :           0 :       unsigned int elem_bits = vector_element_size (GET_MODE_PRECISION (mode),
    1068                 :             :                                                     GET_MODE_NUNITS (mode));
    1069                 :           0 :       tree bool_type = build_nonstandard_boolean_type (elem_bits);
    1070                 :           0 :       return build_vector_type_for_mode (bool_type, mode);
    1071                 :             :     }
    1072                 :       22176 :   else if (VECTOR_MODE_P (mode)
    1073                 :       46044 :            && valid_vector_subparts_p (GET_MODE_NUNITS (mode)))
    1074                 :             :     {
    1075                 :         846 :       machine_mode inner_mode = GET_MODE_INNER (mode);
    1076                 :         846 :       tree inner_type = lto_type_for_mode (inner_mode, unsigned_p);
    1077                 :         846 :       if (inner_type != NULL_TREE)
    1078                 :         846 :         return build_vector_type_for_mode (inner_type, mode);
    1079                 :             :     }
    1080                 :             : 
    1081                 :       22176 :   if (dfloat32_type_node != NULL_TREE
    1082                 :       22176 :       && mode == TYPE_MODE (dfloat32_type_node))
    1083                 :         147 :     return dfloat32_type_node;
    1084                 :       22029 :   if (dfloat64_type_node != NULL_TREE
    1085                 :       22029 :       && mode == TYPE_MODE (dfloat64_type_node))
    1086                 :         123 :     return dfloat64_type_node;
    1087                 :       21906 :   if (dfloat128_type_node != NULL_TREE
    1088                 :       21906 :       && mode == TYPE_MODE (dfloat128_type_node))
    1089                 :          75 :     return dfloat128_type_node;
    1090                 :             : 
    1091                 :       21831 :   if (ALL_SCALAR_FIXED_POINT_MODE_P (mode))
    1092                 :             :     {
    1093                 :           0 :       if (mode == TYPE_MODE (short_fract_type_node))
    1094                 :           0 :         return unsigned_p ? sat_short_fract_type_node : short_fract_type_node;
    1095                 :           0 :       if (mode == TYPE_MODE (fract_type_node))
    1096                 :           0 :         return unsigned_p ? sat_fract_type_node : fract_type_node;
    1097                 :           0 :       if (mode == TYPE_MODE (long_fract_type_node))
    1098                 :           0 :         return unsigned_p ? sat_long_fract_type_node : long_fract_type_node;
    1099                 :           0 :       if (mode == TYPE_MODE (long_long_fract_type_node))
    1100                 :           0 :         return unsigned_p ? sat_long_long_fract_type_node
    1101                 :           0 :                          : long_long_fract_type_node;
    1102                 :             : 
    1103                 :           0 :       if (mode == TYPE_MODE (unsigned_short_fract_type_node))
    1104                 :           0 :         return unsigned_p ? sat_unsigned_short_fract_type_node
    1105                 :           0 :                          : unsigned_short_fract_type_node;
    1106                 :           0 :       if (mode == TYPE_MODE (unsigned_fract_type_node))
    1107                 :           0 :         return unsigned_p ? sat_unsigned_fract_type_node
    1108                 :           0 :                          : unsigned_fract_type_node;
    1109                 :           0 :       if (mode == TYPE_MODE (unsigned_long_fract_type_node))
    1110                 :           0 :         return unsigned_p ? sat_unsigned_long_fract_type_node
    1111                 :           0 :                          : unsigned_long_fract_type_node;
    1112                 :           0 :       if (mode == TYPE_MODE (unsigned_long_long_fract_type_node))
    1113                 :           0 :         return unsigned_p ? sat_unsigned_long_long_fract_type_node
    1114                 :           0 :                          : unsigned_long_long_fract_type_node;
    1115                 :             : 
    1116                 :           0 :       if (mode == TYPE_MODE (short_accum_type_node))
    1117                 :           0 :         return unsigned_p ? sat_short_accum_type_node : short_accum_type_node;
    1118                 :           0 :       if (mode == TYPE_MODE (accum_type_node))
    1119                 :           0 :         return unsigned_p ? sat_accum_type_node : accum_type_node;
    1120                 :           0 :       if (mode == TYPE_MODE (long_accum_type_node))
    1121                 :           0 :         return unsigned_p ? sat_long_accum_type_node : long_accum_type_node;
    1122                 :           0 :       if (mode == TYPE_MODE (long_long_accum_type_node))
    1123                 :           0 :         return unsigned_p ? sat_long_long_accum_type_node
    1124                 :           0 :                          : long_long_accum_type_node;
    1125                 :             : 
    1126                 :           0 :       if (mode == TYPE_MODE (unsigned_short_accum_type_node))
    1127                 :           0 :         return unsigned_p ? sat_unsigned_short_accum_type_node
    1128                 :           0 :                          : unsigned_short_accum_type_node;
    1129                 :           0 :       if (mode == TYPE_MODE (unsigned_accum_type_node))
    1130                 :           0 :         return unsigned_p ? sat_unsigned_accum_type_node
    1131                 :           0 :                          : unsigned_accum_type_node;
    1132                 :           0 :       if (mode == TYPE_MODE (unsigned_long_accum_type_node))
    1133                 :           0 :         return unsigned_p ? sat_unsigned_long_accum_type_node
    1134                 :           0 :                          : unsigned_long_accum_type_node;
    1135                 :           0 :       if (mode == TYPE_MODE (unsigned_long_long_accum_type_node))
    1136                 :           0 :         return unsigned_p ? sat_unsigned_long_long_accum_type_node
    1137                 :           0 :                          : unsigned_long_long_accum_type_node;
    1138                 :             : 
    1139                 :           0 :       if (mode == QQmode)
    1140                 :           0 :         return unsigned_p ? sat_qq_type_node : qq_type_node;
    1141                 :             :       if (mode == HQmode)
    1142                 :           0 :         return unsigned_p ? sat_hq_type_node : hq_type_node;
    1143                 :             :       if (mode == SQmode)
    1144                 :           0 :         return unsigned_p ? sat_sq_type_node : sq_type_node;
    1145                 :             :       if (mode == DQmode)
    1146                 :           0 :         return unsigned_p ? sat_dq_type_node : dq_type_node;
    1147                 :             :       if (mode == TQmode)
    1148                 :           0 :         return unsigned_p ? sat_tq_type_node : tq_type_node;
    1149                 :             : 
    1150                 :             :       if (mode == UQQmode)
    1151                 :           0 :         return unsigned_p ? sat_uqq_type_node : uqq_type_node;
    1152                 :             :       if (mode == UHQmode)
    1153                 :           0 :         return unsigned_p ? sat_uhq_type_node : uhq_type_node;
    1154                 :             :       if (mode == USQmode)
    1155                 :           0 :         return unsigned_p ? sat_usq_type_node : usq_type_node;
    1156                 :             :       if (mode == UDQmode)
    1157                 :           0 :         return unsigned_p ? sat_udq_type_node : udq_type_node;
    1158                 :             :       if (mode == UTQmode)
    1159                 :           0 :         return unsigned_p ? sat_utq_type_node : utq_type_node;
    1160                 :             : 
    1161                 :             :       if (mode == HAmode)
    1162                 :           0 :         return unsigned_p ? sat_ha_type_node : ha_type_node;
    1163                 :             :       if (mode == SAmode)
    1164                 :           0 :         return unsigned_p ? sat_sa_type_node : sa_type_node;
    1165                 :             :       if (mode == DAmode)
    1166                 :           0 :         return unsigned_p ? sat_da_type_node : da_type_node;
    1167                 :             :       if (mode == TAmode)
    1168                 :           0 :         return unsigned_p ? sat_ta_type_node : ta_type_node;
    1169                 :             : 
    1170                 :             :       if (mode == UHAmode)
    1171                 :           0 :         return unsigned_p ? sat_uha_type_node : uha_type_node;
    1172                 :             :       if (mode == USAmode)
    1173                 :           0 :         return unsigned_p ? sat_usa_type_node : usa_type_node;
    1174                 :             :       if (mode == UDAmode)
    1175                 :           0 :         return unsigned_p ? sat_uda_type_node : uda_type_node;
    1176                 :             :       if (mode == UTAmode)
    1177                 :           0 :         return unsigned_p ? sat_uta_type_node : uta_type_node;
    1178                 :             :     }
    1179                 :             : 
    1180                 :       21831 :   for (t = registered_builtin_types; t; t = TREE_CHAIN (t))
    1181                 :             :     {
    1182                 :       21831 :       tree type = TREE_VALUE (t);
    1183                 :       21831 :       if (TYPE_MODE (type) == mode
    1184                 :       21831 :           && VECTOR_TYPE_P (type) == VECTOR_MODE_P (mode)
    1185                 :       43662 :           && !!unsigned_p == !!TYPE_UNSIGNED (type))
    1186                 :       21831 :         return type;
    1187                 :             :     }
    1188                 :             :   return NULL_TREE;
    1189                 :             : }
    1190                 :             : 
    1191                 :             : /* Return true if we are in the global binding level.  */
    1192                 :             : 
    1193                 :             : static bool
    1194                 :        3326 : lto_global_bindings_p (void)
    1195                 :             : {
    1196                 :        3326 :   return cfun == NULL;
    1197                 :             : }
    1198                 :             : 
    1199                 :             : static void
    1200                 :      180880 : lto_set_decl_assembler_name (tree decl)
    1201                 :             : {
    1202                 :             :   /* This is almost the same as lhd_set_decl_assembler_name, except that
    1203                 :             :      we need to uniquify file-scope names, even if they are not
    1204                 :             :      TREE_PUBLIC, to avoid conflicts between individual files.  */
    1205                 :      180880 :   tree id;
    1206                 :             : 
    1207                 :      180880 :   if (TREE_PUBLIC (decl))
    1208                 :      175704 :     id = targetm.mangle_decl_assembler_name (decl, DECL_NAME (decl));
    1209                 :             :   else
    1210                 :             :     {
    1211                 :        5176 :       const char *name = IDENTIFIER_POINTER (DECL_NAME (decl));
    1212                 :        5176 :       char *label;
    1213                 :        5176 :       static unsigned long num;
    1214                 :             : 
    1215                 :        5176 :       ASM_FORMAT_PRIVATE_NAME (label, name, num++);
    1216                 :        5176 :       id = get_identifier (label);
    1217                 :             :     }
    1218                 :             : 
    1219                 :      180880 :   SET_DECL_ASSEMBLER_NAME (decl, id);
    1220                 :      180880 : }
    1221                 :             : 
    1222                 :             : static tree
    1223                 :           0 : lto_pushdecl (tree t ATTRIBUTE_UNUSED)
    1224                 :             : {
    1225                 :             :   /* Do nothing, since we get all information from DWARF and LTO
    1226                 :             :      sections.  */
    1227                 :           0 :   return NULL_TREE;
    1228                 :             : }
    1229                 :             : 
    1230                 :             : static tree
    1231                 :           0 : lto_getdecls (void)
    1232                 :             : {
    1233                 :             :   /* We have our own write_globals langhook, hence the getdecls
    1234                 :             :      langhook shouldn't be used, except by dbxout.cc, so we can't
    1235                 :             :      just abort here.  */
    1236                 :           0 :   return NULL_TREE;
    1237                 :             : }
    1238                 :             : 
    1239                 :             : static tree
    1240                 :   112583726 : lto_builtin_function (tree decl)
    1241                 :             : {
    1242                 :   112583726 :   return decl;
    1243                 :             : }
    1244                 :             : 
    1245                 :             : static void
    1246                 :       86992 : lto_register_builtin_type (tree type, const char *name)
    1247                 :             : {
    1248                 :       86992 :   tree decl;
    1249                 :             : 
    1250                 :       86992 :   if (!TYPE_NAME (type))
    1251                 :             :     {
    1252                 :       86992 :       decl = build_decl (UNKNOWN_LOCATION, TYPE_DECL,
    1253                 :             :                          get_identifier (name), type);
    1254                 :       86992 :       DECL_ARTIFICIAL (decl) = 1;
    1255                 :       86992 :       TYPE_NAME (type) = decl;
    1256                 :             :     }
    1257                 :             : 
    1258                 :       86992 :   registered_builtin_types = tree_cons (0, type, registered_builtin_types);
    1259                 :       86992 : }
    1260                 :             : 
    1261                 :             : /* Build nodes that would have be created by the C front-end; necessary
    1262                 :             :    for including builtin-types.def and ultimately builtins.def.  */
    1263                 :             : 
    1264                 :             : static void
    1265                 :       21748 : lto_build_c_type_nodes (void)
    1266                 :             : {
    1267                 :       21748 :   gcc_assert (void_type_node);
    1268                 :             : 
    1269                 :       21748 :   string_type_node = build_pointer_type (char_type_node);
    1270                 :       21748 :   const_string_type_node
    1271                 :       21748 :     = build_pointer_type (build_qualified_type (char_type_node, TYPE_QUAL_CONST));
    1272                 :             : 
    1273                 :       21748 :   if (strcmp (SIZE_TYPE, "unsigned int") == 0)
    1274                 :             :     {
    1275                 :           0 :       intmax_type_node = integer_type_node;
    1276                 :           0 :       uintmax_type_node = unsigned_type_node;
    1277                 :           0 :       signed_size_type_node = integer_type_node;
    1278                 :             :     }
    1279                 :       21748 :   else if (strcmp (SIZE_TYPE, "long unsigned int") == 0)
    1280                 :             :     {
    1281                 :       21748 :       intmax_type_node = long_integer_type_node;
    1282                 :       21748 :       uintmax_type_node = long_unsigned_type_node;
    1283                 :       21748 :       signed_size_type_node = long_integer_type_node;
    1284                 :             :     }
    1285                 :           0 :   else if (strcmp (SIZE_TYPE, "long long unsigned int") == 0)
    1286                 :             :     {
    1287                 :           0 :       intmax_type_node = long_long_integer_type_node;
    1288                 :           0 :       uintmax_type_node = long_long_unsigned_type_node;
    1289                 :           0 :       signed_size_type_node = long_long_integer_type_node;
    1290                 :             :     }
    1291                 :             :   else
    1292                 :             :     {
    1293                 :           0 :       int i;
    1294                 :             : 
    1295                 :           0 :       signed_size_type_node = NULL_TREE;
    1296                 :           0 :       for (i = 0; i < NUM_INT_N_ENTS; i++)
    1297                 :           0 :         if (int_n_enabled_p[i])
    1298                 :             :           {
    1299                 :           0 :             char name[50], altname[50];
    1300                 :           0 :             sprintf (name, "__int%d unsigned", int_n_data[i].bitsize);
    1301                 :           0 :             sprintf (altname, "__int%d__ unsigned", int_n_data[i].bitsize);
    1302                 :             : 
    1303                 :           0 :             if (strcmp (name, SIZE_TYPE) == 0
    1304                 :           0 :                 || strcmp (altname, SIZE_TYPE) == 0)
    1305                 :             :               {
    1306                 :           0 :                 intmax_type_node = int_n_trees[i].signed_type;
    1307                 :           0 :                 uintmax_type_node = int_n_trees[i].unsigned_type;
    1308                 :           0 :                 signed_size_type_node = int_n_trees[i].signed_type;
    1309                 :             :               }
    1310                 :             :           }
    1311                 :           0 :       if (signed_size_type_node == NULL_TREE)
    1312                 :           0 :         gcc_unreachable ();
    1313                 :             :     }
    1314                 :             : 
    1315                 :       21748 :   wint_type_node = unsigned_type_node;
    1316                 :       21748 :   pid_type_node = integer_type_node;
    1317                 :       21748 : }
    1318                 :             : 
    1319                 :             : /* Perform LTO-specific initialization.  */
    1320                 :             : 
    1321                 :             : static bool
    1322                 :       21748 : lto_init (void)
    1323                 :             : {
    1324                 :       21748 :   int i;
    1325                 :             : 
    1326                 :             :   /* Initialize LTO-specific data structures.  */
    1327                 :       21748 :   in_lto_p = true;
    1328                 :             : 
    1329                 :             :   /* We need to generate LTO if running in WPA mode.  */
    1330                 :       43496 :   flag_generate_lto = (flag_incremental_link == INCREMENTAL_LINK_LTO
    1331                 :       21748 :                        || flag_wpa != NULL);
    1332                 :             : 
    1333                 :             :   /* Create the basic integer types.  */
    1334                 :       21748 :   build_common_tree_nodes (flag_signed_char);
    1335                 :             : 
    1336                 :             :   /* The global tree for the main identifier is filled in by
    1337                 :             :      language-specific front-end initialization that is not run in the
    1338                 :             :      LTO back-end.  It appears that all languages that perform such
    1339                 :             :      initialization currently do so in the same way, so we do it here.  */
    1340                 :       21748 :   if (main_identifier_node == NULL_TREE)
    1341                 :       21748 :     main_identifier_node = get_identifier ("main");
    1342                 :             : 
    1343                 :             :   /* In the C++ front-end, fileptr_type_node is defined as a variant
    1344                 :             :      copy of ptr_type_node, rather than ptr_node itself.  The
    1345                 :             :      distinction should only be relevant to the front-end, so we
    1346                 :             :      always use the C definition here in lto1.
    1347                 :             :      Likewise for const struct tm*.  */
    1348                 :      152236 :   for (unsigned i = 0; i < ARRAY_SIZE (builtin_structptr_types); ++i)
    1349                 :             :     {
    1350                 :      130488 :       gcc_assert (builtin_structptr_types[i].node
    1351                 :             :                   == builtin_structptr_types[i].base);
    1352                 :      130488 :       gcc_assert (TYPE_MAIN_VARIANT (builtin_structptr_types[i].node)
    1353                 :             :                   == builtin_structptr_types[i].base);
    1354                 :             :     }
    1355                 :             : 
    1356                 :       21748 :   lto_build_c_type_nodes ();
    1357                 :       21748 :   gcc_assert (va_list_type_node);
    1358                 :             : 
    1359                 :       21748 :   if (TREE_CODE (va_list_type_node) == ARRAY_TYPE)
    1360                 :             :     {
    1361                 :       21748 :       tree x = build_pointer_type (TREE_TYPE (va_list_type_node));
    1362                 :       21748 :       lto_define_builtins (x, x);
    1363                 :             :     }
    1364                 :             :   else
    1365                 :             :     {
    1366                 :           0 :       lto_define_builtins (build_reference_type (va_list_type_node),
    1367                 :             :                            va_list_type_node);
    1368                 :             :     }
    1369                 :             : 
    1370                 :       21748 :   targetm.init_builtins ();
    1371                 :       21748 :   build_common_builtin_nodes ();
    1372                 :             : 
    1373                 :             :   /* Assign names to the builtin types, otherwise they'll end up
    1374                 :             :      as __unknown__ in debug info.
    1375                 :             :      ???  We simply need to stop pre-seeding the streamer cache.
    1376                 :             :      Below is modeled after from c-common.cc:c_common_nodes_and_builtins  */
    1377                 :             : #define NAME_TYPE(t,n) \
    1378                 :             :   if (t) \
    1379                 :             :     TYPE_NAME (t) = build_decl (UNKNOWN_LOCATION, TYPE_DECL, \
    1380                 :             :                                 get_identifier (n), t)
    1381                 :       21748 :   NAME_TYPE (integer_type_node, "int");
    1382                 :       21748 :   NAME_TYPE (char_type_node, "char");
    1383                 :       21748 :   NAME_TYPE (long_integer_type_node, "long int");
    1384                 :       21748 :   NAME_TYPE (unsigned_type_node, "unsigned int");
    1385                 :       21748 :   NAME_TYPE (long_unsigned_type_node, "long unsigned int");
    1386                 :       21748 :   NAME_TYPE (long_long_integer_type_node, "long long int");
    1387                 :       21748 :   NAME_TYPE (long_long_unsigned_type_node, "long long unsigned int");
    1388                 :       21748 :   NAME_TYPE (short_integer_type_node, "short int");
    1389                 :       21748 :   NAME_TYPE (short_unsigned_type_node, "short unsigned int");
    1390                 :       21748 :   if (signed_char_type_node != char_type_node)
    1391                 :       21748 :     NAME_TYPE (signed_char_type_node, "signed char");
    1392                 :       21748 :   if (unsigned_char_type_node != char_type_node)
    1393                 :       21748 :     NAME_TYPE (unsigned_char_type_node, "unsigned char");
    1394                 :       21748 :   NAME_TYPE (float_type_node, "float");
    1395                 :       21748 :   NAME_TYPE (double_type_node, "double");
    1396                 :       21748 :   NAME_TYPE (long_double_type_node, "long double");
    1397                 :       21748 :   NAME_TYPE (void_type_node, "void");
    1398                 :       21748 :   NAME_TYPE (boolean_type_node, "bool");
    1399                 :       21748 :   NAME_TYPE (complex_float_type_node, "complex float");
    1400                 :       21748 :   NAME_TYPE (complex_double_type_node, "complex double");
    1401                 :       21748 :   NAME_TYPE (complex_long_double_type_node, "complex long double");
    1402                 :       43496 :   for (i = 0; i < NUM_INT_N_ENTS; i++)
    1403                 :       21748 :     if (int_n_enabled_p[i])
    1404                 :             :       {
    1405                 :       21748 :         char name[50];
    1406                 :       21748 :         sprintf (name, "__int%d", int_n_data[i].bitsize);
    1407                 :       21748 :         NAME_TYPE (int_n_trees[i].signed_type, name);
    1408                 :             :       }
    1409                 :             : #undef NAME_TYPE
    1410                 :             : 
    1411                 :       21748 :   return true;
    1412                 :             : }
    1413                 :             : 
    1414                 :             : /* Register c++-specific dumps.  */
    1415                 :             : 
    1416                 :             : void
    1417                 :       21748 : lto_register_dumps (gcc::dump_manager *dumps)
    1418                 :             : {
    1419                 :       43496 :   lto_link_dump_id = dumps->dump_register
    1420                 :       21748 :     (".lto-link", "ipa-lto-link", "ipa-lto-link",
    1421                 :             :      DK_ipa, OPTGROUP_NONE, false);
    1422                 :       43496 :   decl_merge_dump_id = dumps->dump_register
    1423                 :       21748 :     (".lto-decl-merge", "ipa-lto-decl-merge", "ipa-lto-decl-merge",
    1424                 :             :      DK_ipa, OPTGROUP_NONE, false);
    1425                 :       43496 :   partition_dump_id = dumps->dump_register
    1426                 :       21748 :     (".lto-partition", "ipa-lto-partition", "ipa-lto-partition",
    1427                 :             :      DK_ipa, OPTGROUP_NONE, false);
    1428                 :       21748 : }
    1429                 :             : 
    1430                 :             : 
    1431                 :             : /* Initialize tree structures required by the LTO front end.  */
    1432                 :             : 
    1433                 :       21748 : static void lto_init_ts (void)
    1434                 :             : {
    1435                 :       21748 :   tree_contains_struct[NAMESPACE_DECL][TS_DECL_MINIMAL] = 1;
    1436                 :       21748 : }
    1437                 :             : 
    1438                 :             : #undef LANG_HOOKS_NAME
    1439                 :             : #define LANG_HOOKS_NAME "GNU GIMPLE"
    1440                 :             : #undef LANG_HOOKS_OPTION_LANG_MASK
    1441                 :             : #define LANG_HOOKS_OPTION_LANG_MASK lto_option_lang_mask
    1442                 :             : #undef LANG_HOOKS_COMPLAIN_WRONG_LANG_P
    1443                 :             : #define LANG_HOOKS_COMPLAIN_WRONG_LANG_P lto_complain_wrong_lang_p
    1444                 :             : #undef LANG_HOOKS_INIT_OPTIONS_STRUCT
    1445                 :             : #define LANG_HOOKS_INIT_OPTIONS_STRUCT lto_init_options_struct
    1446                 :             : #undef LANG_HOOKS_REGISTER_DUMPS
    1447                 :             : #define LANG_HOOKS_REGISTER_DUMPS lto_register_dumps
    1448                 :             : #undef LANG_HOOKS_HANDLE_OPTION
    1449                 :             : #define LANG_HOOKS_HANDLE_OPTION lto_handle_option
    1450                 :             : #undef LANG_HOOKS_POST_OPTIONS
    1451                 :             : #define LANG_HOOKS_POST_OPTIONS lto_post_options
    1452                 :             : #undef LANG_HOOKS_GET_ALIAS_SET
    1453                 :             : #define LANG_HOOKS_GET_ALIAS_SET gimple_get_alias_set
    1454                 :             : #undef LANG_HOOKS_TYPE_FOR_MODE
    1455                 :             : #define LANG_HOOKS_TYPE_FOR_MODE lto_type_for_mode
    1456                 :             : #undef LANG_HOOKS_SET_DECL_ASSEMBLER_NAME
    1457                 :             : #define LANG_HOOKS_SET_DECL_ASSEMBLER_NAME lto_set_decl_assembler_name
    1458                 :             : #undef LANG_HOOKS_GLOBAL_BINDINGS_P
    1459                 :             : #define LANG_HOOKS_GLOBAL_BINDINGS_P lto_global_bindings_p
    1460                 :             : #undef LANG_HOOKS_PUSHDECL
    1461                 :             : #define LANG_HOOKS_PUSHDECL lto_pushdecl
    1462                 :             : #undef LANG_HOOKS_GETDECLS
    1463                 :             : #define LANG_HOOKS_GETDECLS lto_getdecls
    1464                 :             : #undef LANG_HOOKS_REGISTER_BUILTIN_TYPE
    1465                 :             : #define LANG_HOOKS_REGISTER_BUILTIN_TYPE lto_register_builtin_type
    1466                 :             : #undef LANG_HOOKS_BUILTIN_FUNCTION
    1467                 :             : #define LANG_HOOKS_BUILTIN_FUNCTION lto_builtin_function
    1468                 :             : #undef LANG_HOOKS_INIT
    1469                 :             : #define LANG_HOOKS_INIT lto_init
    1470                 :             : #undef LANG_HOOKS_PARSE_FILE
    1471                 :             : #define LANG_HOOKS_PARSE_FILE lto_main
    1472                 :             : #undef LANG_HOOKS_REDUCE_BIT_FIELD_OPERATIONS
    1473                 :             : #define LANG_HOOKS_REDUCE_BIT_FIELD_OPERATIONS true
    1474                 :             : #undef LANG_HOOKS_TYPES_COMPATIBLE_P
    1475                 :             : #define LANG_HOOKS_TYPES_COMPATIBLE_P NULL
    1476                 :             : #undef LANG_HOOKS_EH_PERSONALITY
    1477                 :             : #define LANG_HOOKS_EH_PERSONALITY lto_eh_personality
    1478                 :             : 
    1479                 :             : /* Attribute hooks.  */
    1480                 :             : #undef LANG_HOOKS_ATTRIBUTE_TABLE
    1481                 :             : #define LANG_HOOKS_ATTRIBUTE_TABLE lto_attribute_table
    1482                 :             : 
    1483                 :             : #undef LANG_HOOKS_BEGIN_SECTION
    1484                 :             : #define LANG_HOOKS_BEGIN_SECTION lto_obj_begin_section
    1485                 :             : #undef LANG_HOOKS_APPEND_DATA
    1486                 :             : #define LANG_HOOKS_APPEND_DATA lto_obj_append_data
    1487                 :             : #undef LANG_HOOKS_END_SECTION
    1488                 :             : #define LANG_HOOKS_END_SECTION lto_obj_end_section
    1489                 :             : 
    1490                 :             : #undef LANG_HOOKS_INIT_TS
    1491                 :             : #define LANG_HOOKS_INIT_TS lto_init_ts
    1492                 :             : 
    1493                 :             : struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
    1494                 :             : 
    1495                 :             : /* Language hooks that are not part of lang_hooks.  */
    1496                 :             : 
    1497                 :             : tree
    1498                 :           0 : convert (tree type ATTRIBUTE_UNUSED, tree expr ATTRIBUTE_UNUSED)
    1499                 :             : {
    1500                 :           0 :   gcc_unreachable ();
    1501                 :             : }
    1502                 :             : 
    1503                 :             : /* Tree walking support.  */
    1504                 :             : 
    1505                 :             : static enum lto_tree_node_structure_enum
    1506                 :           0 : lto_tree_node_structure (union lang_tree_node *t ATTRIBUTE_UNUSED)
    1507                 :             : {
    1508                 :           0 :   return TS_LTO_GENERIC;
    1509                 :             : }
    1510                 :             : 
    1511                 :             : #include "gtype-lto.h"
    1512                 :             : #include "gt-lto-lto-lang.h"
        

Generated by: LCOV version 2.1-beta

LCOV profile is generated on x86_64 machine using following configure options: configure --disable-bootstrap --enable-coverage=opt --enable-languages=c,c++,fortran,go,jit,lto,rust,m2 --enable-host-shared. GCC test suite is run with the built compiler.