This is a follow-up to ff837aa6, as discussed on the llvm-commits thread for that one. (cherry picked from commit 1b3d1661)