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

Return accurate size of addressing mode dsp/dsp+cnst instr descriptor #47284

Merged
merged 2 commits into from
Jan 25, 2021

Conversation

kunalspathak
Copy link
Member

@kunalspathak kunalspathak commented Jan 21, 2021

During spmi asmdiffs with cross compiled jit, I noticed we hit the following assert

assert(id->idDebugOnlyInfo()->idSize == sz);

It happens because for ID_OP_AMD and ID_OP_AMD_CNS format, we create instrDescCnsAmd but then in emitSizeOfInsDsc(), when we try to calculate the size, we calculate the size of instrDescCnsDsp instead. They don't match for cross compilation scenario like running superpmi asmdiffs for cross target. E.g. While running with clrjit_win_x86_x64.dll, sizeof(instrDescCnsAmd) == 40 but sizeof(instrDescCnsDsp) == 32. The is because instrDescCnsDsp contains a field of type target_ssize_t which is different for x64 vs. x86.

struct instrDescCnsDsp : instrDesc // large cons + disp

The fix is to return the size of right struct for these formats.

@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 21, 2021
@kunalspathak kunalspathak marked this pull request as ready for review January 22, 2021 00:41
@kunalspathak
Copy link
Member Author

@dotnet/jit-contrib

@echesakov
Copy link
Contributor

@kunalspathak Have you confirmed our hypothesis that size of the instructions descriptors are the same with crossgen (x86) as we discussed yesterday?

@@ -7440,6 +7438,30 @@ size_t emitter::emitSizeOfInsDsc(instrDesc* id)
return sizeof(instrDesc);
}
}
case ID_OP_AMD:
case ID_OP_AMD_CNS:
if (id->idIsLargeCns())
Copy link
Member

Choose a reason for hiding this comment

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

Based on emitNewInstrAmdCns, I would expect it to be:

            if (id->idIsLargeCns())
            {
                if (id->idIsLargeDsp())
                {
                    return sizeof(instrDescCnsAmd);
                }
                else
                {
                    return sizeof(instrDescCns);
                }
            }
            else
            {
                if (id->idIsLargeDsp())
                {
                    return sizeof(instrDescAmd);
                }
                else
                {
                    return sizeof(instrDesc);
                }
            }

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 yes.

@kunalspathak
Copy link
Member Author

@kunalspathak Have you confirmed our hypothesis that size of the instructions descriptors are the same with crossgen (x86) as we discussed yesterday?

Yes @echesakovMSFT - they are same. I also crossgen stind_i1.ilproj project which reproed the issue and used R2RDump.exe to see if things work.

@kunalspathak kunalspathak merged commit 1a25256 into dotnet:master Jan 25, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Feb 27, 2021
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