Skip to content

Cleanup LclVar alignment requirements. #46026

@sandreenko

Description

@sandreenko

The current alignment mechanism for jit local vars is very complex, I think it is worth a cleanup.

Requirements:

  1. 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.
  2. 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:

  1. There is genTypeAlignments table that is defined in "typelist.h" and is used only in InferOpSizeAlign for ArmArch, for arm64 it is used only in a stress mode, for arm32 it is used in fgInitArgInfo;

  2. 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:

    /* Need to align the offset? */

    and then call the function that handles 64-bit"
    stkOffs = lvaAllocLocalAndSetVirtualOffset(lclNum, lvaLclSize(lclNum), stkOffs);

the correctness requirements are hardcoded into the code, they are not coming from "typelist.h".

  1. for arguments we usually just set alignment to TARGET_POINTER_SIZE and 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

area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMIdesign-discussionOngoing discussion about design without consensus

Type

No type

Projects

Status

Backlog (General)

Relationships

None yet

Development

No branches or pull requests

Issue actions