Skip to content
Vincent Laporte edited this page Nov 16, 2023 · 4 revisions

FAQ

How to debug compilation errors?

Register allocation

register allocation: no more register to allocate “ ra.357”

This message says that there are no free registers for storing the return address of some function (its name is a white space followed by ra). Which function? With the command-line flag -debug on, the compiler will output the required information (grep for the actual name of the variable to filter the too verbose output).

There are two possible kinds of fix to this kind of issue: either spill some registers to ensure there is at least one register that is free at all call sites; or change the calling-convention of the function so that return address is passed on the stack (this can be achieved through the #returnaddress=stack annotation before the function declaration).

Linearization

assignment remains

Assignments (instructions of the form d = e;) are processed by the various compilation passes, removed (when they become dead) or replaced by target operations (i.e., assembly-level instructions, such as rax = #MOV(rbx);). When everything goes well, all assignments are gone before the linearization pass.

This error message arises when one of the earlier passes could not handle the assignment. Often, the instruction selection pass could not find in the target instruction set (ISA) an operation matching said assignment. A common work-around is to decompose the assignment into several simpler steps.

How do I set a register to zero?

For setting variables to zero, Jasmin has the special #set0() intrinsic. For example:

reg u64 i;

i = #set0();
while (i < 256) {
    // ...
    i += 1;
}
Clone this wiki locally