Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/dotnet/runtime.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Andreenko <seandree@microsoft.com>2021-03-16 01:00:41 +0300
committerGitHub <noreply@github.com>2021-03-16 01:00:41 +0300
commitaa1eeb3dff7ae8b670e33e66a935d56591c2638d (patch)
tree23df36ecff85ceabb5d70ddfdabc49119ed38a62 /src/coreclr
parentd6ea28dd585ae9366fd9878264157c4acaf410a1 (diff)
Add Andy's stress mode for byrefs. (#49636)
Diffstat (limited to 'src/coreclr')
-rw-r--r--src/coreclr/jit/compiler.h1
-rw-r--r--src/coreclr/jit/morph.cpp12
2 files changed, 13 insertions, 0 deletions
diff --git a/src/coreclr/jit/compiler.h b/src/coreclr/jit/compiler.h
index 64635e15cb2..6353797cb3c 100644
--- a/src/coreclr/jit/compiler.h
+++ b/src/coreclr/jit/compiler.h
@@ -9267,6 +9267,7 @@ public:
STRESS_MODE(SWITCH_CMP_BR_EXPANSION) \
STRESS_MODE(GENERIC_VARN) \
STRESS_MODE(PROFILER_CALLBACKS) /* Will generate profiler hooks for ELT callbacks */ \
+ STRESS_MODE(BYREF_PROMOTION) /* Change undoPromotion decisions for byrefs */ \
\
/* After COUNT_VARN, stress level 2 does all of these all the time */ \
\
diff --git a/src/coreclr/jit/morph.cpp b/src/coreclr/jit/morph.cpp
index c2ee2047660..762171b4a6c 100644
--- a/src/coreclr/jit/morph.cpp
+++ b/src/coreclr/jit/morph.cpp
@@ -18513,6 +18513,18 @@ void Compiler::fgRetypeImplicitByRefArgs()
bool undoPromotion = ((lvaGetPromotionType(newVarDsc) == PROMOTION_TYPE_DEPENDENT) ||
(nonCallAppearances <= varDsc->lvFieldCnt));
+#ifdef DEBUG
+ // Above is a profitability heurisic; either value of
+ // undoPromotion should lead to correct code. So,
+ // under stress, make different decisions at times.
+ if (compStressCompile(STRESS_BYREF_PROMOTION, 25))
+ {
+ undoPromotion = !undoPromotion;
+ JITDUMP("Stress -- changing byref undo promotion for V%02u to %s undo\n", lclNum,
+ undoPromotion ? "" : "NOT");
+ }
+#endif // DEBUG
+
JITDUMP("%s promotion of implicit by-ref V%02u: %s total: %u non-call: %u fields: %u\n",
undoPromotion ? "Undoing" : "Keeping", lclNum,
(lvaGetPromotionType(newVarDsc) == PROMOTION_TYPE_DEPENDENT) ? "dependent;" : "",