Pull in r292032 from upstream llvm trunk (by Yaron Keren):
Fix PR31644 introduced by r287138 and add a regression test. Thanks Dimitry Andric for the report and fix!
This should restore -MP output to what it was before.
Reported by: jbeich
PR: 216043