Closed penberg closed 12 years ago
AFAICT, the way to fix this is to make sure caller save register are saved and restored by the spill/reload logic of the register allocator. However, we need to do this as a separate pass after we've assigned physical registers to struct var_infos; otherwise we fail to catch all clobbers.
Given this test program:
If you compile Jato with GCC optimization level "-O2", for example:
and then run the program as follows:
You will see the following crash:
Exception in thread "main" java.lang.IllegalArgumentException at Hashtable.(Hashtable.java:12)
at Hashtable.main(Hashtable.java:20)
Now while this doesn't seem to happen with the "-Os" GCC optimization level, it's by pure luck. Looking at the generated assembly, we see that XMM registers (which are caller saved registers on x86-64) are not saved before call instructions:
which means that the any function that uses the XMM registers will clobber our registers.
I went through the code and I believe that the register allocator does not properly handle caller-saved registers. The special-casing in __update_live_ranges() seems incomplete because it doesn't update the "defs" bitmap nor updates use positions.