Skip to content

Commit 3acfef5

Browse files
authored
[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.
1 parent 0264d42 commit 3acfef5

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

libunwind/src/Registers.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -4126,7 +4126,7 @@ inline reg_t Registers_riscv::getRegister(int regNum) const {
41264126
return _registers[regNum];
41274127
if (regNum == UNW_RISCV_VLENB) {
41284128
reg_t vlenb;
4129-
__asm__("csrr %0, 0xC22" : "=r"(vlenb));
4129+
__asm__ volatile("csrr %0, 0xC22" : "=r"(vlenb));
41304130
return vlenb;
41314131
}
41324132
_LIBUNWIND_ABORT("unsupported riscv register");

0 commit comments

Comments
 (0)