Skip to content

[RyuJIT] TailcallStress needs to check more conditions #8017

@BruceForstall

Description

@BruceForstall

When COMPlus_TailcallStress=1 is set, the JIT converts as many call/ret pairs as possible into tail call, which it treats as tail. prefixed "explicit" tail calls. It does not in this case run the legality checks that are run when checking to determine if implicit tailcall optimization can be done, specifically the code under FEATURE_TAILCALL_OPT in fgMorphCall() that rejects a potential tail call if any variable in the function has had its address taken, if there are pinned locals, or if there are struct promoted struct arguments.

This causes code such as this to fail:

    unsafe class Program
    {
        static void foo(IntPtr x)
        {
            Console.WriteLine(*(int*)x);
        }
        static void Main(string[] args)
        {
            int x = 42;
            foo((IntPtr)(&x));
        }
    }

category:correctness
theme:tail-call
skill-level:intermediate
cost:small

Metadata

Metadata

Assignees

No one assigned

    Labels

    JitStressCLR JIT issues involving JIT internal stress modesarea-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMIbug

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions