Skip to content

Conversation

@jakobbotsch
Copy link
Member

@jakobbotsch jakobbotsch commented Feb 22, 2025

  • Remove uses of compArgSize. This value is computed by the old LclVarDsc ABI classification code and used to derive the amount of stack spaced consumed for parameters. Replace it with the value from the new ABI information instead.
  • Remove LclVarDsc::lvSize and LclVarDsc::lvArgStackSize. Generally LclVarDsc::lvExactSize is the right replacement, unless specifically the stack home size is needed, in which case the replacement is Compiler::lvaLclStackHomeSize.
  • Remove uses of LclVarDsc HFA information. This was the primary motivation for removing LclVarDsc::lvSize since it was querying HFA information.

This value is computed by the old LclVarDsc ABI classification code and
used to derive the amount of stack spaced consumed for parameters.
Replace it with this value from the new ABI information instead.
@ghost ghost added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Feb 22, 2025
@dotnet-policy-service
Copy link
Contributor

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

Comment on lines -4592 to -4605
if (isFramePointerUsed())
{
#if defined(TARGET_ARM)
// GetStackOffset() is always valid for incoming stack-arguments, even if the argument
// will become enregistered.
// On Arm compiler->compArgSize doesn't include r11 and lr sizes and hence we need to add 2*REGSIZE_BYTES
noway_assert((2 * REGSIZE_BYTES <= varDsc->GetStackOffset()) &&
(size_t(varDsc->GetStackOffset()) < compiler->compArgSize + 2 * REGSIZE_BYTES));
#else
// GetStackOffset() is always valid for incoming stack-arguments, even if the argument
// will become enregistered.
noway_assert((0 < varDsc->GetStackOffset()) && (size_t(varDsc->GetStackOffset()) < compiler->compArgSize));
#endif
}
Copy link
Member Author

Choose a reason for hiding this comment

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

We could replace compArgSize here as well, but the assert did not look useful to me.

@jakobbotsch jakobbotsch changed the title JIT: Remove uses of compArgSize JIT: Remove uses of old ABI information Feb 22, 2025
Comment on lines 225 to 227
GUID expected = JITEEVersionIdentifier;
GUID actual = versionId;
LogError("Jit Compiler has wrong version identifier");
Copy link
Member

Choose a reason for hiding this comment

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

utilcode.h provides a conversion helper:

Suggested change
GUID expected = JITEEVersionIdentifier;
GUID actual = versionId;
LogError("Jit Compiler has wrong version identifier");
char expected[GUID_STR_BUFFER_LEN], actual[GUID_STR_BUFFER_LEN];
GuidToLPSTR(JITEEVersionIdentifier, expected, GUID_STR_BUFFER_LEN);
GuidToLPSTR(versionId, actual, GUID_STR_BUFFER_LEN));
LogError("Jit Compiler has wrong version identifier. expected: %s, actual: %s", expected, actual);

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, but we don't link with utilcode from here. Looks like that's intentional:

// The following functions are used for arm64/arm32 relocation processing.
// They are copies of the code in src\coreclr\utilcode\util.cpp.
// We decided to copy them instead of linking with utilcode library
// to avoid introducing additional runtime dependencies.

(I removed the leftover code from this PR, but #112820 has the same change.)

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually we do link with it, but only on Linux it seems. I will just add it to Windows too.

Copy link
Member Author

Choose a reason for hiding this comment

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

That does seem to pull in more dependencies that we aren't linking with.. probably something to do separately at this point.

Copy link
Member

Choose a reason for hiding this comment

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

Maybe we can move the formatting code where GUID is defined:

src/native/minipal/guid.h

#define GUID_STR_BUFFER_LEN (ARRAY_SIZE("{12345678-1234-1234-1234-123456789abc}"))

int32_t GUIDAsString(GUID guid, char* guidString, uint32_t len)
{
    assert(len >= GUID_STR_BUFFER_LEN);

    return snprintf(guidString, len, "{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
        guid.data1, guid.data2, guid.data3,
        guid.data4[0], guid.data4[1],
        guid.data4[2], guid.data4[3],
        guid.data4[4], guid.data4[5],
        guid.data4[6], guid.data4[7]) + 1;
}

and remove duplicate definitions from src/coreclr/inc/jiteeversionguid.h, src/coreclr/pal/inc/pal_mstypes.h and src/tests/Interop/common/xplatform.h.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think that's best left for a different PR.

Copy link
Member

Choose a reason for hiding this comment

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

Agreed, I've opened #112826.

@jakobbotsch jakobbotsch marked this pull request as ready for review February 23, 2025 21:50
@jakobbotsch
Copy link
Member Author

cc @dotnet/jit-contrib PTAL @EgorBo

Diffs. There are a few diffs on osx-arm64 where float HFAs are unaligned when passed as stack parameters (e.g. a 12 byte float HFA consumes exactly 12 bytes, and the next parameter can start right after it). The new lvaLclStackHomeSize will detect this case accurately and round up the size of other float HFAs, while the old logic would be more conservative and never round the size up in these cases.

Also some minor TP diffs. After this PR we should be able to get rid of the old parameter ABI classification which should result in some TP improvements.

@jakobbotsch jakobbotsch requested a review from EgorBo February 23, 2025 21:57
Copy link
Member

@EgorBo EgorBo left a comment

Choose a reason for hiding this comment

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

wonder if it fixes one of the HFA issues assigned to me, I'll check

@jakobbotsch jakobbotsch merged commit 9be0be0 into dotnet:main Feb 24, 2025
112 of 115 checks passed
@jakobbotsch jakobbotsch deleted the remove-uses-of-compArgSize branch February 24, 2025 16:18
@github-actions github-actions bot locked and limited conversation to collaborators Mar 27, 2025
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