Skip to content

JIT: Enable tail calls for mismatched return types (void) #111718

Open
@EgorBo

Description

@EgorBo

Given that we see nice perf improvements when JIT emits more tail calls (presumably, due to CET) it might makes sense to enable more patterns, e.g. mismatched return types with void. Example:

int Test()
{
    // some code to make it non-inlineable without NoInlining attribute
    Console.WriteLine();
    Console.WriteLine();
    Console.WriteLine();
    Console.WriteLine();
    Console.WriteLine();
    Console.WriteLine();
    return 42;
}

void Bar()
{
    Test();
}

Current codegen:

; Method Benchmarks:Bar():this (FullOpts)
G_M18344_IG01:
       sub      rsp, 40
G_M18344_IG02:
       call     [Benchmarks:Test():int:this]
       nop      
G_M18344_IG03:
       add      rsp, 40
       ret      
; Total bytes of code: 16

Expected: Test is tail-called.

cc @jakobbotsch @dotnet/jit-contrib

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions