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

Commit 81baf0a

Browse files
author
Sergey Andreenko
authored
Use full move for byte registers stores in jumps. (#11570)
* Use the 4-byte move for jump spilling. The other types of spilling already use the proper move: 1) for lsra spilling it always use 4-byte move because we allocate 4-byte slots; 2) for other types it sets needsByteReg and lsra chooses correct register; We do not apply the second approach to fixing this issue because jmp doesn't have real uses, that can keep this requirement on. Also, it creates more strict restrictions, that we need.
1 parent a7fae64 commit 81baf0a

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

src/jit/codegenxarch.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5406,8 +5406,9 @@ void CodeGen::genJmpMethod(GenTreePtr jmp)
54065406
// assert should hold.
54075407
assert(varDsc->lvRegNum != REG_STK);
54085408

5409-
var_types loadType = varDsc->lvaArgType();
5410-
getEmitter()->emitIns_S_R(ins_Store(loadType), emitTypeSize(loadType), varDsc->lvRegNum, varNum, 0);
5409+
assert(!varDsc->lvIsStructField || (compiler->lvaTable[varDsc->lvParentLcl].lvFieldCnt == 1));
5410+
var_types storeType = genActualType(varDsc->lvaArgType()); // We own the memory and can use the full move.
5411+
getEmitter()->emitIns_S_R(ins_Store(storeType), emitTypeSize(storeType), varDsc->lvRegNum, varNum, 0);
54115412

54125413
// Update lvRegNum life and GC info to indicate lvRegNum is dead and varDsc stack slot is going live.
54135414
// Note that we cannot modify varDsc->lvRegNum here because another basic block may not be expecting it.

src/jit/emitxarch.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4821,6 +4821,12 @@ void emitter::emitIns_S_R(instruction ins, emitAttr attr, regNumber ireg, int va
48214821
UNATIVE_OFFSET sz = emitInsSizeSV(insCodeMR(ins), varx, offs);
48224822
insFormat fmt = emitInsModeFormat(ins, IF_SRD_RRD);
48234823

4824+
#ifdef _TARGET_X86_
4825+
if (attr == EA_1BYTE)
4826+
{
4827+
assert(isByteReg(ireg));
4828+
}
4829+
#endif
48244830
// 16-bit operand instructions will need a prefix
48254831
if (EA_SIZE(attr) == EA_2BYTE)
48264832
{

src/jit/lclvars.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1833,7 +1833,10 @@ bool Compiler::lvaShouldPromoteStructVar(unsigned lclNum, lvaStructPromotionInfo
18331833

18341834
// TODO-PERF - Implement struct promotion for incoming multireg structs
18351835
// Currently it hits assert(lvFieldCnt==1) in lclvar.cpp line 4417
1836-
1836+
// Also the implementation of jmp uses the 4 byte move to store
1837+
// byte parameters to the stack, so that if we have a byte field
1838+
// with something else occupying the same 4-byte slot, it will
1839+
// overwrite other fields.
18371840
if (structPromotionInfo->fieldCnt != 1)
18381841
{
18391842
JITDUMP("Not promoting promotable struct local V%02u, because lvIsParam is true and #fields = "

0 commit comments

Comments
 (0)