summaryrefslogtreecommitdiff
path: root/packaging/0001-ARM-Linux-Support-unaligned-struct-read-write-11290.patch
blob: cfa21ebcb55d087d869430a1a680c6c62f15e92e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
From 233bb0c8341079163acc12bea195e649f54ec5fb Mon Sep 17 00:00:00 2001
From: Jonghyun Park <parjong@gmail.com>
Date: Sat, 20 May 2017 06:26:27 +0900
Subject: [PATCH 01/29] [ARM/Linux] Support unaligned struct read/write
 (#11290)

* [ARM/Linux] Support unaligned struct read

* Fix format error

* Support unaligned struct write
---
 src/jit/importer.cpp | 15 ++++++++++-----
 src/jit/morph.cpp    | 14 ++++++++++++++
 2 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/src/jit/importer.cpp b/src/jit/importer.cpp
index 74018c4..2d50741 100644
--- a/src/jit/importer.cpp
+++ b/src/jit/importer.cpp
@@ -14710,6 +14710,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;
             }
 
@@ -14822,11 +14827,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
                 {
@@ -14836,6 +14836,11 @@ void Compiler::impImportBlockCode(BasicBlock* block)
                 }
                 op1->gtFlags |= GTF_EXCEPT;
 
+                if (prefixFlags & PREFIX_UNALIGNED)
+                {
+                    op1->gtFlags |= GTF_IND_UNALIGNED;
+                }
+
                 impPushOnStack(op1, tiRetVal);
                 break;
             }
diff --git a/src/jit/morph.cpp b/src/jit/morph.cpp
index 9404469..27a1dae 100644
--- a/src/jit/morph.cpp
+++ b/src/jit/morph.cpp
@@ -9960,6 +9960,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;
-- 
2.7.4