When I am constructing sequences of instructions during custom lowering, I would like to be able to also add a comment that appears in the generated assembly with ‘-S -fverbose-asm’. There is a large set of ‘add*’ functions to attach additional information to the MI, but I don’t see one for adding comments.
Is there a method I can call to attach an arbitrary string (‘StringRef’, ‘const char*’, ‘Twine’) to an MI with ‘BuildMI’ or after?
There is no generic mechanism as far as I know. You can look at AsmPrinter.cpp/emitComments() to see what situations trigger comments at the moment.
It looks like the comments that do exist are emitted are pre-cooked and depend on some other attribute of the MI or the context of the MI. Curiously enough, a couple of years ago I had thought about this, but I wanted to have different comments used for instructions selected by the TableGen pattern matcher versus those crafted directly in the C++ code which would be very useful when debugging obscure code-generation issues.
All the best,