This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RFC: support for multiple CFGs (necessary for the tree-profiling branch)


Hello,

On the tree-profiling branch we are working on an inliner that inlines
functions as flow graphs, but before we can finish implementing it, we
need to commit this patch to add support multiple control flow graphs.

This patch makes the CFG a function property.  It adds a new data
structure "struct control_flow_graph", which we hang from each function
via its "struct function" (DECL_STRUCT_FUNCTION, cfun, etc).  This also
requires a lot of mechanical changes throughout the compiler, because
suddenly the number of blocks, edges, etc. is a function property.

(We also need to put reorder_block_def (rbi) structures in GC space,
but I intend to merge those structures into basic_block_def soon, since
we always need them for the tree CFG so that having them as separate
pointers may not be very efficient anymore).

The control flow graph data structure looks like this:

+/* A structure to group all the per-function control flow graph data.  */
+struct control_flow_graph GTY(())
+{
+  /* Block pointers for the exit and entry of a function.
+     These are always the head and tail of the basic block list.  */
+  basic_block entry_block_ptr;
+  basic_block exit_block_ptr;
+
+  /* Index by basic block number, get basic block struct info.  */
+  varray_type basic_block_info;
+
+  /* Number of basic blocks in this flow graph.  */
+  int n_basic_blocks;
+
+  /* Number of edges in this flow graph.  */
+  int n_edges;
+
+  /* The first free basic block number.  */
+  int last_basic_block;
+
+  /* Mapping of labels to their associated blocks.  At present
+     only used for the tree CFG.  ??? Shouldn't need this here.  */
+  varray_type label_to_block_map;
+};
+
+#define ENTRY_BLOCK_PTR(FN)            ((FN)->cfg->entry_block_ptr)
+#define EXIT_BLOCK_PTR(FN)             ((FN)->cfg->exit_block_ptr)
+#define BASIC_BLOCK_INFO(FN)           ((FN)->cfg->basic_block_info)
+#define N_BASIC_BLOCKS(FN)             ((FN)->cfg->n_basic_blocks)
+#define N_EDGES(FN)                    ((FN)->cfg->n_edges)
+#define LAST_BASIC_BLOCK(FN)           ((FN)->cfg->last_basic_block)
+#define LABEL_TO_BLOCK_MAP(FN)         ((FN)->cfg->label_to_block_map)

As you can see, we need to replace n_basic_blocks with N_BASIC_BLOCKS(cfun)
everywhere in the compiler, and also n_edges, last_basic_block, BASIC_BLOCK,
ENTRY_BLOCK_PTR and EXIT_BLOCK_PTR.  The attached patch actually does that.

We would like to have some initial reactions about these changes.  If there
is not too much oposition, I'll commit it as-is to the tree-profiling branch
so that we can go on with the important stuff :)

Gr.
Steven

Attachment: patch.gz
Description: GNU Zip compressed data


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]