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

Fix HFA/HVA classification #37499

Merged
merged 3 commits into from
Jun 12, 2020
Merged

Fix HFA/HVA classification #37499

merged 3 commits into from
Jun 12, 2020

Conversation

CarolEidt
Copy link
Contributor

@CarolEidt CarolEidt commented Jun 5, 2020

Fix #35144 and #35976

@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Jun 5, 2020
Copy link
Contributor

@sandreenko sandreenko left a comment

Choose a reason for hiding this comment

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

Jit/ToolBox changes look good, with one question about compFloatingPointUsed.
I like how clean it looks with DOUBLE\Vector64 separation.

src/coreclr/src/vm/fieldmarshaler.h Outdated Show resolved Hide resolved
src/coreclr/src/vm/fieldmarshaler.h Outdated Show resolved Hide resolved
// For 8-byte vectors corType will be returned as CORINFO_TYPE_DOUBLE.
result = TYP_SIMD16;
// This type may not appear elsewhere, but it will occupy a floating point register.
compFloatingPointUsed = true;
Copy link
Contributor

Choose a reason for hiding this comment

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

is it safe to drop compFloatingPointUsed = true;?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, that was a mistake

src/coreclr/src/jit/morph.cpp Outdated Show resolved Hide resolved
src/coreclr/src/jit/morph.cpp Outdated Show resolved Hide resolved
@CarolEidt
Copy link
Contributor Author

@davidwrighton - the crossgen2 tests are failing in CI, but passing on my local system. Can you advise me what I might be missing?

@CarolEidt
Copy link
Contributor Author

@dotnet/dnceng - is this a known issue? I see it on two of my PRs, and at least one other as well:

##[error].packages/microsoft.dotnet.arcade.sdk/5.0.0-beta.20280.1/tools/RepositoryValidation.proj(33,5): error : (NETCORE_ENGINEERING_TELEMETRY=Build) License file content '/Users/runner/runners/2.169.1/work/1/s/LICENSE.TXT' doesn't match the expected license '/Users/runner/runners/2.169.1/work/1/s/.packages/microsoft.dotnet.arcade.sdk/5.0.0-beta.20280.1/tools/Licenses/MIT.txt'.

@premun
Copy link
Member

premun commented Jun 9, 2020

@CarolEidt looks like folks are aware and fixed it already here: #37626

Rebase should get you going. Meanwhile we are looking into improving the process so that this doesn't happen again.

@CarolEidt
Copy link
Contributor Author

@jkoritzinsky @davidwrighton @sandreenko PTAL
@dotnet/jit-contrib

Copy link
Contributor

@sandreenko sandreenko left a comment

Choose a reason for hiding this comment

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

Jit/ToolBox changes LGTM.

@CarolEidt
Copy link
Contributor Author

ping @jkoritzinsky @davidwrighton
perhaps @jkotas could review?

CORINFO_HFA_ELEM_FLOAT,
CORINFO_HFA_ELEM_DOUBLE,
CORINFO_HFA_ELEM_VECTOR64,
CORINFO_HFA_ELEM_VECTOR128,
Copy link
Member

Choose a reason for hiding this comment

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

There aren't any architectures that have HVA for Vector256?

Copy link
Member

Choose a reason for hiding this comment

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

Looks like __vectorcall for x64 will eventually fit this bill: https://godbolt.org/z/DMX7Y2, but not for ARM32/ARM64 (which don't support Vector256<T>) nor the default calling conventions for x86 or x64 on Unix/Windows.

System V does treat a simple wrapper over __m256 as if it was directly __m256 however, not sure if that is classified as an HFA/HVA by the JIT...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Currently the runtime (JIT + VM) handles the System V ABI completely separately. HFA/HVA is ARM32/ARM64 only.

@tannergooding
Copy link
Member

The changes make sense to me. I imagine the same code paths would need to be updated when Half support is added to the vector types?

Comment on lines +1918 to +1919
CORINFO_HFA_ELEM_VECTOR64,
CORINFO_HFA_ELEM_VECTOR128,
Copy link
Member

Choose a reason for hiding this comment

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

Technically VECTOR64 and VECTOR128 are HVAs, not HFAs. For that reason I have renamed HFA to either HA or HomogenousAggregate everywhere in managed code. If we introduce and expose a new enumeration, I would prefer to name it correctly from the beginning. However, I realize there are lots of hfa usage in JIT code, so leaving it up to you.

@CarolEidt
Copy link
Contributor Author

The changes make sense to me. I imagine the same code paths would need to be updated when Half support is added to the vector types?

I confess that I haven't looked at the ABI requirements for Half, but I'm not sure why they would require a change, as (at least for now) the classification for vectors is independent of the element type.

Copy link
Member

@jkoritzinsky jkoritzinsky left a comment

Choose a reason for hiding this comment

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

VM interop code LGTM

Copy link
Member

@davidwrighton davidwrighton left a comment

Choose a reason for hiding this comment

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

As far as the change to the product goes, it looks ok, although sufficiently complex that I don't have complete confidence that I can review it to complete correctness. So I've made some suggestions of making the test more complex in ways that will cause our various automated runs to find bugs more effectively.

static class Runtime_35144
{
[MethodImpl(MethodImplOptions.NoInlining)]
static void Foo<T>(T x) { }
Copy link
Member

Choose a reason for hiding this comment

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

Could you change this test to pass an object after the T parameter? I would like it for GC Stress to cover the case where we use the calling convention processing logic of the VM to parse all of this.

Copy link
Member

Choose a reason for hiding this comment

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

In particular make the function be written as:

static void Foo<T>(T x, object o)
{
    if (o.GetType() != typeof(string)) throw new Exception();
    if (((string)o) != "SomeString") throw new Exception();
}

and call it passing a string "SomeString" as the extra parameter.

Copy link
Member

Choose a reason for hiding this comment

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

Also, if you could mark the Foo method as AggressiveOptimization so that it isn't compiled by crossgen that will also help chase down the case where crossgen compiles this different from what the normal runtime does.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@davidwrighton - Thanks for the review, and for the suggestions for improving the test!

@CarolEidt CarolEidt merged commit f7458a8 into dotnet:master Jun 12, 2020
@CarolEidt CarolEidt deleted the Fix35144 branch June 12, 2020 21:15
sandreenko pushed a commit to sandreenko/runtime that referenced this pull request Jul 7, 2020
Closes dotnet#36206, closes dotnet#36418.

The issue was fixed by dotnet#37499.
sandreenko pushed a commit that referenced this pull request Jul 8, 2020
* Reenable GitHub_26491.

Closes #13355

* Reenable crossgen2 tests failing with old retyping/

They were fixed both with and without retyping.
Closes #37883.

* Reenable HVA merge cases.

Closes #37341, closes #37880.

* Reenable GitHub_35821.

Closes #36206, closes #36418.

The issue was fixed by #37499.

* Delete extra lines that are no longer needed.

#37506 was fixed in #38241.

* delete a throwing init.
@ghost ghost locked as resolved and limited conversation to collaborators Dec 8, 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 this pull request may close these issues.

[ARM64] Incorrect HFA/HVA property calculation
8 participants