Come up with function_decl_type and use it in tree_function_decl.
authorMartin Liska <mliska@suse.cz>
Thu, 25 Jul 2019 09:36:19 +0000 (11:36 +0200)
committerMartin Liska <marxin@gcc.gnu.org>
Thu, 25 Jul 2019 09:36:19 +0000 (09:36 +0000)
2019-07-25  Martin Liska  <mliska@suse.cz>

* calls.c (maybe_warn_alloc_args_overflow): Use new macros
(e.g. DECL_SET_LAMBDA_FUNCTION and DECL_LAMBDA_FUNCTION_P).
* coverage.c (coverage_begin_function): Likewise.
* fold-const.c (tree_expr_nonzero_warnv_p): Likewise.
* gimple.c (gimple_call_nonnull_result_p): Likewise.
* ipa-icf.c (sem_item::compare_referenced_symbol_properties): Likewise.
(sem_item::hash_referenced_symbol_properties): Likewise.
* lto-streamer-out.c (hash_tree): Likewise.
* predict.c (expr_expected_value_1): Likewise.
* tree-inline.c (expand_call_inline): Likewise.
* tree-streamer-in.c (unpack_ts_function_decl_value_fields): Likewise.
* tree-streamer-out.c (pack_ts_function_decl_value_fields): Likewise.
* tree-core.h (enum function_decl_type): New enum.
(struct tree_function_decl): Remove operator_new_flag and lambda_function.
* tree.h (FUNCTION_DECL_DECL_TYPE): New.
(set_function_decl_type): Likewise.
(DECL_IS_OPERATOR_NEW_P): New.
(DECL_SET_IS_OPERATOR_NEW): Likewise.
(DECL_LAMBDA_FUNCTION): Likewise.
(DECL_LAMBDA_FUNCTION_P): Likewise.
(DECL_IS_OPERATOR_NEW): Remove.
(DECL_SET_LAMBDA_FUNCTION): Likewise.
2019-07-25  Martin Liska  <mliska@suse.cz>

* c-decl.c (merge_decls): Use new macros
(e.g. DECL_SET_LAMBDA_FUNCTION and DECL_LAMBDA_FUNCTION_P).
2019-07-25  Martin Liska  <mliska@suse.cz>

* decl.c (duplicate_decls): Use new macros
(e.g. DECL_SET_LAMBDA_FUNCTION and DECL_LAMBDA_FUNCTION_P).
(cxx_init_decl_processing): Likewise.
(grok_op_properties): Likewise.
* parser.c (cp_parser_lambda_declarator_opt): Likewise.
2019-07-25  Martin Liska  <mliska@suse.cz>

* lto-common.c (compare_tree_sccs_1): Use new macros
(e.g. DECL_SET_LAMBDA_FUNCTION and DECL_LAMBDA_FUNCTION_P).

From-SVN: r273790

20 files changed:
gcc/ChangeLog
gcc/c/ChangeLog
gcc/c/c-decl.c
gcc/calls.c
gcc/coverage.c
gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/cp/parser.c
gcc/fold-const.c
gcc/gimple.c
gcc/ipa-icf.c
gcc/lto-streamer-out.c
gcc/lto/ChangeLog
gcc/lto/lto-common.c
gcc/predict.c
gcc/tree-core.h
gcc/tree-inline.c
gcc/tree-streamer-in.c
gcc/tree-streamer-out.c
gcc/tree.h

index ef12578..89ba868 100644 (file)
@@ -1,3 +1,28 @@
+2019-07-25  Martin Liska  <mliska@suse.cz>
+
+       * calls.c (maybe_warn_alloc_args_overflow): Use new macros
+       (e.g. DECL_SET_LAMBDA_FUNCTION and DECL_LAMBDA_FUNCTION_P).
+       * coverage.c (coverage_begin_function): Likewise.
+       * fold-const.c (tree_expr_nonzero_warnv_p): Likewise.
+       * gimple.c (gimple_call_nonnull_result_p): Likewise.
+       * ipa-icf.c (sem_item::compare_referenced_symbol_properties): Likewise.
+       (sem_item::hash_referenced_symbol_properties): Likewise.
+       * lto-streamer-out.c (hash_tree): Likewise.
+       * predict.c (expr_expected_value_1): Likewise.
+       * tree-inline.c (expand_call_inline): Likewise.
+       * tree-streamer-in.c (unpack_ts_function_decl_value_fields): Likewise.
+       * tree-streamer-out.c (pack_ts_function_decl_value_fields): Likewise.
+       * tree-core.h (enum function_decl_type): New enum.
+       (struct tree_function_decl): Remove operator_new_flag and lambda_function.
+       * tree.h (FUNCTION_DECL_DECL_TYPE): New.
+       (set_function_decl_type): Likewise.
+       (DECL_IS_OPERATOR_NEW_P): New.
+       (DECL_SET_IS_OPERATOR_NEW): Likewise.
+       (DECL_LAMBDA_FUNCTION): Likewise.
+       (DECL_LAMBDA_FUNCTION_P): Likewise.
+       (DECL_IS_OPERATOR_NEW): Remove.
+       (DECL_SET_LAMBDA_FUNCTION): Likewise.
+
 2019-07-25  Xiong Hu Luo  <luoxhu@linux.ibm.com>
 
        * ipa-profile.c (get_most_common_single_value): Use
index 0bb1d4c..77ffbfb 100644 (file)
@@ -1,3 +1,8 @@
+2019-07-25  Martin Liska  <mliska@suse.cz>
+
+       * c-decl.c (merge_decls): Use new macros
+       (e.g. DECL_SET_LAMBDA_FUNCTION and DECL_LAMBDA_FUNCTION_P).
+
 2019-07-23  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/83518
index 0d107ad..92cc06e 100644 (file)
@@ -2639,7 +2639,8 @@ merge_decls (tree newdecl, tree olddecl, tree newtype, tree oldtype)
            |= DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (olddecl);
          TREE_THIS_VOLATILE (newdecl) |= TREE_THIS_VOLATILE (olddecl);
          DECL_IS_MALLOC (newdecl) |= DECL_IS_MALLOC (olddecl);
-         DECL_IS_OPERATOR_NEW (newdecl) |= DECL_IS_OPERATOR_NEW (olddecl);
+         if (DECL_IS_OPERATOR_NEW_P (olddecl))
+           DECL_SET_IS_OPERATOR_NEW (newdecl, true);
          TREE_READONLY (newdecl) |= TREE_READONLY (olddecl);
          DECL_PURE_P (newdecl) |= DECL_PURE_P (olddecl);
          DECL_IS_NOVOPS (newdecl) |= DECL_IS_NOVOPS (olddecl);
index 6ab138e..7507b69 100644 (file)
@@ -1395,7 +1395,7 @@ maybe_warn_alloc_args_overflow (tree fn, tree exp, tree args[2], int idx[2])
                  && fn
                  && !args[1]
                  && lang_GNU_CXX ()
-                 && DECL_IS_OPERATOR_NEW (fn)
+                 && DECL_IS_OPERATOR_NEW_P (fn)
                  && integer_all_onesp (args[i]))
                continue;
 
index 960ff7e..0d5138f 100644 (file)
@@ -643,7 +643,7 @@ coverage_begin_function (unsigned lineno_checksum, unsigned cfg_checksum)
                     (DECL_ASSEMBLER_NAME (current_function_decl)));
   gcov_write_unsigned (DECL_ARTIFICIAL (current_function_decl)
                       && !DECL_FUNCTION_VERSIONED (current_function_decl)
-                      && !DECL_LAMBDA_FUNCTION (current_function_decl));
+                      && !DECL_LAMBDA_FUNCTION_P (current_function_decl));
   gcov_write_filename (xloc.file);
   gcov_write_unsigned (xloc.line);
   gcov_write_unsigned (xloc.column);
index 925b9ef..6c08121 100644 (file)
@@ -1,3 +1,11 @@
+2019-07-25  Martin Liska  <mliska@suse.cz>
+
+       * decl.c (duplicate_decls): Use new macros
+       (e.g. DECL_SET_LAMBDA_FUNCTION and DECL_LAMBDA_FUNCTION_P).
+       (cxx_init_decl_processing): Likewise.
+       (grok_op_properties): Likewise.
+       * parser.c (cp_parser_lambda_declarator_opt): Likewise.
+
 2019-07-24  Martin Sebor  <msebor@redhat.com>
 
        PR driver/80545
index 76bb583..836bb14 100644 (file)
@@ -2293,7 +2293,8 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
          DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (newdecl)
            |= DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (olddecl);
          DECL_NO_LIMIT_STACK (newdecl) |= DECL_NO_LIMIT_STACK (olddecl);
-         DECL_IS_OPERATOR_NEW (newdecl) |= DECL_IS_OPERATOR_NEW (olddecl);
+         if (DECL_IS_OPERATOR_NEW_P (olddecl))
+           DECL_SET_IS_OPERATOR_NEW (newdecl, true);
          DECL_LOOPING_CONST_OR_PURE_P (newdecl)
            |= DECL_LOOPING_CONST_OR_PURE_P (olddecl);
 
@@ -4358,10 +4359,10 @@ cxx_init_decl_processing (void)
     deltype = build_exception_variant (deltype, empty_except_spec);
     tree opnew = push_cp_library_fn (NEW_EXPR, newtype, 0);
     DECL_IS_MALLOC (opnew) = 1;
-    DECL_IS_OPERATOR_NEW (opnew) = 1;
+    DECL_SET_IS_OPERATOR_NEW (opnew, true);
     opnew = push_cp_library_fn (VEC_NEW_EXPR, newtype, 0);
     DECL_IS_MALLOC (opnew) = 1;
-    DECL_IS_OPERATOR_NEW (opnew) = 1;
+    DECL_SET_IS_OPERATOR_NEW (opnew, true);
     push_cp_library_fn (DELETE_EXPR, deltype, ECF_NOTHROW);
     push_cp_library_fn (VEC_DELETE_EXPR, deltype, ECF_NOTHROW);
     if (flag_sized_deallocation)
@@ -4394,10 +4395,10 @@ cxx_init_decl_processing (void)
        newtype = build_exception_variant (newtype, new_eh_spec);
        opnew = push_cp_library_fn (NEW_EXPR, newtype, 0);
        DECL_IS_MALLOC (opnew) = 1;
-       DECL_IS_OPERATOR_NEW (opnew) = 1;
+       DECL_SET_IS_OPERATOR_NEW (opnew, true);
        opnew = push_cp_library_fn (VEC_NEW_EXPR, newtype, 0);
        DECL_IS_MALLOC (opnew) = 1;
-       DECL_IS_OPERATOR_NEW (opnew) = 1;
+       DECL_SET_IS_OPERATOR_NEW (opnew, true);
 
        /* operator delete (void *, align_val_t); */
        deltype = build_function_type_list (void_type_node, ptr_type_node,
@@ -13664,7 +13665,7 @@ grok_op_properties (tree decl, bool complain)
        coerce_delete_type (decl, loc);
       else
        {
-         DECL_IS_OPERATOR_NEW (decl) = 1;
+         DECL_SET_IS_OPERATOR_NEW (decl, true);
          TREE_TYPE (decl) = coerce_new_type (TREE_TYPE (decl), loc);
        }
 
index 5c379aa..ebeffdb 100644 (file)
@@ -10976,7 +10976,7 @@ cp_parser_lambda_declarator_opt (cp_parser* parser, tree lambda_expr)
        DECL_ARTIFICIAL (fco) = 1;
        /* Give the object parameter a different name.  */
        DECL_NAME (DECL_ARGUMENTS (fco)) = closure_identifier;
-       DECL_LAMBDA_FUNCTION (fco) = 1;
+       DECL_SET_LAMBDA_FUNCTION (fco, true);
       }
     if (template_param_list)
       {
index 74544bf..0a24101 100644 (file)
@@ -9250,7 +9250,7 @@ tree_expr_nonzero_warnv_p (tree t, bool *strict_overflow_p)
        tree fndecl = get_callee_fndecl (t);
        if (!fndecl) return false;
        if (flag_delete_null_pointer_checks && !flag_check_new
-           && DECL_IS_OPERATOR_NEW (fndecl)
+           && DECL_IS_OPERATOR_NEW_P (fndecl)
            && !TREE_NOTHROW (fndecl))
          return true;
        if (flag_delete_null_pointer_checks
index 63c8d5e..513bde2 100644 (file)
@@ -1583,7 +1583,7 @@ gimple_call_nonnull_result_p (gcall *call)
   if (!fndecl)
     return false;
   if (flag_delete_null_pointer_checks && !flag_check_new
-      && DECL_IS_OPERATOR_NEW (fndecl)
+      && DECL_IS_OPERATOR_NEW_P (fndecl)
       && !TREE_NOTHROW (fndecl))
     return true;
 
index 2174fb7..13e63b7 100644 (file)
@@ -344,8 +344,8 @@ sem_item::compare_referenced_symbol_properties (symtab_node *used_by,
            return return_false_with_msg ("inline attributes are different");
        }
 
-      if (DECL_IS_OPERATOR_NEW (n1->decl)
-         != DECL_IS_OPERATOR_NEW (n2->decl))
+      if (DECL_IS_OPERATOR_NEW_P (n1->decl)
+         != DECL_IS_OPERATOR_NEW_P (n2->decl))
        return return_false_with_msg ("operator new flags are different");
     }
 
@@ -409,7 +409,7 @@ sem_item::hash_referenced_symbol_properties (symtab_node *ref,
          hstate.add_flag (DECL_DISREGARD_INLINE_LIMITS (ref->decl));
          hstate.add_flag (DECL_DECLARED_INLINE_P (ref->decl));
        }
-      hstate.add_flag (DECL_IS_OPERATOR_NEW (ref->decl));
+      hstate.add_flag (DECL_IS_OPERATOR_NEW_P (ref->decl));
     }
   else if (is_a <varpool_node *> (ref))
     {
index e0881cf..47a9143 100644 (file)
@@ -1121,12 +1121,12 @@ hash_tree (struct streamer_tree_cache_d *cache, hash_map<tree, hashval_t> *map,
       hstate.add_int (DECL_BUILT_IN_CLASS (t));
       hstate.add_flag (DECL_STATIC_CONSTRUCTOR (t));
       hstate.add_flag (DECL_STATIC_DESTRUCTOR (t));
+      hstate.add_flag (FUNCTION_DECL_DECL_TYPE (t));
       hstate.add_flag (DECL_UNINLINABLE (t));
       hstate.add_flag (DECL_POSSIBLY_INLINED (t));
       hstate.add_flag (DECL_IS_NOVOPS (t));
       hstate.add_flag (DECL_IS_RETURNS_TWICE (t));
       hstate.add_flag (DECL_IS_MALLOC (t));
-      hstate.add_flag (DECL_IS_OPERATOR_NEW (t));
       hstate.add_flag (DECL_DECLARED_INLINE_P (t));
       hstate.add_flag (DECL_STATIC_CHAIN (t));
       hstate.add_flag (DECL_NO_INLINE_WARNING_P (t));
index c18b2c4..2779269 100644 (file)
@@ -1,3 +1,8 @@
+2019-07-25  Martin Liska  <mliska@suse.cz>
+
+       * lto-common.c (compare_tree_sccs_1): Use new macros
+       (e.g. DECL_SET_LAMBDA_FUNCTION and DECL_LAMBDA_FUNCTION_P).
+
 2019-07-22  Giuliano Belinassi  <giuliano.belinassi@usp.br>
 
        * lang.opt (flag_dump_callgraph): New flag.
index ef2d02a..ffa05f9 100644 (file)
@@ -1228,7 +1228,7 @@ compare_tree_sccs_1 (tree t1, tree t2, tree **map)
       compare_values (DECL_IS_NOVOPS);
       compare_values (DECL_IS_RETURNS_TWICE);
       compare_values (DECL_IS_MALLOC);
-      compare_values (DECL_IS_OPERATOR_NEW);
+      compare_values (DECL_IS_OPERATOR_NEW_P);
       compare_values (DECL_DECLARED_INLINE_P);
       compare_values (DECL_STATIC_CHAIN);
       compare_values (DECL_NO_INLINE_WARNING_P);
index 07f66aa..06138c0 100644 (file)
@@ -2450,7 +2450,7 @@ expr_expected_value_1 (tree type, tree op0, enum tree_code code,
              return NULL;
            }
 
-         if (DECL_IS_MALLOC (decl) || DECL_IS_OPERATOR_NEW (decl))
+         if (DECL_IS_MALLOC (decl) || DECL_IS_OPERATOR_NEW_P (decl))
            {
              if (predictor)
                *predictor = PRED_MALLOC_NONNULL;
index fa37a0d..372738e 100644 (file)
@@ -1820,6 +1820,17 @@ struct GTY(()) tree_decl_non_common {
   tree result;
 };
 
+/* Classify a special function declaration type.  */
+
+enum function_decl_type
+{
+  NONE,
+  OPERATOR_NEW,
+  LAMBDA_FUNCTION
+
+  /* 0 values left */
+};
+
 /* FUNCTION_DECL inherits from DECL_NON_COMMON because of the use of the
    arguments/result/saved_tree fields by front ends.   It was either inherit
    FUNCTION_DECL from non_common, or inherit non_common from FUNCTION_DECL,
@@ -1859,19 +1870,22 @@ struct GTY(()) tree_function_decl {
   unsigned novops_flag : 1;
   unsigned returns_twice_flag : 1;
   unsigned malloc_flag : 1;
-  unsigned operator_new_flag : 1;
   unsigned declared_inline_flag : 1;
   unsigned no_inline_warning_flag : 1;
 
   unsigned no_instrument_function_entry_exit : 1;
+
+  /* Align the bitfield to boundary of a byte.  */
+  ENUM_BITFIELD(function_decl_type) decl_type: 2;
+
   unsigned no_limit_stack : 1;
   unsigned disregard_inline_limits : 1;
   unsigned pure_flag : 1;
   unsigned looping_const_or_pure_flag : 1;
   unsigned has_debug_args_flag : 1;
   unsigned versioned_function : 1;
-  unsigned lambda_function: 1;
-  /* No bits left.  */
+
+  /* 0 bits left.  */
 };
 
 struct GTY(()) tree_translation_unit_decl {
index 4311309..46bbec1 100644 (file)
@@ -4895,7 +4895,7 @@ expand_call_inline (basic_block bb, gimple *stmt, copy_body_data *id)
      we may get confused if the compiler sees that the inlined new
      function returns a pointer which was just deleted.  See bug
      33407.  */
-  if (DECL_IS_OPERATOR_NEW (fn))
+  if (DECL_IS_OPERATOR_NEW_P (fn))
     {
       return_slot = NULL;
       modify_dest = NULL;
index dc8bbf8..f2880f1 100644 (file)
@@ -333,7 +333,7 @@ unpack_ts_function_decl_value_fields (struct bitpack_d *bp, tree expr)
   DECL_IS_NOVOPS (expr) = (unsigned) bp_unpack_value (bp, 1);
   DECL_IS_RETURNS_TWICE (expr) = (unsigned) bp_unpack_value (bp, 1);
   DECL_IS_MALLOC (expr) = (unsigned) bp_unpack_value (bp, 1);
-  DECL_IS_OPERATOR_NEW (expr) = (unsigned) bp_unpack_value (bp, 1);
+  DECL_SET_IS_OPERATOR_NEW (expr, (unsigned) bp_unpack_value (bp, 1));
   DECL_DECLARED_INLINE_P (expr) = (unsigned) bp_unpack_value (bp, 1);
   DECL_STATIC_CHAIN (expr) = (unsigned) bp_unpack_value (bp, 1);
   DECL_NO_INLINE_WARNING_P (expr) = (unsigned) bp_unpack_value (bp, 1);
index a83057e..7e93e6c 100644 (file)
@@ -295,7 +295,7 @@ pack_ts_function_decl_value_fields (struct bitpack_d *bp, tree expr)
   bp_pack_value (bp, DECL_IS_NOVOPS (expr), 1);
   bp_pack_value (bp, DECL_IS_RETURNS_TWICE (expr), 1);
   bp_pack_value (bp, DECL_IS_MALLOC (expr), 1);
-  bp_pack_value (bp, DECL_IS_OPERATOR_NEW (expr), 1);
+  bp_pack_value (bp, DECL_IS_OPERATOR_NEW_P (expr), 1);
   bp_pack_value (bp, DECL_DECLARED_INLINE_P (expr), 1);
   bp_pack_value (bp, DECL_STATIC_CHAIN (expr), 1);
   bp_pack_value (bp, DECL_NO_INLINE_WARNING_P (expr), 1);
index 99d021e..81c11a4 100644 (file)
@@ -2994,11 +2994,34 @@ extern void decl_fini_priority_insert (tree, priority_type);
 #define DECL_IS_MALLOC(NODE) \
   (FUNCTION_DECL_CHECK (NODE)->function_decl.malloc_flag)
 
+/* Macro for direct set and get of function_decl.decl_type.  */
+#define FUNCTION_DECL_DECL_TYPE(NODE) \
+  (NODE->function_decl.decl_type)
+
+/* Set decl_type of a DECL.  Set it to T when SET is true, or reset
+   it to NONE.  */
+
+static inline void
+set_function_decl_type (tree decl, function_decl_type t, bool set)
+{
+  if (set)
+    {
+      gcc_assert (FUNCTION_DECL_DECL_TYPE (decl) == NONE
+                 || FUNCTION_DECL_DECL_TYPE (decl) == t);
+      decl->function_decl.decl_type = t;
+    }
+  else if (FUNCTION_DECL_DECL_TYPE (decl) == t)
+    FUNCTION_DECL_DECL_TYPE (decl) = NONE;
+}
+
 /* Nonzero in a FUNCTION_DECL means this function should be treated as
    C++ operator new, meaning that it returns a pointer for which we
    should not use type based aliasing.  */
-#define DECL_IS_OPERATOR_NEW(NODE) \
-  (FUNCTION_DECL_CHECK (NODE)->function_decl.operator_new_flag)
+#define DECL_IS_OPERATOR_NEW_P(NODE) \
+  (FUNCTION_DECL_CHECK (NODE)->function_decl.decl_type == OPERATOR_NEW)
+
+#define DECL_SET_IS_OPERATOR_NEW(NODE, VAL) \
+  set_function_decl_type (FUNCTION_DECL_CHECK (NODE), OPERATOR_NEW, VAL)
 
 /* Nonzero in a FUNCTION_DECL means this function may return more
    than once.  */
@@ -3143,8 +3166,11 @@ extern vec<tree, va_gc> **decl_debug_args_insert (tree);
    (FUNCTION_DECL_CHECK (NODE)->decl_with_vis.cxx_destructor)
 
 /* In FUNCTION_DECL, this is set if this function is a lambda function.  */
-#define DECL_LAMBDA_FUNCTION(NODE) \
-  (FUNCTION_DECL_CHECK (NODE)->function_decl.lambda_function)
+#define DECL_LAMBDA_FUNCTION_P(NODE) \
+  (FUNCTION_DECL_CHECK (NODE)->function_decl.decl_type == LAMBDA_FUNCTION)
+
+#define DECL_SET_LAMBDA_FUNCTION(NODE, VAL) \
+  set_function_decl_type (FUNCTION_DECL_CHECK (NODE), LAMBDA_FUNCTION, VAL)
 
 /* In FUNCTION_DECL that represent an virtual method this is set when
    the method is final.  */