From fc949a45ffd01be07dc314f558b39a78a73016fc Mon Sep 17 00:00:00 2001 From: Pat Gavlin Date: Wed, 26 Jul 2017 15:54:16 -0700 Subject: [PATCH] Disable folding in genCreateAddrMode under LB-specific circumstances. If we are calling this function during emit with `fold = true`, then disable folding iff the value to be used as the index is already in a register. Not doing so can cause entire address modes to be folded away, which leads to asserts and potential SBCG. Fixes VSO 468730. --- src/jit/codegencommon.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/jit/codegencommon.cpp b/src/jit/codegencommon.cpp index 1137207..5caf96f 100644 --- a/src/jit/codegencommon.cpp +++ b/src/jit/codegencommon.cpp @@ -2385,6 +2385,16 @@ FOUND_AM: /* Special case: constant array index (that is range-checked) */ +#if defined(LEGACY_BACKEND) + // If we've already placed rv2 in a register, we were probably planning to use it in this addressing mode. + // Because the folding below may in fact result in no address mode (e.g. if we had "[mul * rv2 + cns]" that + // happens to fold to "[cns2]"), do not fold during code gen. + if (mode == -1 && rv2->InReg()) + { + fold = false; + } +#endif + if (fold) { ssize_t tmpMul; -- 2.7.4