[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:59:29 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:

I'm renaming it to "awailable" to avoid confusion with the overloaded "free" term.

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


More information about the llvm-commits mailing list