This is useful for PNaCl's RewriteAtomics pass. NaCl intrinsics don't exist for some of the more exotic RMW instructions, so by refactoring this function into its own, RewriteAtomics can share code rewriting those atomics with AtomicExpand while additionally saving a few cycles by generating the cmpxchg NaCl-specific intrinsic with the callback. Without this patch, RewriteAtomics would require two extra passes over functions, by first requiring use of the full AtomicExpand pass to just expand the leftover exotic RMWs and then running itself again to expand resulting cmpxchgs.
NFC