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

Set FieldSeq in CreateSpan for field handle #80622

Merged
merged 1 commit into from
Jan 14, 2023
Merged

Conversation

EgorBo
Copy link
Member

@EgorBo EgorBo commented Jan 13, 2023

Fixes this codegen:

int ConstRva()
{
    ReadOnlySpan<int> RVA = new [] { 1, 2, 3, 4, 5 };
    return RVA[3];
}

to produce "return 4".

Because previously CreateSpan intrisnsic (that Roslyn emits for this syntax) didn't properly propagate FieldSeq for the field so the corresponding VN optimization wasn't able to fold RVA[const] (it only worked for bytes where CreateSpan is not emitted).

PTAL @SingleAccretion @jakobbotsch @dotnet/jit-contrib

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Jan 13, 2023
@ghost ghost assigned EgorBo Jan 13, 2023
@ghost
Copy link

ghost commented Jan 13, 2023

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch, @kunalspathak
See info in area-owners.md if you want to be subscribed.

Issue Details

Fixes this codegen:

int ConstRva()
{
    ReadOnlySpan<int> RVA = new [] { 1, 2, 3, 4, 5 };
    return RVA[3];
}

to produce "return 4".

Because previously CreateSpan intrisnsic (that Roslyn emits for this syntax) didn't properly propagate FieldSeq for the field so the corresponding VN optimization wasn't able to fold it.

PTAL @SingleAccretion @jakobbotsch @dotnet/jit-contrib

Author: EgorBo
Assignees: EgorBo
Labels:

area-CodeGen-coreclr

Milestone: -

GenTree* pointerValue = gtNewIconHandleNode((size_t)data, GTF_ICON_CONST_PTR);
GenTree* lengthValue = gtNewIconNode(count, TYP_INT);
FieldSeq* fldSeq =
GetFieldSeqStore()->Create(fieldToken, (ssize_t)data, FieldSeq::FieldKind::SimpleStaticKnownAddress);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not "really" SimpleStaticKnownAddress in the non-runtime (aka NAOT) case, but I don't think that's a big problem as long as we don't assume this address dereferenceable in the Jit (which we don't).

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 this pull request may close these issues.

3 participants