This is the clang side of the RFC in http://lists.llvm.org/pipermail/cfe-dev/2017-February/052549.html
Note that in contrast to the original suggestion -fsource-asm here we use the preferred -fverbose-asm. Basically explicitly saying -fverbose-asm in the command line enables a minimum amount of debugging, so in AsmPrinter we can use it to print the source code.
This patch introduces a -masm-source flag for cc1 that maps to the AsmSource value in the llvm code generation.
See the llvm side of this in https://reviews.llvm.org/D30897
TODO: Testing
I think that we should factor this out a bit. This feature is not the only one with this problem. The optimization reporting features also have this property (they need to enable debug info for some reason other than an actual desire to embed debug info in the resulting binaries). I think that we should add some separate feature, which this can toggle, but that optimization reporting can also use, to avoid actually generating debug info when only needed by these features.