]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
cfghooks: Remove name field
authorAndrew Pinski <andrew.pinski@oss.qualcomm.com>
Sat, 9 May 2026 00:51:54 +0000 (17:51 -0700)
committerAndrew Pinski <andrew.pinski@oss.qualcomm.com>
Sat, 9 May 2026 13:32:33 +0000 (06:32 -0700)
Now we have an IR field, we can remove the name field. The
only time the name is used was for internal errors so having
this field outside of the hooks is better anyways.

Bootstrapped and tested on x86_64-linux-gnu.

gcc/ChangeLog:

* cfghooks.cc (current_ir_name): New function.
(dump_bb_for_graph): Use current_ir_name
instead of accessing the name field.
(dump_bb_as_sarif_properties): Likewise.
(redirect_edge_and_branch): Likewise.
(can_remove_branch_p): Likewise.
(redirect_edge_and_branch_force): Likewise.
(split_block_1): Likewise.
(move_block_after): Likewise.
(delete_basic_block): Likewise.
(split_edge): Likewise.
(create_basic_block_1): Likewise.
(can_merge_blocks_p): Likewise.
(predict_edge): Likewise.
(predicted_by_p): Likewise.
(merge_blocks): Likewise.
(make_forwarder_block): Likewise.
(force_nonfallthru): Likewise.
(can_duplicate_block_p): Likewise.
(duplicate_block): Likewise.
(block_ends_with_call_p): Likewise.
(block_ends_with_condjump_p): Likewise.
(flow_call_edges_add): Likewise.
* cfghooks.h (struct cfg_hooks): Remove the name
field.
* cfgrtl.cc (rtl_cfg_hooks): Update for the removal
of the name field.
(cfg_layout_rtl_cfg_hooks): Likewise.
* tree-cfg.cc (struct cfg_hooks): Likewise.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
gcc/cfghooks.cc
gcc/cfghooks.h
gcc/cfgrtl.cc
gcc/tree-cfg.cc

index 381d63c9398c24ce67f81363c999e564bf58f135..9c90c52d5d372e1bdc30cee5a0160b1840ff0574 100644 (file)
@@ -89,6 +89,23 @@ current_ir_type (void)
   return cfg_hooks->ir;
 }
 
+static const char *
+current_ir_name (void)
+{
+  enum ir_type ir = cfg_hooks->ir;
+  switch (ir)
+    {
+    case IR_GIMPLE:
+      return "gimple";
+    case IR_RTL_CFGRTL:
+      return "rtl";
+    case IR_RTL_CFGLAYOUT:
+      return "cfglayout mode";
+    default:
+      gcc_unreachable();
+    }
+}
+
 /* Verify the CFG consistency.
 
    Currently it does following: checks edge and basic block list correctness
@@ -339,7 +356,7 @@ dump_bb_for_graph (pretty_printer *pp, basic_block bb)
 {
   if (!cfg_hooks->dump_bb_for_graph)
     internal_error ("%s does not support dump_bb_for_graph",
-                   cfg_hooks->name);
+                   current_ir_name ());
   /* TODO: Add pretty printer for counter.  */
   if (bb->count.initialized_p ())
     pp_printf (pp, "COUNT:" "%" PRId64, bb->count.to_gcov_type ());
@@ -355,7 +372,7 @@ dump_bb_as_sarif_properties (diagnostics::sarif_builder *builder,
 {
   if (!cfg_hooks->dump_bb_for_graph)
     internal_error ("%s does not support dump_bb_as_sarif_properties",
-                   cfg_hooks->name);
+                   current_ir_name ());
   namespace bb_property_names = custom_sarif_properties::cfg::basic_block;
   if (bb->index == ENTRY_BLOCK)
     output_bag.set_string (bb_property_names::kind, "entry");
@@ -409,7 +426,7 @@ redirect_edge_and_branch (edge e, basic_block dest)
 
   if (!cfg_hooks->redirect_edge_and_branch)
     internal_error ("%s does not support redirect_edge_and_branch",
-                   cfg_hooks->name);
+                   current_ir_name ());
 
   ret = cfg_hooks->redirect_edge_and_branch (e, dest);
 
@@ -429,7 +446,7 @@ can_remove_branch_p (const_edge e)
 {
   if (!cfg_hooks->can_remove_branch_p)
     internal_error ("%s does not support can_remove_branch_p",
-                   cfg_hooks->name);
+                   current_ir_name ());
 
   if (EDGE_COUNT (e->src->succs) != 2)
     return false;
@@ -523,7 +540,7 @@ redirect_edge_and_branch_force (edge e, basic_block dest)
 
   if (!cfg_hooks->redirect_edge_and_branch_force)
     internal_error ("%s does not support redirect_edge_and_branch_force",
-                   cfg_hooks->name);
+                   current_ir_name ());
 
   if (current_loops != NULL)
     rescan_loop_exit (e, false, true);
@@ -560,7 +577,7 @@ split_block_1 (basic_block bb, void *i)
   edge res;
 
   if (!cfg_hooks->split_block)
-    internal_error ("%s does not support split_block", cfg_hooks->name);
+    internal_error ("%s does not support split_block", current_ir_name ());
 
   new_bb = cfg_hooks->split_block (bb, i);
   if (!new_bb)
@@ -625,7 +642,8 @@ move_block_after (basic_block bb, basic_block after)
   bool ret;
 
   if (!cfg_hooks->move_block_after)
-    internal_error ("%s does not support move_block_after", cfg_hooks->name);
+    internal_error ("%s does not support move_block_after",
+                   current_ir_name ());
 
   ret = cfg_hooks->move_block_after (bb, after);
 
@@ -638,7 +656,8 @@ void
 delete_basic_block (basic_block bb)
 {
   if (!cfg_hooks->delete_basic_block)
-    internal_error ("%s does not support delete_basic_block", cfg_hooks->name);
+    internal_error ("%s does not support delete_basic_block",
+                   current_ir_name ());
 
   cfg_hooks->delete_basic_block (bb);
 
@@ -685,7 +704,7 @@ split_edge (edge e)
   basic_block src = e->src, dest = e->dest;
 
   if (!cfg_hooks->split_edge)
-    internal_error ("%s does not support split_edge", cfg_hooks->name);
+    internal_error ("%s does not support split_edge", current_ir_name ());
 
   if (current_loops != NULL)
     rescan_loop_exit (e, false, true);
@@ -763,7 +782,8 @@ create_basic_block_1 (void *head, void *end, basic_block after)
   basic_block ret;
 
   if (!cfg_hooks->create_basic_block)
-    internal_error ("%s does not support create_basic_block", cfg_hooks->name);
+    internal_error ("%s does not support create_basic_block",
+                   current_ir_name ());
 
   ret = cfg_hooks->create_basic_block (head, end, after);
 
@@ -804,7 +824,8 @@ can_merge_blocks_p (basic_block bb1, basic_block bb2)
   bool ret;
 
   if (!cfg_hooks->can_merge_blocks_p)
-    internal_error ("%s does not support can_merge_blocks_p", cfg_hooks->name);
+    internal_error ("%s does not support can_merge_blocks_p",
+                   current_ir_name ());
 
   ret = cfg_hooks->can_merge_blocks_p (bb1, bb2);
 
@@ -815,7 +836,8 @@ void
 predict_edge (edge e, enum br_predictor predictor, int probability)
 {
   if (!cfg_hooks->predict_edge)
-    internal_error ("%s does not support predict_edge", cfg_hooks->name);
+    internal_error ("%s does not support predict_edge",
+                   current_ir_name ());
 
   cfg_hooks->predict_edge (e, predictor, probability);
 }
@@ -824,7 +846,8 @@ bool
 predicted_by_p (const_basic_block bb, enum br_predictor predictor)
 {
   if (!cfg_hooks->predict_edge)
-    internal_error ("%s does not support predicted_by_p", cfg_hooks->name);
+    internal_error ("%s does not support predicted_by_p",
+                   current_ir_name ());
 
   return cfg_hooks->predicted_by_p (bb, predictor);
 }
@@ -838,7 +861,8 @@ merge_blocks (basic_block a, basic_block b)
   edge_iterator ei;
 
   if (!cfg_hooks->merge_blocks)
-    internal_error ("%s does not support merge_blocks", cfg_hooks->name);
+    internal_error ("%s does not support merge_blocks",
+                   current_ir_name ());
 
   /* Pick the more reliable count.  If both qualities agrees, pick the larger
      one since turning mistakely hot code to cold is more harmful.  */
@@ -929,7 +953,7 @@ make_forwarder_block (basic_block bb, bool (*redirect_edge_p) (edge, void*), voi
 
   if (!cfg_hooks->make_forwarder_block)
     internal_error ("%s does not support make_forwarder_block",
-                   cfg_hooks->name);
+                   current_ir_name ());
 
   fallthru = split_block_after_labels (bb);
   dummy = fallthru->src;
@@ -1075,7 +1099,7 @@ force_nonfallthru (edge e)
 
   if (!cfg_hooks->force_nonfallthru)
     internal_error ("%s does not support force_nonfallthru",
-                   cfg_hooks->name);
+                   current_ir_name ());
 
   ret = cfg_hooks->force_nonfallthru (e);
   if (ret != NULL)
@@ -1109,7 +1133,7 @@ can_duplicate_block_p (const_basic_block bb)
 {
   if (!cfg_hooks->can_duplicate_block_p)
     internal_error ("%s does not support can_duplicate_block_p",
-                   cfg_hooks->name);
+                   current_ir_name ());
 
   if (bb == EXIT_BLOCK_PTR_FOR_FN (cfun) || bb == ENTRY_BLOCK_PTR_FOR_FN (cfun))
     return false;
@@ -1138,7 +1162,7 @@ duplicate_block (basic_block bb, edge e, basic_block after, copy_bb_data *id)
 
   if (!cfg_hooks->duplicate_block)
     internal_error ("%s does not support duplicate_block",
-                   cfg_hooks->name);
+                   current_ir_name ());
 
   if (bb->count < new_count)
     new_count = bb->count;
@@ -1212,7 +1236,8 @@ bool
 block_ends_with_call_p (basic_block bb)
 {
   if (!cfg_hooks->block_ends_with_call_p)
-    internal_error ("%s does not support block_ends_with_call_p", cfg_hooks->name);
+    internal_error ("%s does not support block_ends_with_call_p",
+                   current_ir_name ());
 
   return (cfg_hooks->block_ends_with_call_p) (bb);
 }
@@ -1224,7 +1249,7 @@ block_ends_with_condjump_p (const_basic_block bb)
 {
   if (!cfg_hooks->block_ends_with_condjump_p)
     internal_error ("%s does not support block_ends_with_condjump_p",
-                   cfg_hooks->name);
+                   current_ir_name ());
 
   return (cfg_hooks->block_ends_with_condjump_p) (bb);
 }
@@ -1242,7 +1267,7 @@ flow_call_edges_add (sbitmap blocks)
 {
   if (!cfg_hooks->flow_call_edges_add)
     internal_error ("%s does not support flow_call_edges_add",
-                   cfg_hooks->name);
+                   current_ir_name ());
 
   return (cfg_hooks->flow_call_edges_add) (blocks);
 }
index 75857f6f90dc56f103cb687996c0ddd619b57771..e9c1f30b16a4cbf1a55834e56ae1c8e94d56f72e 100644 (file)
@@ -77,8 +77,7 @@ public:
 
 struct cfg_hooks
 {
-  /* Name of the corresponding ir.  */
-  const char *name;
+  /* The ir that hooks corresponds with.  */
   enum ir_type ir;
 
   /* Debugging.  */
index 5a0b09f801e40eddee296e81dd1ecc33561e1b92..3f6c9c67a8c4ff41633c9fcc61ff0dba7fd147ef 100644 (file)
@@ -5385,7 +5385,6 @@ rtl_account_profile_record (basic_block bb, struct profile_record *record)
 
 /* Implementation of CFG manipulation for linearized RTL.  */
 struct cfg_hooks rtl_cfg_hooks = {
-  "rtl",
   IR_RTL_CFGRTL,
   rtl_verify_flow_info,
   rtl_dump_bb,
@@ -5429,7 +5428,6 @@ struct cfg_hooks rtl_cfg_hooks = {
    version of the compiler.  */
 
 struct cfg_hooks cfg_layout_rtl_cfg_hooks = {
-  "cfglayout mode",
   IR_RTL_CFGLAYOUT,
   rtl_verify_flow_info_1,
   rtl_dump_bb,
index 56a5af865386e526912b1ad4a83237040ffa323e..b9c1edc30c5612495e23c0be850cccf9926949dd 100644 (file)
@@ -9360,7 +9360,6 @@ gimple_account_profile_record (basic_block bb,
 }
 
 struct cfg_hooks gimple_cfg_hooks = {
-  "gimple",
   IR_GIMPLE,
   gimple_verify_flow_info,
   gimple_dump_bb,              /* dump_bb  */