I don't see anything terrible in the pass or how you've written it. I can't comment on the atomic lowerings itself without a much closer look. http://reviews.llvm.org/D3356