Msg/ClobberedRegs
From CPUlator Wiki
< Msg
A calling convention defines which registers a function is allowed to modify (caller-saved), and which registers a function should preserve (callee-saved). Clobbering a register means overwriting its value. This message tells you that there were callee-saved registers (those a function should not modify) that were changed inside the current function.
Examples
ARMv7
.global _start
_start:
bl Func
nop
Func:
add r4, #1 // Modify a callee-saved register
bx lr
Debugging
- This message is complaining that one or more registers differ between the start of the function and at the function return. Use breakpoints and make a note of the value of those registers at both the function entry and return. Are they the same?
- If your function wants to (temporarily) modify callee-saved registers, it should preserve its value first, usually by storing the old value onto the stack and restoring it just before leaving the function. Saving and restoring (also called spilling and filling) can go wrong in many ways, such placing the stack at a location that doesn't contain memory.
Implementation
The simulator identifies idiomatic call and return instructions executed at runtime. It records the values of registers when executing call instructions, and verifies that callee-saved registers haven't changed when executing the matching function return. This warning is generated at the return instruction.
Disabling this message
This debugging check can be disabled in the Debugging Checks section of the Settings box: Function clobbered callee-saved register. The main reason you might consider disabling this warning is if you are intentionally using a non-standard calling convention.