[llvm] [coro][NFC] Move switch basic block towards beginning of coroutine (PR #143626)

Adrian Vogelsgesang via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 10 15:58:47 PDT 2025


https://github.com/vogelsgesang created https://github.com/llvm/llvm-project/pull/143626

This makes the code flow a bit more natural when reading the LLVM IR of a split coroutine. It does not change anything from an end-user perspective but makes debugging the CoroSplit pass slightly easier.

>From 340074743b121d951eae857d319081f32cd12c04 Mon Sep 17 00:00:00 2001
From: Adrian Vogelsgesang <avogelsgesang at salesforce.com>
Date: Tue, 10 Jun 2025 21:34:46 +0000
Subject: [PATCH] [coro][NFC] Move switch basic block towards beginning of
 coroutine

This makes the code flow a bit more natural when reading the LLVM IR of
a split coroutine. It does not change anything from an end-user
perspective but makes debugging the CoroSplit pass slightly easier.
---
 llvm/lib/Transforms/Coroutines/CoroSplit.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/llvm/lib/Transforms/Coroutines/CoroSplit.cpp b/llvm/lib/Transforms/Coroutines/CoroSplit.cpp
index f9a6c70fedc2d..cebe44581b061 100644
--- a/llvm/lib/Transforms/Coroutines/CoroSplit.cpp
+++ b/llvm/lib/Transforms/Coroutines/CoroSplit.cpp
@@ -703,6 +703,7 @@ void coro::BaseCloner::replaceEntryBlock() {
     auto *SwitchBB =
         cast<BasicBlock>(VMap[Shape.SwitchLowering.ResumeEntryBlock]);
     Builder.CreateBr(SwitchBB);
+    SwitchBB->moveAfter(Entry);
     break;
   }
   case coro::ABI::Async:



More information about the llvm-commits mailing list