This is an archive of the discontinued LLVM Phabricator instance.

Add new -fverbose-asm that enables source interleaving
Needs ReviewPublic

Authored by rogfer01 on Mar 13 2017, 9:28 AM.

Details

Summary

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

Diff Detail

Event Timeline

rogfer01 created this revision.Mar 13 2017, 9:28 AM
rogfer01 edited the summary of this revision. (Show Details)Mar 13 2017, 9:30 AM
rogfer01 edited the summary of this revision. (Show Details)

Hi Roger,

I'm very glad to see you started to work on this!

A somewhat obvious comment: no chance for this to be accepted without LIT tests. I understand you have your doubts on the best approach to testing -- and it's OK to ask either here or on llvm-dev -- but tests should be added nevertheless.

Yours,
Andrey

A somewhat obvious comment: no chance for this to be accepted without LIT tests. I understand you have your doubts on the best approach to testing -- and it's OK to ask either here or on llvm-dev -- but tests should be added nevertheless.

Sure. I wasn't planning to commit this without tests! :)

Thank you.

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.

-fverbose-asm seems like a good name to me, but that's taken already. This feature should imply -fverbose-asm (that's where the value-add is over having objdump do this). But we don't always want this when we enable -fverbose-asm. How about -fsource-interleaved-asm for this feature?

This patch introduces a -masm-source flag for cc1 that maps to the AsmSource value in the llvm code generation.

I see no reason to use a different flag name for cc1. Just use the same flag (tag it with Flags<[CC1Option] in the .td file).

lib/Driver/ToolChains/Clang.cpp
2754

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.

lib/Frontend/CompilerInvocation.cpp
855

This is where you'd enable debug line-table info when needed by this feature.

emaste added a subscriber: emaste.Jun 11 2017, 5:36 AM