[llvm] [DebugInfo][BPF] Add 'annotations' field for DIBasicType & DISubroutineType (PR #91422)

via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 20 03:24:54 PDT 2024


eddyz87 wrote:

> @eddyz87 You can reproduce the crash just by adding `-mtriple=powerpc64-aix` to the test. It doesn't require an AIX host.
> 
> Possibly the test just needs an explicit triple -- given that this is BPF functionality, it doesn't sound relevant to AIX.

Thank you for this suggestion. The test is for BPF functionality, but the expectation is that the relevant debug information would be generated for non-BPF binaries (linux kernel). However, looking at the reasons for the failure (below, under spoiler) I think that you are right, and it is better to hide the test behind `REQUIRES: x86-registered-target` and `-mtriple=x86_64-unknown-linux-gnu`. Will submit a PR shortly. Please let me know if you'd like to see revert+re-apply instead.

<details>
<summary>Test failure details</summary>
The test fails with the following backtrace:

```
$ llc -mtriple=powerpc64-aix -filetype=obj -o /dev/null llvm/test/DebugInfo/attr-btf_type_tag.ll
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.	Program arguments: llc -mtriple=powerpc64-aix -filetype=obj -o /dev/null /home/eddy/work/llvm-project/llvm/test/DebugInfo/attr-btf_type_tag.ll
 ...
 #4 0x000064cbfb6fd87b llvm::MCSection::getBeginSymbol()
                       /home/eddy/work/llvm-project/llvm/include/llvm/MC/MCSection.h:141:39
 #5 0x000064cbfb6fd87b llvm::DwarfUnit::addStringOffsetsStart()
                       /home/eddy/work/llvm-project/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp:1885:49
 #6 0x00005e3e18ba72e4 llvm::DwarfDebug::finishUnitAttributes(llvm::DICompileUnit const*, llvm::DwarfCompileUnit&)
                       /home/eddy/work/llvm-project/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp:1037:11
...
```

Relevant source code:

```c++
// DwarfUnit.cpp
  1879	void DwarfUnit::addStringOffsetsStart() {
  1880	  const TargetLoweringObjectFile &TLOF = Asm->getObjFileLowering();
  1881	  addSectionLabel(getUnitDie(), dwarf::DW_AT_str_offsets_base,
  1882	                  DU->getStringOffsetsStartSym(),
  1883	                  TLOF.getDwarfStrOffSection()->getBeginSymbol());
  1884	}

// DwarfDebug.cpp
   330  DwarfDebug::DwarfDebug(AsmPrinter *A)
   ...
   420    UseSegmentedStringOffsetsTable = DwarfVersion >= 5;
  ...
  1009  void DwarfDebug::finishUnitAttributes(const DICompileUnit *DIUnit,
  1010                                        DwarfCompileUnit &NewCU) {
  ...
  1033      // Add DW_str_offsets_base to the unit DIE, except for split units.
  1034      if (useSegmentedStringOffsetsTable())
  1035        NewCU.addStringOffsetsStart();
```
Adding some debug prints shows that `TLOF.getDwarfStrOffSection()` is NULL.
Object file format for powerpc-aix is `XCOFF`, inspecting `MCObjectFileInfo::initCOFFMCObjectFileInfo` shows that `DwarfStrOffSection` is indeed not initialized for this object file format.
Also, using `clang` to generate `ll` file for the test from scratch shows that for `powerpc-aix` DWARF v3 is used instead of v5.

Hence, the following line in the `ll` file triggers test failure:

```llvm
!31 = !{i32 7, !"Dwarf Version", i32 5}
```
</details>

https://github.com/llvm/llvm-project/pull/91422


More information about the llvm-commits mailing list