Skip to content

Commit

Permalink
[RISC-V] Remove unnecessary assertion from emitOutputInstr (#98484)
Browse files Browse the repository at this point in the history
* Remove unnecessary assertion

It fired a false positive when W^X was enabled

* Use uint32 write instead of memcpy to be faster

There shouldn't be a problem when we introduce compressed instructions, VF2 supports unaligned stores (sw)
Also, replace compile-time conditions with static_asserts.

* Bring back memcpy because plain RV64 ISA allows trapping on misaligned load/stores
  • Loading branch information
tomeksowi authored Feb 19, 2024
1 parent b473606 commit 07992e2
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/coreclr/jit/emitriscv64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2118,8 +2118,8 @@ void emitter::emitJumpDistBind()
unsigned emitter::emitOutput_Instr(BYTE* dst, code_t code) const
{
assert(dst != nullptr);
assert(sizeof(code_t) == 4);
memcpy(dst + writeableOffset, &code, sizeof(code_t));
static_assert(sizeof(code_t) == 4, "code_t must be 4 bytes");
memcpy(dst + writeableOffset, &code, sizeof(code));
return sizeof(code_t);
}

Expand Down Expand Up @@ -3157,8 +3157,7 @@ size_t emitter::emitOutputInstr(insGroup* ig, instrDesc* id, BYTE** dp)
instruction ins;
size_t sz = 0;

assert(REG_NA == static_cast<int>(REG_NA));
assert(writeableOffset == 0);
static_assert(REG_NA == static_cast<int>(REG_NA), "REG_NA must fit in an int");

insOpts insOp = id->idInsOpt();

Expand Down

0 comments on commit 07992e2

Please sign in to comment.