This is an archive of the discontinued LLVM Phabricator instance.

[DEBUGINFO, NVPTX] Removed Label Arithmetic from DWARF Pub Sections for NVPTX
Needs ReviewPublic

Authored by jdtatz on Sep 23 2020, 7:55 PM.

Details

Summary

The NVPTX target disallows both labels in debug sections and label arithmetic,
so instead the content sizes are computed before writing. The new test
in "debug-pub.ll" was added for this specfic change. Also included
are the renabling of Data16bitsDirective and NVPTXTargetStreamer::emitRawBytes,
which have been fixed since CUDA 9.0, with the debuginfo tests updated for this.

Diff Detail

Event Timeline

jdtatz created this revision.Sep 23 2020, 7:55 PM
jdtatz requested review of this revision.Sep 23 2020, 7:55 PM
jdtatz updated this revision to Diff 293942.Sep 23 2020, 10:46 PM

Removed the renabling of Data16bitsDirective and NVPTXTargetStreamer::emitRawBytes as it's
extraneous to the point of this patch and should be submitted in a new patch afterwards.

If I do recall it correctly, NVPTX debug info does not support pub sections. You just need to tweak the frontend to disable emission of pub sections (need to add , nameTableKind: None to the DICompileUnit)

If I do recall it correctly, NVPTX debug info does not support pub sections. You just need to tweak the frontend to disable emission of pub sections (need to add , nameTableKind: None to the DICompileUnit)

Sorry that I took so long to respond.
But I was able to find information on which dwarf sections ptx supports in the official documentation.
https://docs.nvidia.com/cuda/ptx-writers-guide-to-interoperability/index.html#debug-information
They also mention that they support the "debug_aranges" section which is currently disabled for only the NVPTX backend, but I could re-enable it if that's ok.

jdtatz updated this revision to Diff 295987.Oct 3 2020, 10:48 AM

Updated LLVM.DebugInfo/X86::dwarf-pubnames-split.ll test to remove the label arithmetic
Fixed my new test where I forgot to include the new lengths in the last update
Although I don't understand yet, why LLVM.DebugInfo/X86::debug-pubtables-dwarf64.ll is failing.

If I do recall it correctly, NVPTX debug info does not support pub sections. You just need to tweak the frontend to disable emission of pub sections (need to add , nameTableKind: None to the DICompileUnit)

Sorry that I took so long to respond.
But I was able to find information on which dwarf sections ptx supports in the official documentation.
https://docs.nvidia.com/cuda/ptx-writers-guide-to-interoperability/index.html#debug-information
They also mention that they support the "debug_aranges" section which is currently disabled for only the NVPTX backend, but I could re-enable it if that's ok.

Yeah, they are just optional.

llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
2339–2357

I would guard this with the check for DwarfSectionsAsReferences flag.

jdtatz updated this revision to Diff 296004.Oct 3 2020, 1:48 PM

Used @ABataev suggestion of adding a "guard this with the check for DwarfSectionsAsReferences",
so that these changes are only used for targets that don't support labels in Dwarf sections.

Did you check if ptxas can process it correctly? Are there any problems with it? I did not see that nvcc generates these sections at all.

jdtatz marked an inline comment as done.Oct 9 2020, 2:17 PM

Did you check if ptxas can process it correctly? Are there any problems with it? I did not see that nvcc generates these sections at all.

It can and you can check with ptxas $PTX_FILE -o $OUT && llvm-dwarfdump $OUT -debug-pubnames
To get nvcc to generate it you can use the example in their ptx interop guide, but you must pass the --device-debug / -G flag to nvcc for it to generate the "debug_pubnames" section.