Register Guide

RISC-V s10 / x26 Register: Saved register

Callee-saved register 10; must be preserved across function calls.

ABI name: s10; physical register: x26.
Save rule: Callee.
Read it through its psABI role first, then inspect how each instruction reads or writes it.
Physical Name x26ABI Name s10Save Rule Callee
Role
Saved register
Convention
Callee-saved
Remember This First
s* registers are callee-saved: if a function borrows them, it must restore them before return.
psABI Reference

Saved register

The psABI marks s0-s11 as preserved across calls. A callee that modifies them must restore their original values before returning; s0 may also serve as the frame pointer.

Preserved across calls: Yes
RISC-V psABI integer register convention
Quick Understanding & Search Notes

s10 / x26 belongs to the s0-s11 saved-register group. The psABI marks it preserved across calls; a callee that modifies it must restore it before returning.

s0-s11 are saved registers preserved across calls.
A callee that modifies s10 must restore its original value before returning.

When It Fits Best

  • - Keep values that still matter after calling another function.
  • - Preserve data that must remain available after nested calls.
  • - s10 is an ordinary saved register and does not have the s0/fp frame-pointer alias role.

When Not To Use It This Way

  • - Do not modify s* and return without restoring it.
  • - Prefer t* for short-lived temporaries instead of occupying s* for brief calculations.

What Happens Around A Call

1

s* registers are callee-saved: if a function borrows them, it must restore them before return.

2

Callers may assume s* remain unchanged after the call returns.

3

Changing s* usually implies save-on-entry and restore-on-exit.

Save And Restore callee-saved Registers On RV64

Examples explain the rule, not a complete program
addi sp, sp, -16
sd   s10, 0(sp)
addi s10, a0, 0
call foo
# s10 still keeps the value needed after the call
ld   s10, 0(sp)
addi sp, sp, 16
ret

FAQ

Why is s10 / x26 suitable for values that survive calls?

s0-s11 are preserved across calls; a callee that modifies them must restore them, so callers can rely on their values after return.

Who restores s10 if a function modifies it?

The callee restores it before returning.