Skip to content

Coalescing calls to non-returning throw helpers? #9205

@stephentoub

Description

@stephentoub

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMIenhancementProduct code improvement that does NOT require public API changes/additionsoptimizationtenet-performancePerformance related issue

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions