On Sat, Aug 15, 2026 at 6:38 AM Andrea Pinski
<[email protected]> wrote:
>
> On Fri, Aug 14, 2026 at 2:13 PM H.J. Lu <[email protected]> wrote:
> >
> > Add EDGE_PURE_SIBCALL to mark an edge which has a pure sibcall without
> > other control flow transfers.
>
> I don't like the pure part of the name, especially considered pure for
> a function that already exists.
> Maybe ONLY would be better.

Here is the v2 patch to add EDGE_ONLY_SIBCALL.

-- 
H.J.
---
Add EDGE_ONLY_SIBCALL to mark an edge which has a sibcall without other
control flow transfers.

* basic-block.h (EDGE_ONLY_SIBCALL): New.
* cfgbuild.cc (make_edges): Use EDGE_ONLY_SIBCALL to make a
sibcall edge.
* cfgexpand.cc (expand_gimple_tailcall): Likewise.
* cfgrtl.cc (purge_dead_edges): Assert EDGE_ONLY_SIBCALL.
From db066051d17b87ff59845c33a9ef3d0b9384e3f6 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <[email protected]>
Date: Thu, 13 Aug 2026 07:54:40 +0800
Subject: [PATCH v2] Add EDGE_ONLY_SIBCALL

Add EDGE_ONLY_SIBCALL to mark an edge which has a sibcall without other
control flow transfers.

	* basic-block.h (EDGE_ONLY_SIBCALL): New.
	* cfgbuild.cc (make_edges): Use EDGE_ONLY_SIBCALL to make a
	sibcall edge.
	* cfgexpand.cc (expand_gimple_tailcall): Likewise.
	* cfgrtl.cc (purge_dead_edges): Assert EDGE_ONLY_SIBCALL.

Signed-off-by: H.J. Lu <[email protected]>
---
 gcc/basic-block.h | 3 +++
 gcc/cfgbuild.cc   | 2 +-
 gcc/cfgexpand.cc  | 3 +--
 gcc/cfgrtl.cc     | 3 +--
 4 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/gcc/basic-block.h b/gcc/basic-block.h
index 08082447568..43863d84ef3 100644
--- a/gcc/basic-block.h
+++ b/gcc/basic-block.h
@@ -69,6 +69,9 @@ enum cfg_edge_flags {
 #define EDGE_COMPLEX \
   (EDGE_ABNORMAL | EDGE_ABNORMAL_CALL | EDGE_EH | EDGE_PRESERVE)
 
+/* An edge has a sibcall without other control flow transfers.  */
+#define EDGE_ONLY_SIBCALL (EDGE_ABNORMAL | EDGE_SIBCALL)
+
 struct GTY(()) rtl_bb_info {
   /* The first insn of the block is embedded into bb->il.x.  */
   /* The last insn of the block.  */
diff --git a/gcc/cfgbuild.cc b/gcc/cfgbuild.cc
index 3ed1eca694b..ee80d35cc13 100644
--- a/gcc/cfgbuild.cc
+++ b/gcc/cfgbuild.cc
@@ -315,7 +315,7 @@ make_edges (basic_block min, basic_block max, int update_p)
 	 in the first place.  */
       if (code == CALL_INSN && SIBLING_CALL_P (insn))
 	cached_make_edge (edge_cache, bb, EXIT_BLOCK_PTR_FOR_FN (cfun),
-			  EDGE_SIBCALL | EDGE_ABNORMAL);
+			  EDGE_ONLY_SIBCALL);
 
       /* If this is a CALL_INSN, then mark it as reaching the active EH
 	 handler for this CALL_INSN.  If we're handling non-call
diff --git a/gcc/cfgexpand.cc b/gcc/cfgexpand.cc
index 128cfc77684..dc2e5af6c26 100644
--- a/gcc/cfgexpand.cc
+++ b/gcc/cfgexpand.cc
@@ -4578,8 +4578,7 @@ expand_gimple_tailcall (basic_block bb, gcall *stmt, bool *can_fallthru,
       delete_insn (NEXT_INSN (last));
     }
 
-  e = make_edge (bb, EXIT_BLOCK_PTR_FOR_FN (cfun), EDGE_ABNORMAL
-		 | EDGE_SIBCALL);
+  e = make_edge (bb, EXIT_BLOCK_PTR_FOR_FN (cfun), EDGE_ONLY_SIBCALL);
   e->probability = probability;
   head_end_for_bb[bb->index].second = last;
   update_bb_for_insn_chain (head_end_for_bb[bb->index].first,
diff --git a/gcc/cfgrtl.cc b/gcc/cfgrtl.cc
index 474b84a0893..c1d92267afd 100644
--- a/gcc/cfgrtl.cc
+++ b/gcc/cfgrtl.cc
@@ -3370,8 +3370,7 @@ purge_dead_edges (basic_block bb)
 	 have created the sibcall in the first place.  Second, there
 	 should of course never have been a fallthru edge.  */
       gcc_assert (single_succ_p (bb));
-      gcc_assert (single_succ_edge (bb)->flags
-		  == (EDGE_SIBCALL | EDGE_ABNORMAL));
+      gcc_assert (single_succ_edge (bb)->flags == EDGE_ONLY_SIBCALL);
 
       return false;
     }
-- 
2.55.0

Reply via email to