kcc accepted this revision. kcc added a comment. This revision is now accepted and ready to land. LGTM, but please consider moving the code around (in a separate CL) to reduce the number of #ifdefs https://reviews.llvm.org/D50922