[ARM/Linux] Support unaligned struct read/write (#11290)
authorJonghyun Park <parjong@gmail.com>
Fri, 19 May 2017 21:26:27 +0000 (06:26 +0900)
committerBruce Forstall <brucefo@microsoft.com>
Fri, 19 May 2017 21:26:27 +0000 (14:26 -0700)
* [ARM/Linux] Support unaligned struct read

* Fix format error

* Support unaligned struct write

src/jit/importer.cpp
src/jit/morph.cpp

index 3fdb416109c3862e01e7cc7c8c6b0284b62a681a..65bd12e1334c5133b7ba11c07c811c1e0d4a9b61 100644 (file)
@@ -14711,6 +14711,11 @@ void Compiler::impImportBlockCode(BasicBlock* block)
                 assertImp(varTypeIsStruct(op2));
 
                 op1 = impAssignStructPtr(op1, op2, resolvedToken.hClass, (unsigned)CHECK_SPILL_ALL);
+
+                if (op1->OperIsBlkOp() && (prefixFlags & PREFIX_UNALIGNED))
+                {
+                    op1->gtFlags |= GTF_BLK_UNALIGNED;
+                }
                 goto SPILL_APPEND;
             }
 
@@ -14823,11 +14828,6 @@ void Compiler::impImportBlockCode(BasicBlock* block)
                     // Could point anywhere, example a boxed class static int
                     op1->gtFlags |= GTF_IND_TGTANYWHERE | GTF_GLOB_REF;
                     assertImp(varTypeIsArithmetic(op1->gtType));
-
-                    if (prefixFlags & PREFIX_UNALIGNED)
-                    {
-                        op1->gtFlags |= GTF_IND_UNALIGNED;
-                    }
                 }
                 else
                 {
@@ -14837,6 +14837,11 @@ void Compiler::impImportBlockCode(BasicBlock* block)
                 }
                 op1->gtFlags |= GTF_EXCEPT;
 
+                if (prefixFlags & PREFIX_UNALIGNED)
+                {
+                    op1->gtFlags |= GTF_IND_UNALIGNED;
+                }
+
                 impPushOnStack(op1, tiRetVal);
                 break;
             }
index c216c7ee9d1afd92ab3c0f32fa0f099b55168531..7aa4e4351b399e5bfc7506e1f2754e236844372b 100644 (file)
@@ -9907,6 +9907,20 @@ GenTreePtr Compiler::fgMorphCopyBlock(GenTreePtr tree)
             requiresCopyBlock = true;
         }
 
+#if defined(_TARGET_ARM_)
+        if ((rhs->OperIsIndir()) && (rhs->gtFlags & GTF_IND_UNALIGNED))
+        {
+            JITDUMP(" rhs is unaligned");
+            requiresCopyBlock = true;
+        }
+
+        if (asg->gtFlags & GTF_BLK_UNALIGNED)
+        {
+            JITDUMP(" asg is unaligned");
+            requiresCopyBlock = true;
+        }
+#endif // _TARGET_ARM_
+
         if (dest->OperGet() == GT_OBJ && dest->AsBlk()->gtBlkOpGcUnsafe)
         {
             requiresCopyBlock = true;