Repository navigation
JIT: Fix hang when a switch targets an empty-block cycle - #133686
Conversation
Share visited-block cycle detection between branch and switch optimization, and add a single-file Reflection.Emit regression for the two-block cycle. Fixes dotnet#133677 Co-authored-by: Copilot <[email protected]> Copilot-Session: 96e8fae2-5073-4d66-8b12-6b26a9a75dd2
|
Azure Pipelines: Successfully started running 5 pipeline(s). 11 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
There was a problem hiding this comment.
🟡 Changes recommended
Retain allocation-free cycle detection or reuse a scratch bit vector to avoid repeated graph-sized allocations.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Fixes a JIT hang caused by switch targets entering cycles of empty unconditional blocks.
Changes:
- Adds shared cycle detection for branch and switch optimization.
- Declares the cycle-detection helper.
- Adds a Reflection.Emit regression test.
File summaries
| File | Summary |
|---|---|
src/tests/JIT/Regression_ro_2/Runtime_133677.cs |
Adds regression coverage for the two-block cycle. |
src/coreclr/jit/fgopt.cpp |
Detects cyclic empty-block chains before redirecting edges. |
src/coreclr/jit/compiler.h |
Declares the cycle-detection helper. |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 1
- Review effort level: Lite
|
PTAL @AndyAyersMS @dotnet/jit-contrib No diffs The original repro was in C# + debug attribute, converted to IL to avoid the dependency on Roslyn optimizations. |
AndyAyersMS
left a comment
There was a problem hiding this comment.
You could probably add a C# test under the regression_d or Regression_NoOptimize_d projects, but not sure it's worth the trouble.
|
/ba-g unrelated mono failures |
Fixes dotnet#133677. `fgOptimizeSwitchBranches` can repeatedly redirect a switch edge around a cycle of empty unconditional blocks without making progress. Share `BitVec`-based cycle detection with `fgOptimizeBranchToEmptyUnconditional` and leave cyclic targets unchanged. Add `Runtime_133677.cs` to the globbed `Regression_ro_2` runner. The test emits the two-block cycle directly, so it needs neither unoptimized C# compilation nor environment overrides or a separate project. Validation: the regression hangs with the baseline JIT and passes with the fixed Checked JIT, including default tiering and `JitStress=2`. Cached `benchmarks.run.` replay has no failures, and the asm comparison has no diffs (37 contexts lack recorded data). The original [repro ](dotnet#133677 in C# + debug attribute, converted to IL to avoid the dependency on Roslyn optimizations. Co-authored-by: Copilot <[email protected]> Copilot-Session: 96e8fae2-5073-4d66-8b12-6b26a9a75dd2
Fixes #133677.
fgOptimizeSwitchBranchescan repeatedly redirect a switch edge around a cycle of empty unconditional blocks without making progress. ShareBitVec-based cycle detection withfgOptimizeBranchToEmptyUnconditionaland leave cyclic targets unchanged.Add
Runtime_133677.csto the globbedRegression_ro_2runner. The test emits the two-block cycle directly, so it needs neither unoptimized C# compilation nor environment overrides or a separate project.Validation: the regression hangs with the baseline JIT and passes with the fixed Checked JIT, including default tiering and
JitStress=2. Cachedbenchmarks.run.replay has no failures, and the asm comparison has no diffs (37 contexts lack recorded data).The original repro was in C# + debug attribute, converted to IL to avoid the dependency on Roslyn optimizations.