Skip to content

Commit 169e22c

Browse files
authored
[mono] Unaligned read/write only when NO_UNALIGNED_ACCESS is set (#91813)
* unaligned read/store only on platforms not supporting it
1 parent 867f5d4 commit 169e22c

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/mono/mono/mini/memory-access.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,7 @@ mini_emit_memory_load (MonoCompile *cfg, MonoType *type, MonoInst *src, int offs
481481
/* LLVM can handle unaligned loads and stores, so there's no reason to
482482
* manually decompose an unaligned load here into a memcpy if we're
483483
* using LLVM. */
484+
#ifdef NO_UNALIGNED_ACCESS
484485
if ((ins_flag & MONO_INST_UNALIGNED) && !COMPILE_LLVM (cfg)) {
485486
MonoInst *addr, *tmp_var;
486487
int align;
@@ -498,9 +499,10 @@ mini_emit_memory_load (MonoCompile *cfg, MonoType *type, MonoInst *src, int offs
498499

499500
mini_emit_memcpy_const_size (cfg, addr, src, size, 1);
500501
EMIT_NEW_TEMPLOAD (cfg, ins, tmp_var->inst_c0);
501-
} else {
502+
} else
503+
#endif
502504
EMIT_NEW_LOAD_MEMBASE_TYPE (cfg, ins, type, src->dreg, offset);
503-
}
505+
504506
ins->flags |= ins_flag;
505507

506508
if (ins_flag & MONO_INST_VOLATILE) {
@@ -524,14 +526,17 @@ mini_emit_memory_store (MonoCompile *cfg, MonoType *type, MonoInst *dest, MonoIn
524526
if (!(ins_flag & MONO_INST_NONULLCHECK))
525527
MONO_EMIT_NULL_CHECK (cfg, dest->dreg, FALSE);
526528

529+
#ifdef NO_UNALIGNED_ACCESS
527530
if ((ins_flag & MONO_INST_UNALIGNED) && !COMPILE_LLVM (cfg)) {
528531
MonoInst *addr, *mov, *tmp_var;
529532

530533
tmp_var = mono_compile_create_var (cfg, type, OP_LOCAL);
531534
EMIT_NEW_TEMPSTORE (cfg, mov, tmp_var->inst_c0, value);
532535
EMIT_NEW_VARLOADA (cfg, addr, tmp_var, tmp_var->inst_vtype);
533536
mini_emit_memory_copy_internal (cfg, dest, addr, mono_class_from_mono_type_internal (type), 1, FALSE, (ins_flag & MONO_INST_STACK_STORE) != 0);
534-
} else {
537+
} else
538+
#endif
539+
{
535540
MonoInst *ins;
536541

537542
/* FIXME: should check item at sp [1] is compatible with the type of the store. */

0 commit comments

Comments
 (0)