[llvm] [DSE] Mark promise of pre-split coroutine visible to caller (PR #133918)

via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 8 22:55:39 PDT 2025


================
@@ -987,9 +990,24 @@ struct DSEState {
     // Collect blocks with throwing instructions not modeled in MemorySSA and
     // alloc-like objects.
     unsigned PO = 0;
+    bool FoundPromise = !F.isPresplitCoroutine();
     for (BasicBlock *BB : post_order(&F)) {
       PostOrderNumbers[BB] = PO++;
       for (Instruction &I : *BB) {
+        auto *II = dyn_cast<IntrinsicInst>(&I);
+        if (!FoundPromise && II != nullptr) {
+          const auto ID = II->getIntrinsicID();
+          if (ID == Intrinsic::coro_begin ||
+              ID == Intrinsic::coro_begin_custom_abi) {
+            auto *AnyCoroId = cast<CoroBeginInst>(II)->getId();
+            auto *CoroId = dyn_cast_if_present<CoroIdInst>(AnyCoroId);
+            if (CoroId && isa<ConstantPointerNull>(CoroId->getRawInfo())) {
----------------
NewSigma wrote:

Done

https://github.com/llvm/llvm-project/pull/133918


More information about the llvm-commits mailing list