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

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

-- 
H.J.
From 3cfe1a03878abe04a2565777a45637677d1a70f3 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <[email protected]>
Date: Thu, 13 Aug 2026 07:54:40 +0800
Subject: [PATCH] Add EDGE_PURE_SIBCALL

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

	* basic-block.h (EDGE_PURE_SIBCALL): New.
	* cfgbuild.cc (make_edges): Use EDGE_PURE_SIBCALL to make a
	sibcall edge.
	* cfgexpand.cc (expand_gimple_tailcall): Likewise.
	* cfgrtl.cc (purge_dead_edges): Assert EDGE_PURE_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..e1eac952d1d 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 pure sibcall without other control flow transfers.  */
+#define EDGE_PURE_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..37d3311be3f 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_PURE_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..d84df06a082 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_PURE_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..118fb56c38f 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_PURE_SIBCALL);
 
       return false;
     }
-- 
2.55.0

Reply via email to