Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
VSadov committed Mar 29, 2024
1 parent 66383be commit 981922e
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 14 deletions.
9 changes: 7 additions & 2 deletions src/coreclr/jit/codegencommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -502,9 +502,14 @@ void CodeGenInterface::genUpdateLife(GenTree* tree)
treeLifeUpdater->UpdateLife(tree);
}

bool CodeGenInterface::genUpdateLife(VARSET_VALARG_TP newLife)
void CodeGenInterface::genUpdateLife(VARSET_VALARG_TP newLife)
{
return compiler->compUpdateLife</*ForCodeGen*/ true>(newLife);
compiler->compUpdateLife</*ForCodeGen*/ true>(newLife);
}

bool CodeGenInterface::genWillUpdateLife(VARSET_VALARG_TP newLife)
{
return compiler->compWillUpdateLife(newLife);
}

// Return the register mask for the given register variable
Expand Down
3 changes: 2 additions & 1 deletion src/coreclr/jit/codegeninterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,8 @@ class CodeGenInterface
regMaskTP genGetRegMask(GenTree* tree);

void genUpdateLife(GenTree* tree);
bool genUpdateLife(VARSET_VALARG_TP newLife);
void genUpdateLife(VARSET_VALARG_TP newLife);
bool genWillUpdateLife(VARSET_VALARG_TP newLife);

TreeLifeUpdater<true>* treeLifeUpdater;

Expand Down
13 changes: 7 additions & 6 deletions src/coreclr/jit/codegenlinear.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,21 +192,22 @@ void CodeGen::genCodeForBBlist()

compiler->m_pLinearScan->recordVarLocationsAtStartOfBB(block);

// Updating variable liveness after last instruction of previous block was emitted
// and before first of the current block is emitted
bool livenessChanged = genUpdateLife(block->bbLiveIn);

// if liveness has changed and the last block ended on emitting a call that can do GC,
// if liveness is changing and the last block ended on emitting a call that can do GC,
// emit a nop to ensure that GC info is not changing between
// "call has been made" and "call has returned" states.
if (livenessChanged)
if (genWillUpdateLife(block->bbLiveIn))
{
if (GetEmitter()->emitLastInsIsCallWithGC())
{
printf("####################\n");
instGen(INS_nop);
}
}

// Updating variable liveness after last instruction of previous block was emitted
// and before first of the current block is emitted
genUpdateLife(block->bbLiveIn);

// Even if liveness didn't change, we need to update the registers containing GC references.
// genUpdateLife will update the registers live due to liveness changes. But what about registers that didn't
// change? We cleared them out above. Maybe we should just not clear them out, but update the ones that change
Expand Down
7 changes: 6 additions & 1 deletion src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -8516,7 +8516,12 @@ class Compiler
// Update the GC's masks, register's masks and reports change on variable's homes given a set of
// current live variables if changes have happened since "compCurLife".
template <bool ForCodeGen>
inline bool compUpdateLife(VARSET_VALARG_TP newLife);
inline void compUpdateLife(VARSET_VALARG_TP newLife);

inline bool compWillUpdateLife(VARSET_VALARG_TP newLife)
{
return (!VarSetOps::Equal(this, compCurLife, newLife));
}

// Gets a register mask that represent the kill set for a helper call since
// not all JIT Helper calls follow the standard ABI on the target architecture.
Expand Down
5 changes: 1 addition & 4 deletions src/coreclr/jit/compiler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3543,12 +3543,11 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// The set of live variables reflects the result of only emitted code, it should not be considering the becoming
// live/dead of instructions that has not been emitted yet. This is requires by "compChangeLife".
template <bool ForCodeGen>
inline bool Compiler::compUpdateLife(VARSET_VALARG_TP newLife)
inline void Compiler::compUpdateLife(VARSET_VALARG_TP newLife)
{
if (!VarSetOps::Equal(this, compCurLife, newLife))
{
compChangeLife<ForCodeGen>(newLife);
return true;
}
#ifdef DEBUG
else
Expand All @@ -3561,8 +3560,6 @@ inline bool Compiler::compUpdateLife(VARSET_VALARG_TP newLife)
}
}
#endif // DEBUG

return false;
}

/*****************************************************************************
Expand Down

0 comments on commit 981922e

Please sign in to comment.