[llvm] [Coroutines] Only rematerialize when operands are free after the suspend (PR #209195)

Christian Ulmann via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 13 22:51:07 PDT 2026


================
@@ -28,6 +32,82 @@ using namespace coro;
 // "coro-frame", which results in leaner debug spew.
 #define DEBUG_TYPE "coro-suspend-crossing"
 
+// Returns true if \p Root is available in the resume function without
+// introducing a new spill. This holds when a value is:
+// 1. A constant: Genuinely free, as it is materialized as an immediate in the
+//    resume function.
+// 2. An argument: Treated as free heuristically. An argument crossing the
+//    suspend is actually spilled, but treating it as free preserves beneficial
+//    shared-operand rematerialization
+// 3. A value that already crosses a suspend point for an independent use, i.e.,
+//    it is spilled regardless
+// 4. A materializable value all of whose operands are themselves free.
+static bool isFreeAfterSuspend(
----------------
Dinistro wrote:

A value is "free" if it costs no frame space to materialize it after a suspend point.

A value is not "free" if using it after a suspend point needs additional space in the coroutine frame. This is the case if the value itself if not materializable or if any operand of it needs to be forwarded through the frame that would otherwise not be used there.

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


More information about the llvm-commits mailing list