Skip to content

JIT: TransformUnusedIndirection may create unused non-faulting loads #125203

@AndyAyersMS

Description

@AndyAyersMS

For IR like TransformUnusedIndirection

               [000077] D----------                   t77 =    LCL_ADDR  byref  V06 loc2         [+0]
N001 (  1,  1) [000000] -----+-----                    t0 =    LCL_VAR   byref  V02 arg0         u:1 (last use) $c0
                                                            /--*  t0     byref
N002 (  7,  5) [000068] nc--G+-----                   t68 = *  IND       struct
                                                            /--*  t77    byref
                                                            +--*  t68    struct
N003 ( 17, 12) [000030] sA---+-----                         *  STORE_BLK struct<System.Runtime.Intrinsics.Vector128`1, 16> (copy) (memory.copy)

Liveness (during Lower) will transform the IND to a NULLCHECK when it reaches the LCL_ADDR, but this IND is nonfaulting, and could be removed, as well as its address. Liveness will also remove the LCL_ADDR.

However (since we're transforming nodes we already processed) we've already registered V02 as live at that point so if we remove the LCL_VR we end up with an inconsistency where V02 is claimed to be live during codegen but is not live out and has no uses in the block.

Not sure how common this is, perhaps rare, but Wasm got tripped up by it because the codegen for IND (now a NULLCHECK) wanted to branch to a throw helper block, but the JIT never asked for one since, the NULLCHECK does not have GTF_EXCEPT set.

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

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions