Skip to content

Commit

Permalink
add STRESS_PROMOTE_LESS_STRUCTS mode. (#49084)
Browse files Browse the repository at this point in the history
* add STRESS_PROMOTE_LESS_STRUCTS mode.

* add comment

* Disable failing tests.

* review

* fix build break
  • Loading branch information
Sergey Andreenko authored Mar 16, 2021
1 parent ed305e4 commit e614e17
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/coreclr/jit/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3594,6 +3594,31 @@ bool Compiler::compStressCompileHelper(compStressArea stressArea, unsigned weigh
return (hash < weight);
}

//------------------------------------------------------------------------
// compPromoteFewerStructs: helper to determine if the local
// should not be promoted under a stress mode.
//
// Arguments:
// lclNum - local number to test
//
// Returns:
// true if this local should not be promoted.
//
// Notes:
// Reject ~50% of the potential promotions if STRESS_PROMOTE_FEWER_STRUCTS is active.
//
bool Compiler::compPromoteFewerStructs(unsigned lclNum)
{
bool rejectThisPromo = false;
const bool promoteLess = compStressCompile(STRESS_PROMOTE_FEWER_STRUCTS, 50);
if (promoteLess)
{

rejectThisPromo = (((info.compMethodHash() ^ lclNum) & 1) == 0);
}
return rejectThisPromo;
}

#endif // DEBUG

void Compiler::compInitDebuggingInfo()
Expand Down
3 changes: 3 additions & 0 deletions src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -9268,6 +9268,7 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
STRESS_MODE(GENERIC_VARN) \
STRESS_MODE(PROFILER_CALLBACKS) /* Will generate profiler hooks for ELT callbacks */ \
STRESS_MODE(BYREF_PROMOTION) /* Change undoPromotion decisions for byrefs */ \
STRESS_MODE(PROMOTE_FEWER_STRUCTS)/* Don't promote some structs that can be promoted */ \
\
/* After COUNT_VARN, stress level 2 does all of these all the time */ \
\
Expand Down Expand Up @@ -9314,6 +9315,8 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
return compStressCompile(STRESS_RANDOM_INLINE, 50);
}

bool compPromoteFewerStructs(unsigned lclNum);

#endif // DEBUG

bool compTailCallStress()
Expand Down
8 changes: 8 additions & 0 deletions src/coreclr/jit/lclvars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2104,6 +2104,14 @@ bool Compiler::StructPromotionHelper::ShouldPromoteStructVar(unsigned lclNum)
// TODO-1stClassStructs: a temporary solution to keep diffs small, it will be fixed later.
shouldPromote = false;
}
#if defined(DEBUG)
else if (compiler->compPromoteFewerStructs(lclNum))
{
// Do not promote some structs, that can be promoted, to stress promoted/unpromoted moves.
JITDUMP("Not promoting promotable struct local V%02u, because of STRESS_PROMOTE_FEWER_STRUCTS\n", lclNum);
shouldPromote = false;
}
#endif

//
// If the lvRefCnt is zero and we have a struct promoted parameter we can end up with an extra store of
Expand Down
2 changes: 2 additions & 0 deletions src/tests/Interop/PInvoke/Vector2_3_4/Vector2_3_4.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<!-- https://github.com/dotnet/runtime/issues/49189 -->
<JitOptimizationSensitive Condition="'$(TargetArchitecture)' == 'x86'">true</JitOptimizationSensitive>
</PropertyGroup>
<ItemGroup>
<Compile Include="*.cs" />
Expand Down
2 changes: 2 additions & 0 deletions src/tests/JIT/Methodical/xxobj/ldobj/_il_relldobj_V.ilproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<CLRTestPriority>1</CLRTestPriority>
<!-- https://github.com/dotnet/runtime/issues/49189 -->
<JitOptimizationSensitive Condition="'$(TargetArchitecture)' == 'x86'">true</JitOptimizationSensitive>
</PropertyGroup>
<PropertyGroup>
<DebugType>PdbOnly</DebugType>
Expand Down

0 comments on commit e614e17

Please sign in to comment.