Explicit cast of a void pointer to a pointer type in different address space is
incorrectly classified as bitcast, which causes invalid bitcast in codegen.
The patch fixes that by checking the address space of the source and destination
type and set the correct cast kind.
I know the code was like this before, but please rewrite this to just use getAs<PointerType>() instead of doing the separate isPointerType() check.