Most of the code assumes that if "allocated" is set then the variable is used. It seems like an error that allocate_register_reservations() is setting it even for unused variables.
I think you are right. I probably introduced this regression in f8338ef08953686298bb31315a19e6044325bb49, I forgot to skip unused objects in allocate_register_reservations() when I wrote it.
Yes, probably the best solution is to add ```c if (!var->last_read || !var->data_type->reg_size[regset]) continue; ``` in allocate_register_reservations().
Francisco, is there a reason we're doing that? Why does get_allocated_object() check that flag?
Once that flag is set, the object registers are assumed to be reserved for that variable. allocate_register_reservations() should ensure that flag is set for all **used objects with register reservations** (we clearly have to fix the **used** part), and also allocate_objects() sets it for objects without register reservations, one at the time.