Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

[Windows|Arm64|VarArgs] Correctly pass HFA arguments#18364

Merged
jashook merged 4 commits into
dotnet:masterfrom
jashook:handle_arm64_hfa_varargs
Jun 13, 2018
Merged

[Windows|Arm64|VarArgs] Correctly pass HFA arguments#18364
jashook merged 4 commits into
dotnet:masterfrom
jashook:handle_arm64_hfa_varargs

Conversation

@jashook
Copy link
Copy Markdown

@jashook jashook commented Jun 7, 2018

Windows arm64 VarArgs ABI requires passing using the general purpose registers. For HFA types, this would lead to bad codegen for vararg methods. Both the fixed arguments and the variable arguments are affected.

For arguments only, HFA structs need to be treated as if they are not HFAs.

@jashook jashook changed the title [Windows][Arm64][VarArgs] Correct HFA type information for arguments [Windows|Arm64|VarArgs] Correct HFA type information for arguments Jun 7, 2018
@jashook jashook changed the title [Windows|Arm64|VarArgs] Correct HFA type information for arguments [Windows|Arm64|VarArgs] Correctly pass HFA arguments Jun 7, 2018
@jashook jashook closed this Jun 7, 2018
@jashook jashook reopened this Jun 7, 2018
@jashook jashook force-pushed the handle_arm64_hfa_varargs branch from b481792 to 110fa8e Compare June 8, 2018 17:32
Copy link
Copy Markdown

@briansull briansull left a comment

Choose a reason for hiding this comment

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

Looks Good

Comment thread src/jit/compiler.cpp Outdated
#if !defined(_TARGET_UNIX_) && defined(_TARGET_ARM64_)
&& !isVarArg // Arm64 Windows VarArg methods arguments will not
// classify HFA types, they will need to be treated
// as if they are not HFA types.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

It would be nice to fix up this comment, if you can get the formatter to go along with a fix. Maybe put the comment above the && line.

Comment thread src/jit/compiler.cpp Outdated
// Structs that are pointer sized or smaller should have been handled by getPrimitiveTypeForStruct
assert(structSize > TARGET_POINTER_SIZE);
#if !defined(_TARGET_UNIX_)
if (!isVarArg)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I don't see why this is needed. It should still be the case that getPrimitiveTypeForStruct should return a primitive type for anything <= TARGET_POINTER_SIZE, right?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

You are correct, thank you for catching this I do not know what I was thinking at the time.

Comment thread src/jit/morph.cpp Outdated
//
// Arguments:
// tmpVarNum - the var num which we clone into the newly created temp var.
// bool isVarArg - is a VarArg method. Will effect HFA decision for arm64 windows
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nit: should be "affect"

Comment thread src/jit/compiler.h

void SortArgs();

void EvalArgsToTemps();
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

EvalArgs [](start = 9, length = 8)

Could you change this to be in the positive sense? Perhaps allowHfa?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Addressed

@CarolEidt
Copy link
Copy Markdown

This looks good except for some minor things and one more substantive question.
I hope that eventually we can refactor both the incoming and outgoing arg handling so that we don't have to pass the hfa-related bools around all over the place.

Copy link
Copy Markdown

@CarolEidt CarolEidt left a comment

Choose a reason for hiding this comment

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

🕐

@jashook jashook force-pushed the handle_arm64_hfa_varargs branch 4 times, most recently from 8cd6d87 to 359b0fd Compare June 9, 2018 01:06
Copy link
Copy Markdown

@CarolEidt CarolEidt left a comment

Choose a reason for hiding this comment

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

LGTM - thanks! (and sorry for the delay in reviewing)

Copy link
Copy Markdown

@briansull briansull left a comment

Choose a reason for hiding this comment

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

Looks Good

@jashook jashook force-pushed the handle_arm64_hfa_varargs branch from 359b0fd to 1116404 Compare June 12, 2018 21:21
Previously, the type would be reported as HFA and enregistered; however,
this is not correct, as arm64 varargs abi requires passing using
int registers.
@jashook jashook force-pushed the handle_arm64_hfa_varargs branch from 1116404 to 6439ed1 Compare June 12, 2018 21:26
@jashook
Copy link
Copy Markdown
Author

jashook commented Jun 12, 2018

@CarolEidt @briansull can you take another look, I have updated and rebased against master. This pulls in #18358. I have also followed Carol's approach to using fgArgEntry to store isVararg.

This removes some of the isVararg parameters passed around.

@jashook jashook closed this Jun 12, 2018
@jashook jashook reopened this Jun 12, 2018
Copy link
Copy Markdown

@CarolEidt CarolEidt left a comment

Choose a reason for hiding this comment

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

LGTM - thanks!!

Comment thread src/jit/morph.cpp
//
// Arguments:
// tmpVarNum - the var num which we clone into the newly created temp var.
// curArgTabEntry
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thanks for catching that!

@jashook jashook closed this Jun 12, 2018
@jashook jashook reopened this Jun 12, 2018
Copy link
Copy Markdown

@briansull briansull left a comment

Choose a reason for hiding this comment

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

Looks Good, with a couple of comments

gcInfo.gcMarkRegPtrVal(argReg, loadType);

if (compiler->lvaIsMultiregStruct(varDsc))
if (compiler->lvaIsMultiregStruct(varDsc, compiler->info.compIsVarArgs))
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

What is the effect of passing a true for compIsVarArgs as the second parameter?

If it simply makes this function always return false when varargs is true,
then it does not need to be a parameter.

Instead write:

if (!compiler->info.compIsVarArgs && compiler->lvaIsMultiregStruct(varDsc))

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

It will the decision for whether it is a multiregstruct for hfa cases. I believe it is necessary.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

sorry i was wrong

Comment thread src/jit/compiler.cpp Outdated
if (IsHfa(clsHnd))
#else // !ARM_SOFTFP
if (IsHfa(clsHnd)
#if !defined(_TARGET_UNIX_) && defined(_TARGET_ARM64_)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

It might be better to define

#if defined(_TARGET_ARM64_) && !defined(_TARGET_UNIX_)
#define IGNORE_HFA_FOR_VARARG

Don't we have a TARGET_WINDOWS or WIN64?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I believe there is only a WINOWS_AMD64_ABI define.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I may be missing something.

Copy link
Copy Markdown

@briansull briansull left a comment

Choose a reason for hiding this comment

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

Looks Good

@jashook
Copy link
Copy Markdown
Author

jashook commented Jun 13, 2018

@dotnet-bot test OSX10.12 x64 Checked Innerloop Build and Test

@jashook
Copy link
Copy Markdown
Author

jashook commented Jun 13, 2018

osx timed out. Arm64 has passed. OSX has passed in last change, only difference are ifdef names. Which the build passes so I do not think it is required to wait.

@jashook jashook merged commit c485d3f into dotnet:master Jun 13, 2018
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
…18364)

* Fix passing HFA of two floats to vararg methods

Previously, the type would be reported as HFA and enregistered; however,
this is not correct, as arm64 varargs abi requires passing using
int registers.

* Address linux build issue

* Apply final format patch

* Add _TARGET_WINDOWS_


Commit migrated from dotnet/coreclr@c485d3f
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants