Skip to content

Commit

Permalink
Fix liveness of FrameListRoot (#39452)
Browse files Browse the repository at this point in the history
* Fix liveness of FrameListRoot

The FrameListRoot variable isn't used if `call->IsSuppressGCTransition()`, but liveness wasn't checking this.

Fix #39221
  • Loading branch information
CarolEidt authored Jul 17, 2020
1 parent cc6d54c commit 49186d7
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/coreclr/src/jit/liveness.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,11 +349,10 @@ void Compiler::fgPerNodeLocalVarLiveness(GenTree* tree)
// This ensures that the block->bbVarUse will contain
// the FrameRoot local var if is it a tracked variable.

if ((tree->AsCall()->IsUnmanaged() || tree->AsCall()->IsTailCallViaJitHelper()) &&
compMethodRequiresPInvokeFrame())
if ((call->IsUnmanaged() || call->IsTailCallViaJitHelper()) && compMethodRequiresPInvokeFrame())
{
assert((!opts.ShouldUsePInvokeHelpers()) || (info.compLvFrameListRoot == BAD_VAR_NUM));
if (!opts.ShouldUsePInvokeHelpers())
if (!opts.ShouldUsePInvokeHelpers() && !call->IsSuppressGCTransition())
{
// Get the FrameRoot local and mark it as used.

Expand Down Expand Up @@ -1476,7 +1475,7 @@ void Compiler::fgComputeLifeCall(VARSET_TP& life, GenTreeCall* call)
{
// Get the FrameListRoot local and make it live.
assert((!opts.ShouldUsePInvokeHelpers()) || (info.compLvFrameListRoot == BAD_VAR_NUM));
if (!opts.ShouldUsePInvokeHelpers())
if (!opts.ShouldUsePInvokeHelpers() && !call->IsSuppressGCTransition())
{
noway_assert(info.compLvFrameListRoot < lvaCount);

Expand Down Expand Up @@ -1901,10 +1900,11 @@ void Compiler::fgComputeLifeLIR(VARSET_TP& life, BasicBlock* block, VARSET_VALAR

blockRange.Remove(node);

// Removing a call does not affect liveness unless it is a tail call in a nethod with P/Invokes or
// Removing a call does not affect liveness unless it is a tail call in a method with P/Invokes or
// is itself a P/Invoke, in which case it may affect the liveness of the frame root variable.
if (!opts.MinOpts() && !opts.ShouldUsePInvokeHelpers() &&
((call->IsTailCall() && compMethodRequiresPInvokeFrame()) || call->IsUnmanaged()) &&
((call->IsTailCall() && compMethodRequiresPInvokeFrame()) ||
(call->IsUnmanaged() && !call->IsSuppressGCTransition())) &&
lvaTable[info.compLvFrameListRoot].lvTracked)
{
fgStmtRemoved = true;
Expand Down

0 comments on commit 49186d7

Please sign in to comment.