diff --git a/src/coreclr/jit/liveness.cpp b/src/coreclr/jit/liveness.cpp index d5b20d3fa040a5..c07ced43d5af4b 100644 --- a/src/coreclr/jit/liveness.cpp +++ b/src/coreclr/jit/liveness.cpp @@ -51,11 +51,12 @@ class Liveness // // * Outside SSA: Partial defs are _not_ full defs and are also not // considered uses. They do not get included in bbVarUse/bbVarDef. - SsaLiveness = false, - ComputeMemoryLiveness = false, - IsLIR = false, - IsEarly = false, - EliminateDeadCode = false, + SsaLiveness = false, + ComputeMemoryLiveness = false, + IsLIR = false, + IsEarly = false, + EliminateDeadCode = false, + TrackAddressExposedLocals = false, }; Liveness(Compiler* compiler) @@ -446,7 +447,7 @@ void Liveness::SelectTrackedLocals() // Pinned variables may not be tracked (a condition of the GCInfo representation) // or enregistered, on x86 -- it is believed that we can enregister pinned (more properly, "pinning") // references when using the general GC encoding. - if (varDsc->IsAddressExposed()) + if (!TLiveness::TrackAddressExposedLocals && varDsc->IsAddressExposed()) { varDsc->lvTracked = 0; assert(varDsc->lvType != TYP_STRUCT || varDsc->lvDoNotEnregister); // For structs, should have set this when @@ -1044,7 +1045,8 @@ void Liveness::MarkUseDef(GenTreeLclVarCommon* tree) // We don't treat stores to tracked locals as modifications of ByrefExposed memory; // Make sure no tracked local is addr-exposed, to make sure we don't incorrectly CSE byref // loads aliasing it across a store to it. - assert(!varDsc->IsAddressExposed()); + assert(!varDsc->IsAddressExposed() || + (TLiveness::TrackAddressExposedLocals && !TLiveness::ComputeMemoryLiveness)); if (TLiveness::IsLIR && (varDsc->lvType != TYP_STRUCT) && !varTypeIsMultiReg(varDsc)) { @@ -2822,11 +2824,12 @@ void Compiler::fgSsaLiveness() { enum { - SsaLiveness = true, - ComputeMemoryLiveness = true, - IsLIR = false, - IsEarly = false, - EliminateDeadCode = true, + SsaLiveness = true, + ComputeMemoryLiveness = true, + IsLIR = false, + IsEarly = false, + EliminateDeadCode = true, + TrackAddressExposedLocals = false, }; SsaLivenessClass(Compiler* comp) @@ -2848,11 +2851,12 @@ void Compiler::fgAsyncLiveness() { enum { - SsaLiveness = false, - ComputeMemoryLiveness = false, - IsLIR = true, - IsEarly = false, - EliminateDeadCode = false, + SsaLiveness = false, + ComputeMemoryLiveness = false, + IsLIR = true, + IsEarly = false, + EliminateDeadCode = false, + TrackAddressExposedLocals = true, }; AsyncLiveness(Compiler* comp) @@ -2874,11 +2878,12 @@ void Compiler::fgPostLowerLiveness() { enum { - SsaLiveness = false, - ComputeMemoryLiveness = false, - IsLIR = true, - IsEarly = false, - EliminateDeadCode = true, + SsaLiveness = false, + ComputeMemoryLiveness = false, + IsLIR = true, + IsEarly = false, + EliminateDeadCode = true, + TrackAddressExposedLocals = false, }; PostLowerLiveness(Compiler* comp) @@ -2918,11 +2923,12 @@ PhaseStatus Compiler::fgEarlyLiveness() { enum { - SsaLiveness = false, - ComputeMemoryLiveness = false, - IsLIR = false, - IsEarly = true, - EliminateDeadCode = true, + SsaLiveness = false, + ComputeMemoryLiveness = false, + IsLIR = false, + IsEarly = true, + EliminateDeadCode = true, + TrackAddressExposedLocals = false, }; EarlyLiveness(Compiler* comp)