JIT: remove GTF_INX_REFARR_LAYOUT (#33098)
authorAndy Ayers <andya@microsoft.com>
Sat, 7 Mar 2020 18:34:05 +0000 (10:34 -0800)
committerGitHub <noreply@github.com>
Sat, 7 Mar 2020 18:34:05 +0000 (10:34 -0800)
commit5c981af975915b87c68577bbb9be098bfee203c0
tree2f29a810728cbc6c52be115e88a13e1b1fa356ff
parentef3d5d77c7642d979b86f41751a671dfacbefa82
JIT: remove GTF_INX_REFARR_LAYOUT (#33098)

When morphing `GT_INDEX` nodes, we were inadvertently also setting
`GTF_IND_NONFAULTING` for the `GT_IND` subtree for ref type arrays, because
`GTF_IND_NONFAULTING` has the same value as `GTF_INX_REFARR_LAYOUT`.

This turns out to be safe since in general there is an upstream bounds check to
cover the null check from the indexing operation, so the fact that we were
claiming the `GT_IND` can't fault is ok.

A no diff change would remove the `GTF_INX_REFARR_LAYOUT` flag and then modify
`fgMorphArrayIndex` to set `GTF_IND_NONFAULTING` for ref type arrays with bounds
checks:
```
    // If there's a bounds check, the the indir won't fault.
    if (bndsChk && (tree->gtType == TYP_REF))
    {
        tree->gtFlags |= GTF_IND_NONFAULTING;
    }

    tree->gtFlags |= GTF_EXCEPT;
```

But there's no good reason to limit the above change to ref type arrays and no
good reason to OR in `GTF_EXCEPT` when there are bounds checks.

Closes #32647.
src/coreclr/src/jit/compiler.cpp
src/coreclr/src/jit/gentree.cpp
src/coreclr/src/jit/gentree.h
src/coreclr/src/jit/importer.cpp
src/coreclr/src/jit/morph.cpp
src/coreclr/src/jit/optcse.cpp