Skip to content

Implicit conversion from uint32& to uint32* should be reconsidered #39040

@AaronRobinsonMSFT

Description

@AaronRobinsonMSFT

The implicit conversion was previously performed by the JIT and during subsequent test passes it was discovered that IL stub generated depended on this behavior. The IL stub generation code issue was fixed in ddd458e and an assert was added:

// We should not be passing gc typed args to an unmanaged call.
GenTree* arg = argUse.GetNode();
if (varTypeIsGC(arg->TypeGet()))
{
assert(!"*** invalid IL: gc type passed to unmanaged call");
}

During a recent investigation of a WPF issue, dotnet/wpf#3226, it was discovered that the C++/CLI compiler also emits IL that depends on the previous behavior. The WPF issue doesn't appear related to this change, but that investigation is on going. The FontFace::GetFileZero() function exhibits this behavior in a Windows_NT.x64.Checked build.

JIT dump section:

    [ 0]  19 (0x013) ldloc.s 6
    [ 1]  21 (0x015) ldloca.s 2 // uint32& instead of uint32* defined by signature below.
    [ 2]  23 (0x017) ldc.i4.0 0
    [ 3]  24 (0x018) conv.i8
    [ 3]  25 (0x019) ldloc.s 6
    [ 4]  27 (0x01b) ldind.i8
    [ 4]  28 (0x01c) ldc.i4.s 32
    [ 5]  30 (0x01e) conv.i8
    [ 5]  31 (0x01f) add
    [ 4]  32 (0x020) ldind.i8
    [ 4]  33 (0x021) calli 11000030
lvaGrabTemp returning 10 (V10 tmp1) called for impImportIndirectCall.


STMT00004 (IL 0x013...  ???)
               [000025] -A-XG-------              *  ASG       long  
               [000024] D------N----              +--*  LCL_VAR   long   V10 tmp1         
               [000023] *--XG-------              \--*  IND       long  
               [000022] ---XG-------                 \--*  ADD       long  
               [000019] *--XG-------                    +--*  IND       long  
               [000018] ------------                    |  \--*  LCL_VAR   long   V07 loc6         
               [000021] ------------                    \--*  CAST      long <- int
               [000020] ------------                       \--*  CNS_INT   int    32

In Compiler::impImportCall: opcode is calli, kind=0, callRetType is int, structSize is 0

Inline a CALLI PINVOKE call from method MS.Internal.Text.TextInterface.FontFace:GetFileZero():MS.Internal.Text.TextInterface.FontFile:this

At this point it appears that it would be prudent to bring back this behavior. See #35026 (comment).

/cc @AndyAyersMS @BruceForstall @JulieLeeMSFT @jkotas @jeffschwMSFT

Metadata

Metadata

Assignees

Labels

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

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions