Skip to content

[coro][NFC] Move switch basic block to beginning of coroutine #143626

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 11, 2025

Conversation

vogelsgesang
Copy link
Member

@vogelsgesang vogelsgesang commented Jun 10, 2025

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

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.
@vogelsgesang vogelsgesang requested a review from ChuanqiXu9 June 10, 2025 22:58
@vogelsgesang vogelsgesang changed the title [coro][NFC] Move switch basic block towards beginning of coroutine [coro][NFC] Move switch basic block to beginning of coroutine Jun 10, 2025
@llvmbot
Copy link
Member

llvmbot commented Jun 10, 2025

@llvm/pr-subscribers-llvm-transforms

@llvm/pr-subscribers-coroutines

Author: Adrian Vogelsgesang (vogelsgesang)

Changes

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.


Full diff: https://github.com/llvm/llvm-project/pull/143626.diff

1 Files Affected:

  • (modified) llvm/lib/Transforms/Coroutines/CoroSplit.cpp (+1)
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:

@vogelsgesang vogelsgesang merged commit 14c11e4 into llvm:main Jun 11, 2025
10 checks passed
rorth pushed a commit to rorth/llvm-project that referenced this pull request Jun 11, 2025
…43626)

This makes the code flow when reading the LLVM IR of a split coroutine a
bit more natural. It does not change anything from an end-user
perspective but makes debugging the CoroSplit pass slightly easier.
tomtor pushed a commit to tomtor/llvm-project that referenced this pull request Jun 14, 2025
…43626)

This makes the code flow when reading the LLVM IR of a split coroutine a
bit more natural. It does not change anything from an end-user
perspective but makes debugging the CoroSplit pass slightly easier.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants