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