Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete GTF_INX_REFARR_LAYOUT #32647

Closed
jkotas opened this issue Feb 21, 2020 · 3 comments · Fixed by #33098
Closed

Delete GTF_INX_REFARR_LAYOUT #32647

jkotas opened this issue Feb 21, 2020 · 3 comments · Fixed by #33098
Assignees
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
Milestone

Comments

@jkotas
Copy link
Member

jkotas commented Feb 21, 2020

This flag should be no longer needed. Deleting it is causing unexpected assembly diffs that need to be investigated. More context: #32521 (comment)

@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added the untriaged New issue has not been triaged by the area owner label Feb 21, 2020
@jkotas jkotas added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Feb 21, 2020
@jkotas
Copy link
Member Author

jkotas commented Feb 22, 2020

cc @ivdiazsa

@AndyAyersMS AndyAyersMS self-assigned this Mar 2, 2020
@AndyAyersMS AndyAyersMS removed the untriaged New issue has not been triaged by the area owner label Mar 2, 2020
@AndyAyersMS
Copy link
Member

AndyAyersMS commented Mar 2, 2020

Looks like one source of collision is GTF_IND_NONFAULTING.

@AndyAyersMS AndyAyersMS added this to the 5.0 milestone Mar 2, 2020
@AndyAyersMS
Copy link
Member

When morphing GT_INDEX nodes, we were inadvertenly 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 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;

Removing GTF_INX_REFARR_LAYOUT and adding change above gives a no-diff change.

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

Once we do the more general fix we see diffs, so might as well further
clean up by removing the odd related constraint in the importer under
REDO_RETURN_NODE.

AndyAyersMS added a commit to AndyAyersMS/runtime that referenced this issue Mar 3, 2020
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.

Once we do the more general fix we see diffs, so we might as well further clean
up the related constraint in the importer found under `REDO_RETURN_NODE`.

Closes dotnet#32647.
AndyAyersMS added a commit that referenced this issue Mar 7, 2020
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.
@ghost ghost locked as resolved and limited conversation to collaborators Dec 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants