From 233bb0c8341079163acc12bea195e649f54ec5fb Mon Sep 17 00:00:00 2001 From: Jonghyun Park 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