the invariant for the risc-v codegen is, that 64bit regs generally contain the sign-extension of a 32bit value. This wasn't heeded by loads of 32bit values from memory, which used lwu and ultimately caused a miscompilation in string_test of tcctest.c. Now most of tcctest.c works (not with -run, but with linking a real executable), except some ftoi/ftof conversions.
Unified · Split
| @@ -155,7 +155,7 @@ ST_FUNC void load(int r, SValue *sv) · 154 unmodified lines | |||
| 155 | if (bt == VT_FUNC) | 155 | if (bt == VT_FUNC) |
| 156 | size = PTR_SIZE; | 156 | size = PTR_SIZE; |
| 157 | func3 = size == 1 ? 0 : size == 2 ? 1 : size == 4 ? 2 : 3; | 157 | func3 = size == 1 ? 0 : size == 2 ? 1 : size == 4 ? 2 : 3; |
| 158 | if (size < 8 && !is_float(sv->type.t) && (sv->type.t & VT_UNSIGNED)) | 158 | if (size < 4 && !is_float(sv->type.t) && (sv->type.t & VT_UNSIGNED)) |
| 159 | func3 |= 4; | 159 | func3 |= 4; |
| 160 | } | 160 | } |
| 161 | if (v == VT_LOCAL) { | 161 | if (v == VT_LOCAL) { |