Skip to content

Commit

Permalink
Updating check for empty debug ranges
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Bohe committed Oct 21, 2022
1 parent a11fd5d commit e8b102d
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/coreclr/jit/codegencommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8775,12 +8775,14 @@ void CodeGenInterface::VariableLiveKeeper::VariableLiveDescriptor::startLiveRang

//------------------------------------------------------------------------
// isLastRangeEmpty: Returns whether the last live range [A,B) is empty,
// meaning A == B.
// meaning A == B. This is an approximation as instructions may be removed
// after being emitted.
//
bool CodeGenInterface::VariableLiveKeeper::VariableLiveDescriptor::isLastRangeEmpty() const
{
return !m_VariableLiveRanges->empty() &&
m_VariableLiveRanges->back().m_StartEmitLocation == m_VariableLiveRanges->back().m_EndEmitLocation;
m_VariableLiveRanges->back().m_StartEmitLocation.noDistanceWith(
m_VariableLiveRanges->back().m_EndEmitLocation);
}

//------------------------------------------------------------------------
Expand Down
23 changes: 23 additions & 0 deletions src/coreclr/jit/emit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,29 @@ bool emitLocation::IsLessOneInsAway(emitter* emit) const
return false;
}

//------------------------------------------------------------------------
// noDistanceWith: Returns true if no instruction was emitted between
// both locations. This response is an approximation. There might be emitted
// instructions that were removed after the emitLocatiosn were generated.
//
// Arguments:
// loc - an emitLocation instance
//
// Assumptions:
// this emitLocation was captured before loc.
bool emitLocation::noDistanceWith(emitLocation& loc) const
{
assert(Valid());
assert(loc.Valid());
// Spanning an IG boundary?
if (ig->igNext == loc.ig)
{
return (emitGetInsNumFromCodePos(codePos) == ig->igInsCnt) && (emitGetInsNumFromCodePos(loc.codePos) == 0);
}
// otherwise
return this->operator==(loc);
}

#ifdef DEBUG
void emitLocation::Print(LONG compMethodID) const
{
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/jit/emit.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ class emitLocation
UNATIVE_OFFSET GetFuncletPrologOffset(emitter* emit) const;

bool IsLessOneInsAway(emitter* emit) const;
bool noDistanceWith(emitLocation& lhs) const;

#ifdef DEBUG
void Print(LONG compMethodID) const;
Expand Down

0 comments on commit e8b102d

Please sign in to comment.