llvm.bitcast has so far not had a verifier and this allowed various bugs to sneak into the codebase (including within tests!) which could only be caught once translated to actual LLVM IR. This patch fixes those problematic cases by now verifying bitcasts on pointers are done correctly.
Specifically, it verifies that if pointers are involved, that both result and source types are pointers, that this also applies to vector of pointers and that pointer casts are of the same address space.
The only thing left unverified is the general case of "source type size does not match result type size". I think this case is less trivial and more prone to false positives, so I did not yet implement it.
Should we also check if the address-spaces of pointers in vectors match up, e.g., llvm.vec<4 x ptr<1>> and llvm.vec<4 x ptr<2>>, or is that checked elsewhere already?