Add missing clobbers to coroutine context switch assembly#329
Conversation
Add condition flag and FP status register clobbers that were missing: - x86_64: cc, st0-st7 - aarch64: nzcv - arm/thumb: cpsr - riscv64/riscv32: fflags, frm - loongarch64: fcc0-fcc7, fcsr0-fcsr3
📝 WalkthroughWalkthroughExpanded inline assembly context-switching code in src/coro/coroutines.zig to preserve additional processor and floating-point state across multiple architectures (x86_64, aarch64, arm, riscv, powerpc) by adding flags and registers to clobber sets and corresponding restoration logic. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/coro/coroutines.zig (1)
240-253: x86_64:.ccalongside.rflags— potentially redundant but harmless.Line 243 already declares
.rflags = true, and line 244 adds.cc = true. In LLVM's model,ccis the canonical condition-code clobber and typically maps to the same flags register. Having both declared shouldn't cause problems — the compiler just gets told twice that flags are toast. Thest0–st7additions are spot-on; x87 FPU state isn't saved/restored across the switch, so clobbering them is necessary.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/coro/coroutines.zig` around lines 240 - 253, Remove the redundant ".cc = true" entry from the clobber list so only ".rflags = true" declares the condition-code/flags clobber; keep the x87 st0–st7 entries as-is. Locate the clobber structure containing ".rflags = true" and ".cc = true" in src/coro/coroutines.zig and delete the ".cc = true" line to avoid the duplicate flags declaration.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/coro/coroutines.zig`:
- Around line 240-253: Remove the redundant ".cc = true" entry from the clobber
list so only ".rflags = true" declares the condition-code/flags clobber; keep
the x87 st0–st7 entries as-is. Locate the clobber structure containing ".rflags
= true" and ".cc = true" in src/coro/coroutines.zig and delete the ".cc = true"
line to avoid the duplicate flags declaration.
Summary
cc,st0-st7nzcvcpsrfflags,frmfcc0-fcc7,fcsr0-fcsr3Test plan
./check.sh --filter "Coroutine"passes (all 12 tests)