[libunwind][RISCV] Make asm statement volatile (#130286)

Compiling with `O3`, the `early-machinelicm` pass hoisted the asm
statement to a path that has been executed unconditionally during stack
unwinding. On hardware without vector extension support, this resulted
in reading a nonexistent register.
This commit is contained in:
Gergely Futo 2025-03-10 10:13:33 +01:00 committed by GitHub
parent 0264d42dc7
commit 3acfef56b1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -4126,7 +4126,7 @@ inline reg_t Registers_riscv::getRegister(int regNum) const {
return _registers[regNum];
if (regNum == UNW_RISCV_VLENB) {
reg_t vlenb;
__asm__("csrr %0, 0xC22" : "=r"(vlenb));
__asm__ volatile("csrr %0, 0xC22" : "=r"(vlenb));
return vlenb;
}
_LIBUNWIND_ABORT("unsupported riscv register");