-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Description
The current alignment mechanism for jit local vars is very complex, I think it is worth a cleanup.
Requirements:
- There are different requirements for incoming arguments and local vars in the method:
1.1 the incoming argument requirements are simple, esp. without vector calling convention. - There are correctness and performance requirements for local vars:
2.1 there are more correctness requirements for armArch, less for XARCH;
I propose to create 2 functions:
- getAlignmentForArg();
- getAlignmentForLocal(bool correctness/performance);
What do we have now:
-
There is
genTypeAlignmentstable that is defined in "typelist.h" and is used only inInferOpSizeAlignfor ArmArch, for arm64 it is used only in a stress mode, for arm32 it is used infgInitArgInfo; -
How do we get alignment for arm64? It happens in
lvaAllocLocalAndSetVirtualOffset, but this function has correct code only for 64-bit target, for arm32 we set the correct alignment before calling it:
runtime/src/coreclr/jit/lclvars.cpp
Line 6496 in d0121ea
/* Need to align the offset? */
and then call the function that handles 64-bit"
runtime/src/coreclr/jit/lclvars.cpp
Line 6536 in d0121ea
stkOffs = lvaAllocLocalAndSetVirtualOffset(lclNum, lvaLclSize(lclNum), stkOffs);
the correctness requirements are hardcoded into the code, they are not coming from "typelist.h".
- for arguments we usually just set alignment to
TARGET_POINTER_SIZEand it works as long as we don't have vector calling convention, if we get it we will have the wrong alignment for arm/arm64.
With the new requirements for arm64 apple I had to check and change all of these places for the new ABI.
I suggest to delete alignment information from "typelist.h", delete genTypeAlignments, replace code in lvaAllocLocalAndSetVirtualOffset and lvaAssignVirtualFrameOffsetsToLocals with a call to getAlignmentForLocal;
Stress code in lvaStressLclFldCB also should be changed to use getAlignmentForLocal, the old code that was working only for armArch should be deleted.
category:design
theme:alignment
skill-level:intermediate
cost:medium
impact:small
Metadata
Metadata
Assignees
Labels
Type
Projects
Status