Consider using `IrType::Pointer` for raw pointers and references
Currently, both raw pointers (raw_ptr) and references (&T) are treated as u64 addresses in the IR, obtained by ptr_to_int from the original pointer. Since the references were introduced, there is a TODO comment in the IR generation asking if this conversion step is actually needed and if we can have raw pointers and references modeled as Pointer to an IrType instead of being u64.
The obvious benefit of having them modeled as Pointers, beside the clearly communicating the semantics, is knowing that certain locals are actually pointing to other values, and conserving the pointee types. E.g., currently, pointer and reference locals are emitted like:
local u64 my_ref
This results in a cumbersome and also cognitively demanding treatment of pointers and references in e.q. optimizations, because the only way to know if my_ref in the above example is a reference/pointer or a plain u64 number, is to look at the certain usage patterns specific for pointers and references, which is difficult and in a general case very likely never a 100% valid heuristics.
That's why I propose, as the mentioned TODO comment says, to explore if we can use IrType::Pointer instead.
The reason why the current design of having pointers modeled as plain u64 was originally chosen is not known to me.