runtime: Coalescing calls to non-returning throw helpers?
Repro:
using System;
class Program
{
public static void Main()
{
var arr = new int[20];
var s0 = new Span<int>(arr, 0, 1);
var s1 = new Span<int>(arr, 1, 1);
var s2 = new Span<int>(arr, 2, 1);
var s3 = new Span<int>(arr, 3, 1);
var s4 = new Span<int>(arr, 4, 1);
var s5 = new Span<int>(arr, 5, 1);
}
}
The generated asm includes this at the end:
G_M45847_IG05:
E84B8ECC5D call System.ThrowHelper:ThrowArgumentOutOfRangeException()
G_M45847_IG06:
E8468ECC5D call System.ThrowHelper:ThrowArgumentOutOfRangeException()
G_M45847_IG07:
E8418ECC5D call System.ThrowHelper:ThrowArgumentOutOfRangeException()
G_M45847_IG08:
E83C8ECC5D call System.ThrowHelper:ThrowArgumentOutOfRangeException()
G_M45847_IG09:
E8378ECC5D call System.ThrowHelper:ThrowArgumentOutOfRangeException()
G_M45847_IG10:
E8328ECC5D call System.ThrowHelper:ThrowArgumentOutOfRangeException()
CC int3
Can/should these be coalesced into a common call point?
category:cq theme:basic-cq skill-level:expert cost:medium
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 20 (20 by maintainers)
Commits related to this issue
- JIT: add pass to merge common throw helper calls Look for blocks with single statement noreturn calls, and try to reroute flow so there's just one block call that all predecessors target. Resolves #... — committed to AndyAyersMS/coreclr by AndyAyersMS 5 years ago
- JIT: add pass to merge common throw helper calls Look for blocks with single statement noreturn calls, and try to reroute flow so there's just one block call that all predecessors target. Resolves #... — committed to AndyAyersMS/coreclr by AndyAyersMS 5 years ago
- JIT: add pass to merge common throw helper calls (#27113) Look for blocks with single statement noreturn calls, and try to reroute flow so there's just one block call that all predecessors target. ... — committed to dotnet/coreclr by AndyAyersMS 5 years ago
Here’s a prototype SimpleThrowTailMerge that can merge many common throw helper blocks.
Jit-Diffs reports:
The size win is modest, though still perhaps worth pursuing.
throw
constructs in a method or across an inline complex.