/* Define control flow data structures for the CFG.
- Copyright (C) 1987-2014 Free Software Foundation, Inc.
+ Copyright (C) 1987-2021 Free Software Foundation, Inc.
This file is part of GCC.
#ifndef GCC_BASIC_BLOCK_H
#define GCC_BASIC_BLOCK_H
-#include "predict.h"
-#include "vec.h"
-#include "hashtab.h"
-#include "hash-set.h"
-#include "machmode.h"
-#include "tm.h"
-#include "hard-reg-set.h"
-#include "input.h"
-#include "function.h"
-#include "cfgrtl.h"
-#include "cfg.h"
-#include "cfganal.h"
-#include "lcm.h"
-#include "cfgbuild.h"
-#include "cfgcleanup.h"
-#include "dominance.h"
-
-/* Use gcov_type to hold basic block counters. Should be at least
- 64bit. Although a counter cannot be negative, we use a signed
- type, because erroneous negative counts can be generated when the
- flow graph is manipulated by various optimizations. A signed type
- makes those easy to detect. */
+#include <profile-count.h>
/* Control flow edge information. */
-struct GTY((user)) edge_def {
+class GTY((user)) edge_def {
+public:
/* The two blocks at the ends of the edge. */
basic_block src;
basic_block dest;
unsigned int dest_idx;
int flags; /* see cfg-flags.def */
- int probability; /* biased by REG_BR_PROB_BASE */
- gcov_type count; /* Expected number of executions calculated
- in profile.c */
+ profile_probability probability;
+
+ /* Return count of edge E. */
+ inline profile_count count () const;
};
/* Masks for edge.flags. */
PTR GTY ((skip (""))) aux;
/* Innermost loop containing the block. */
- struct loop *loop_father;
+ class loop *loop_father;
/* The dominance and postdominance information node. */
struct et_node * GTY ((skip (""))) dom[2];
int index;
/* Expected number of executions: calculated in profile.c. */
- gcov_type count;
-
- /* Expected frequency. Normalized to be in range 0 to BB_FREQ_MAX. */
- int frequency;
+ profile_count count;
/* The discriminator for this block. The discriminator distinguishes
among several basic blocks that share a common locus, allowing for
#define BB_COPY_PARTITION(dstbb, srcbb) \
BB_SET_PARTITION (dstbb, BB_PARTITION (srcbb))
-/* What sort of profiling information we have. */
-enum profile_status_d
-{
- PROFILE_ABSENT,
- PROFILE_GUESSED,
- PROFILE_READ,
- PROFILE_LAST /* Last value, used by profile streaming. */
-};
-
-/* A structure to group all the per-function control flow graph data.
- The x_* prefixing is necessary because otherwise references to the
- fields of this struct are interpreted as the defines for backward
- source compatibility following the definition of this struct. */
-struct GTY(()) control_flow_graph {
- /* Block pointers for the exit and entry of a function.
- These are always the head and tail of the basic block list. */
- basic_block x_entry_block_ptr;
- basic_block x_exit_block_ptr;
-
- /* Index by basic block number, get basic block struct info. */
- vec<basic_block, va_gc> *x_basic_block_info;
-
- /* Number of basic blocks in this flow graph. */
- int x_n_basic_blocks;
-
- /* Number of edges in this flow graph. */
- int x_n_edges;
-
- /* The first free basic block number. */
- int x_last_basic_block;
-
- /* UIDs for LABEL_DECLs. */
- int last_label_uid;
-
- /* Mapping of labels to their associated blocks. At present
- only used for the gimple CFG. */
- vec<basic_block, va_gc> *x_label_to_block_map;
-
- enum profile_status_d x_profile_status;
-
- /* Whether the dominators and the postdominators are available. */
- enum dom_state x_dom_computed[2];
-
- /* Number of basic blocks in the dominance tree. */
- unsigned x_n_bbs_in_dom_tree[2];
-
- /* Maximal number of entities in the single jumptable. Used to estimate
- final flowgraph size. */
- int max_jumptable_ents;
-};
-
/* Defines for accessing the fields of the CFG structure for function FN. */
#define ENTRY_BLOCK_PTR_FOR_FN(FN) ((FN)->cfg->x_entry_block_ptr)
#define EXIT_BLOCK_PTR_FOR_FN(FN) ((FN)->cfg->x_exit_block_ptr)
/* The two blocks that are always in the cfg. */
#define NUM_FIXED_BLOCKS (2)
-/* The base value for branch probability notes and edge probabilities. */
-#define REG_BR_PROB_BASE 10000
-
/* This is the value which indicates no edge is present. */
#define EDGE_INDEX_NO_EDGE -1
#define BRANCH_EDGE(bb) (EDGE_SUCC ((bb), 0)->flags & EDGE_FALLTHRU \
? EDGE_SUCC ((bb), 1) : EDGE_SUCC ((bb), 0))
-#define RDIV(X,Y) (((X) + (Y) / 2) / (Y))
/* Return expected execution frequency of the edge E. */
-#define EDGE_FREQUENCY(e) RDIV ((e)->src->frequency * (e)->probability, \
- REG_BR_PROB_BASE)
+#define EDGE_FREQUENCY(e) e->count ().to_frequency (cfun)
/* Compute a scale factor (or probability) suitable for scaling of
gcov_type values via apply_probability() and apply_scale(). */
insns. */
#define CLEANUP_CFGLAYOUT 32 /* Do cleanup in cfglayout mode. */
#define CLEANUP_CFG_CHANGED 64 /* The caller changed the CFG. */
-
-#include "cfghooks.h"
+#define CLEANUP_NO_PARTITIONING 128 /* Do not try to fix partitions. */
+#define CLEANUP_FORCE_FAST_DCE 0x100 /* Force run_fast_dce to be called
+ at least once. */
/* Return true if BB is in a transaction. */
return false;
}
+
+/* Return true when one of the predecessor edges of BB is marked with
+ EDGE_ABNORMAL_CALL or EDGE_EH. */
+
+static inline bool
+has_abnormal_call_or_eh_pred_edge_p (basic_block bb)
+{
+ edge e;
+ edge_iterator ei;
+
+ FOR_EACH_EDGE (e, ei, bb->preds)
+ if (e->flags & (EDGE_ABNORMAL_CALL | EDGE_EH))
+ return true;
+
+ return false;
+}
+
+/* Return count of edge E. */
+inline profile_count edge_def::count () const
+{
+ return src->count.apply_probability (probability);
+}
+
#endif /* GCC_BASIC_BLOCK_H */