Checking validity of metadata in an .ll file

Hi all,

I was wondering if there is a way to check that metadata emitted in an LLVM file are corrects with respect to debug informations.
My problem is that I emit ‘metadata’ in an .ll file and then using ‘llc’ there is no debug information emitted in final assembly.
For now I limit metadata to routines/subprogram/file/block descriptors, is this the problem ?

Thanks for your help
Best Regards
Seb

Hi all,

I was wondering if there is a way to check that metadata emitted in an LLVM file are corrects with respect to debug informations.

Right now there is no such check. In fact, 'llc' is trained to silently ignore malformed debug information, because 'opt' is not held reliable to maintain debug info. That said, it would be valuable to write such verification pass.

My problem is that I emit 'metadata' in an .ll file and then using 'llc' there is no debug information emitted in final assembly.
For now I limit metadata to routines/subprogram/file/block descriptors, is this the problem ?

It is hard to guess with limited info. Probably it is easier to just single step in llc (DwarfDebug.cpp) and understand what is missing.

Hi Devang,

Thanks for the answer, I eventually found that in DW_TAG_compile_unit metadata, if field for ‘main’ compile unit is set to false then no debug info is generated. Can someone explain what is the meaning of this field ?

You wrote:

“Right now there is no such check. In fact, ‘llc’ is trained to silently ignore malformed debug information, because ‘opt’ is not held reliable to maintain debug info. That said, it would be valuable to write such verification pass.”

Does this means that after opt metadata are not reliable at all ?

Best Regards
Seb

Hi Devang,

Thanks for the answer, I eventually found that in DW_TAG_compile_unit metadata, if field for 'main' compile unit is set to false then no debug info is generated. Can someone explain what is the meaning of this field ?

It is a relic from the days when each include headers where described using its own compile unit. At that time, it was used to identify main source file for the translation unit. It'd be good to clean this up now.

You wrote:

"Right now there is no such check. In fact, 'llc' is trained to silently ignore malformed debug information, because 'opt' is not held reliable to maintain debug info. That said, it would be valuable to write such verification pass."

Does this means that after opt metadata are not reliable at all ?

Yes. For example, it is certainly possible that opt deletes a function. In such cases, the metadata descriptor for the function will have incomplete info. So the dwarf writer should silently ignore such incomplete descriptors.