re PR fortran/57992 (Pointless packing of contiguous arrays for simply contiguous...
[gcc.git] / gcc / cgraphbuild.c
index 54eba785efa979d1d85871dcaedbbb07244bd541..97c010531bb0c360aae6d1c6e5b4daa285722f76 100644 (file)
@@ -1,5 +1,5 @@
 /* Callgraph construction.
-   Copyright (C) 2003-2015 Free Software Foundation, Inc.
+   Copyright (C) 2003-2019 Free Software Foundation, Inc.
    Contributed by Jan Hubicka
 
 This file is part of GCC.
@@ -22,25 +22,15 @@ along with GCC; see the file COPYING3.  If not see
 #include "system.h"
 #include "coretypes.h"
 #include "backend.h"
-#include "hard-reg-set.h"
 #include "tree.h"
 #include "gimple.h"
-#include "alloc-pool.h"
 #include "tree-pass.h"
 #include "cgraph.h"
-#include "alias.h"
-#include "fold-const.h"
-#include "internal-fn.h"
 #include "gimple-fold.h"
 #include "gimple-iterator.h"
 #include "gimple-walk.h"
-#include "langhooks.h"
-#include "intl.h"
 #include "ipa-utils.h"
 #include "except.h"
-#include "symbol-summary.h"
-#include "ipa-prop.h"
-#include "ipa-inline.h"
 
 /* Context of record_reference.  */
 struct record_reference_ctx
@@ -87,7 +77,7 @@ record_reference (tree *tp, int *walk_subtrees, void *data)
          ctx->varpool_node->create_reference (node, IPA_REF_ADDR);
        }
 
-      if (TREE_CODE (decl) == VAR_DECL)
+      if (VAR_P (decl))
        {
          varpool_node *vnode = varpool_node::get_create (decl);
          ctx->varpool_node->create_reference (vnode, IPA_REF_ADDR);
@@ -124,7 +114,7 @@ record_type_list (cgraph_node *node, tree list)
       if (TREE_CODE (type) == ADDR_EXPR)
        {
          type = TREE_OPERAND (type, 0);
-         if (TREE_CODE (type) == VAR_DECL)
+         if (VAR_P (type))
            {
              varpool_node *vnode = varpool_node::get_create (type);
              node->create_reference (vnode, IPA_REF_ADDR);
@@ -200,21 +190,8 @@ record_eh_tables (cgraph_node *node, function *fun)
 int
 compute_call_stmt_bb_frequency (tree decl, basic_block bb)
 {
-  int entry_freq = ENTRY_BLOCK_PTR_FOR_FN
-                    (DECL_STRUCT_FUNCTION (decl))->frequency;
-  int freq = bb->frequency;
-
-  if (profile_status_for_fn (DECL_STRUCT_FUNCTION (decl)) == PROFILE_ABSENT)
-    return CGRAPH_FREQ_BASE;
-
-  if (!entry_freq)
-    entry_freq = 1, freq++;
-
-  freq = freq * CGRAPH_FREQ_BASE / entry_freq;
-  if (freq > CGRAPH_FREQ_MAX)
-    freq = CGRAPH_FREQ_MAX;
-
-  return freq;
+  return bb->count.to_cgraph_frequency
+      (ENTRY_BLOCK_PTR_FOR_FN (DECL_STRUCT_FUNCTION (decl))->count);
 }
 
 /* Mark address taken in STMT.  */
@@ -229,7 +206,7 @@ mark_address (gimple *stmt, tree addr, tree, void *data)
       node->mark_address_taken ();
       ((symtab_node *)data)->create_reference (node, IPA_REF_ADDR, stmt);
     }
-  else if (addr && TREE_CODE (addr) == VAR_DECL
+  else if (addr && VAR_P (addr)
           && (TREE_STATIC (addr) || DECL_EXTERNAL (addr)))
     {
       varpool_node *vnode = varpool_node::get_create (addr);
@@ -254,8 +231,7 @@ mark_load (gimple *stmt, tree t, tree, void *data)
       node->mark_address_taken ();
       ((symtab_node *)data)->create_reference (node, IPA_REF_ADDR, stmt);
     }
-  else if (t && TREE_CODE (t) == VAR_DECL
-          && (TREE_STATIC (t) || DECL_EXTERNAL (t)))
+  else if (t && VAR_P (t) && (TREE_STATIC (t) || DECL_EXTERNAL (t)))
     {
       varpool_node *vnode = varpool_node::get_create (t);
 
@@ -270,8 +246,7 @@ static bool
 mark_store (gimple *stmt, tree t, tree, void *data)
 {
   t = get_base_address (t);
-  if (t && TREE_CODE (t) == VAR_DECL
-      && (TREE_STATIC (t) || DECL_EXTERNAL (t)))
+  if (t && VAR_P (t) && (TREE_STATIC (t) || DECL_EXTERNAL (t)))
     {
       varpool_node *vnode = varpool_node::get_create (t);
 
@@ -342,17 +317,15 @@ pass_build_cgraph_edges::execute (function *fun)
 
          if (gcall *call_stmt = dyn_cast <gcall *> (stmt))
            {
-             int freq = compute_call_stmt_bb_frequency (current_function_decl,
-                                                        bb);
              decl = gimple_call_fndecl (call_stmt);
              if (decl)
-               node->create_edge (cgraph_node::get_create (decl), call_stmt, bb->count, freq);
+               node->create_edge (cgraph_node::get_create (decl), call_stmt, bb->count);
              else if (gimple_call_internal_p (call_stmt))
                ;
              else
                node->create_indirect_edge (call_stmt,
                                            gimple_call_flags (call_stmt),
-                                           bb->count, freq);
+                                           bb->count);
            }
          node->record_stmt_references (stmt);
          if (gomp_parallel *omp_par_stmt = dyn_cast <gomp_parallel *> (stmt))
@@ -379,7 +352,7 @@ pass_build_cgraph_edges::execute (function *fun)
 
   /* Look for initializers of constant variables and private statics.  */
   FOR_EACH_LOCAL_DECL (fun, ix, decl)
-    if (TREE_CODE (decl) == VAR_DECL
+    if (VAR_P (decl)
        && (TREE_STATIC (decl) && !DECL_EXTERNAL (decl))
        && !DECL_HAS_VALUE_EXPR_P (decl)
        && TREE_TYPE (decl) != error_mark_node)
@@ -438,18 +411,16 @@ cgraph_edge::rebuild_edges (void)
 
          if (gcall *call_stmt = dyn_cast <gcall *> (stmt))
            {
-             int freq = compute_call_stmt_bb_frequency (current_function_decl,
-                                                        bb);
              decl = gimple_call_fndecl (call_stmt);
              if (decl)
                node->create_edge (cgraph_node::get_create (decl), call_stmt,
-                                  bb->count, freq);
+                                  bb->count);
              else if (gimple_call_internal_p (call_stmt))
                ;
              else
                node->create_indirect_edge (call_stmt,
                                            gimple_call_flags (call_stmt),
-                                           bb->count, freq);
+                                           bb->count);
            }
          node->record_stmt_references (stmt);
        }
@@ -458,11 +429,6 @@ cgraph_edge::rebuild_edges (void)
     }
   record_eh_tables (node, cfun);
   gcc_assert (!node->global.inlined_to);
-
-  if (node->instrumented_version
-      && !node->instrumentation_clone)
-    node->create_reference (node->instrumented_version, IPA_REF_CHKP, NULL);
-
   return 0;
 }
 
@@ -485,8 +451,6 @@ cgraph_edge::rebuild_references (void)
     else
       i++;
 
-  node->count = ENTRY_BLOCK_PTR_FOR_FN (cfun)->count;
-
   FOR_EACH_BB_FN (bb, cfun)
     {
       for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
@@ -495,10 +459,6 @@ cgraph_edge::rebuild_references (void)
        node->record_stmt_references (gsi_stmt (gsi));
     }
   record_eh_tables (node, cfun);
-
-  if (node->instrumented_version
-      && !node->instrumentation_clone)
-    node->create_reference (node->instrumented_version, IPA_REF_CHKP, NULL);
 }
 
 namespace {