This adds support for pointer types for atomic xchg and let us write instructions such as atomicrmw xchg i64** %0, i64* %1 seq_cst. This is similar to the patch for allowing atomicrmw xchg on floating point types https://reviews.llvm.org/D52416.
Motivation: In Julia, we keep GC-managed objects as pointer in LLVM IR so that our compiler pass can insert GC-related instructions to track these objects. Thus, we cannot easily use bitcast (like clang does) to use atomicrmw xchg for swapping a pointer value (https://github.com/JuliaLang/julia/issues/44932). Adding direct support for xchg of pointer in LLVM would let us use native instructions in a wider class of programs. I think it may be beneficial to other languages with GC using approaches similar to Julia.
You can change this to get the size from the datalayout, instead of using getPrimitiveSizeInBits(). (Not that I really expect anyone to declare a non-power-of-two pointer type, but I don't think we actually forbid it.)