[JIT/ARM] Fix Compiler::lvaFrameAddress
authorKonstantin Baladurin <k.baladurin@partner.samsung.com>
Mon, 18 Jun 2018 12:49:40 +0000 (15:49 +0300)
committerKonstantin Baladurin <k.baladurin@partner.samsung.com>
Mon, 18 Jun 2018 12:55:52 +0000 (15:55 +0300)
Use sp-based offset only if r10 reserved or offset is lower than
encoding limit.

Commit migrated from https://github.com/dotnet/coreclr/commit/d513e316e1a5f5e8e482193c736e90d51aba1f88

src/coreclr/src/jit/compiler.hpp

index 51c0299..f0c7449 100644 (file)
@@ -2438,7 +2438,7 @@ inline
             int actualOffset   = (spOffset + addrModeOffset);
             int ldrEncodeLimit = (varTypeIsFloating(type) ? 0x3FC : 0xFFC);
             // Use ldr sp imm encoding.
-            if (lvaDoneFrameLayout == FINAL_FRAME_LAYOUT || opts.MinOpts() || (actualOffset <= ldrEncodeLimit))
+            if (opts.MinOpts() || (actualOffset <= ldrEncodeLimit))
             {
                 offset    = spOffset;
                 *pBaseReg = compLocallocUsed ? REG_SAVED_LOCALLOC_SP : REG_SPBASE;
@@ -2448,17 +2448,14 @@ inline
             {
                 *pBaseReg = REG_FPBASE;
             }
-            // Use a single movw. prefer locals.
-            else if (actualOffset <= 0xFFFC) // Fix 383910 ARM ILGEN
+            // Otherwise, use SP. This is either (1) a small positive offset using a single movw, (2)
+            // a large offset using movw/movt. In either case, we must have already reserved
+            // the "reserved register".
+            else
             {
                 offset    = spOffset;
                 *pBaseReg = compLocallocUsed ? REG_SAVED_LOCALLOC_SP : REG_SPBASE;
             }
-            // Use movw, movt.
-            else
-            {
-                *pBaseReg = REG_FPBASE;
-            }
         }
     }
     else