// Is the first "VariableLiveRange" or the previous one has been closed so its "m_EndEmitLocation" is valid
noway_assert(m_VariableLiveRanges->empty() || m_VariableLiveRanges->back().m_EndEmitLocation.Valid());
- // Creates new live range with invalid end
- m_VariableLiveRanges->emplace_back(varLocation, emitLocation(), emitLocation());
- m_VariableLiveRanges->back().m_StartEmitLocation.CaptureLocation(emit);
-
+ if (!m_VariableLiveRanges->empty() &&
+ m_VariableLiveRanges->back().m_EndEmitLocation.IsPreviousIns(emit) &&
+ siVarLoc::Equals(&varLocation, &(m_VariableLiveRanges->back().m_VarLocation)))
+ {
+ // The variable is being born at the exactly same place just one assembly instructtion.
+ // We assume it never died.
+ m_VariableLiveRanges->back().m_EndEmitLocation.Init();
+ }
+ else
+ {
+ // Creates new live range with invalid end
+ m_VariableLiveRanges->emplace_back(varLocation, emitLocation(), emitLocation());
+ m_VariableLiveRanges->back().m_StartEmitLocation.CaptureLocation(emit);
+ }
+
#ifdef DEBUG
if (!m_VariableLifeBarrier->hasLiveRangesToDump())
{
return emit->emitCurIGsize;
}
+// Returns true if the emitter is on the next instruction of the same group than this emitLocation
+bool emitLocation::IsPreviousIns(const emitter* emit) const
+{
+ assert(Valid());
+ bool sameGroup = ig == emit->emitCurIG;
+ bool sameInsNum = emitGetInsNumFromCodePos(codePos) == emitGetInsNumFromCodePos(emit->emitCurOffset()) - 1;
+ return sameGroup && sameInsNum;
+}
+
#ifdef DEBUG
void emitLocation::Print() const
{
UNATIVE_OFFSET GetFuncletPrologOffset(emitter* emit) const;
+ bool emitLocation::IsPreviousIns(const emitter* emit) const;
+
#ifdef DEBUG
void Print() const;
#endif // DEBUG
return (codePos >> 16);
}
-inline unsigned emitter::emitCurOffset()
+inline unsigned emitter::emitCurOffset() const
{
unsigned codePos = emitCurIGinsCnt + (emitCurIGsize << 16);
/************************************************************************/
void* emitCurBlock();
-unsigned emitCurOffset();
+unsigned emitCurOffset() const;
UNATIVE_OFFSET emitCodeOffset(void* blockPtr, unsigned codeOffs);