[PATCH] D114705: [DwarfDebug] Move emission of global vars, types and imports to endModule()

Kristina Bessonova via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 29 06:13:57 PST 2021


krisb created this revision.
krisb added reviewers: dblaikie, aprantl, probinson, ellis.
Herald added subscribers: asavonic, kerbowa, mgrang, hiraditya, jgravelle-google, sbc100, nhaehnle, jvesely, nemanjai, dschuff, jholewinski.
krisb requested review of this revision.
Herald added subscribers: llvm-commits, aheejin.
Herald added a project: LLVM.

This patch proposes to move emission of global variables, types,
imported entities, etc from DwarfDebug::beginModule() to DwarfDebug::endModule().
Effectively, this changes nothing but the order of debug entities which
will be created as follows:

- subprograms (including related context, local variables/labels, local imported entities; related types can be created as a part of the emission of local entities of an abstract subprogram);
- global variables (including related context and types);
- retained types and enums;
- non-local-scoped imported entities;
- basic types;
- other types left (as a part of local variables attributes emission).

Note that the order of emitted compile units may also be changed as now we emit
units that contain subprograms first and then all other non-empty units.

This is a part extracted from D113741 <https://reviews.llvm.org/D113741>.

The motivation behind this change is the following:
(1) DwarfDebug::beginModule() is run at the very beginning of backend's pipeline,

  from this time IR can be significantly changed by target-specific passes,
  and debug info never accounts for these changes (for example, address space
  lowering done by generic-to-nvvm for NVPTX backend).

(2) imported subprogram names should refer to an abstract subprogram if it exists,

  but it isn't known in DwarfDebug::beginModule() (it's possible to make some
  guesses based on location info, but it's not quite reliable);

(3) aforementioned entities if they are scoped within a bracketed block

  (subject of D113741) couldn't be emitted in DwarfDebug::beginModule()
  (they need parent emitted first). Another problem is if we try to gather
  some information about local entities and defer their emission
  (till subprogram's processing or DwarfDebug::endModule()) all the gathered
  details might be irrelevant by the time the entities are being emitted
  (because of (1)).

This patch isn't intended to fix something but the issue (1), but I believe
it should also simplify reviewing and testing of D113741 <https://reviews.llvm.org/D113741>.

It also removes some comments that I believe are no longer relevant.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114705

Files:
  lld/test/wasm/debuginfo.test
  llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
  llvm/test/CodeGen/ARM/2011-01-19-MergedGlobalDbg.ll
  llvm/test/CodeGen/ARM/2011-08-02-MergedGlobalDbg.ll
  llvm/test/DebugInfo/AMDGPU/variable-locations.ll
  llvm/test/DebugInfo/BPF/extern-void.ll
  llvm/test/DebugInfo/Generic/cross-cu-linkonce-distinct.ll
  llvm/test/DebugInfo/Generic/debug-info-qualifiers.ll
  llvm/test/DebugInfo/Generic/debug-names-linkage-name.ll
  llvm/test/DebugInfo/Generic/enum-types.ll
  llvm/test/DebugInfo/Generic/incorrect-variable-debugloc.ll
  llvm/test/DebugInfo/Generic/namespace.ll
  llvm/test/DebugInfo/Generic/varargs.ll
  llvm/test/DebugInfo/MIR/AArch64/implicit-def-dead-scope.mir
  llvm/test/DebugInfo/NVPTX/debug-addr-class.ll
  llvm/test/DebugInfo/NVPTX/debug-info.ll
  llvm/test/DebugInfo/NVPTX/debug-loc-offset.ll
  llvm/test/DebugInfo/PowerPC/strict-dwarf.ll
  llvm/test/DebugInfo/X86/2011-09-26-GlobalVarContext.ll
  llvm/test/DebugInfo/X86/DW_AT_calling-convention.ll
  llvm/test/DebugInfo/X86/align_cpp11.ll
  llvm/test/DebugInfo/X86/align_objc.ll
  llvm/test/DebugInfo/X86/arange-and-stub.ll
  llvm/test/DebugInfo/X86/containing-type-extension-rust.ll
  llvm/test/DebugInfo/X86/debug-info-access.ll
  llvm/test/DebugInfo/X86/debug-info-blocks.ll
  llvm/test/DebugInfo/X86/debug-info-static-member.ll
  llvm/test/DebugInfo/X86/debug-loc-offset.mir
  llvm/test/DebugInfo/X86/dwarf-aranges.ll
  llvm/test/DebugInfo/X86/dwarf-linkage-names.ll
  llvm/test/DebugInfo/X86/dwarfdump-DIImportedEntity_elements.ll
  llvm/test/DebugInfo/X86/generate-odr-hash.ll
  llvm/test/DebugInfo/X86/gnu-public-names.ll
  llvm/test/DebugInfo/X86/lexical-block-file-inline.ll
  llvm/test/DebugInfo/X86/linkage-name.ll
  llvm/test/DebugInfo/X86/namelist1.ll
  llvm/test/DebugInfo/X86/sret.ll
  llvm/test/DebugInfo/X86/subprogram-across-cus.ll
  llvm/test/DebugInfo/X86/template.ll
  llvm/test/DebugInfo/X86/tls.ll
  llvm/test/DebugInfo/X86/vla-global.ll
  llvm/test/DebugInfo/attr-btf_tag.ll
  llvm/test/MC/WebAssembly/debug-info.ll
  llvm/test/MC/WebAssembly/debug-info64.ll
  llvm/test/MC/WebAssembly/dwarfdump.ll
  llvm/test/MC/WebAssembly/dwarfdump64.ll



More information about the llvm-commits mailing list