[PATCH] D155818: [CloneFunction][DebugInfo] Clone DISubprogram's local types

Vladislav Dzhidzhoev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 1 04:56:12 PDT 2023


dzhidzhoev added a comment.

  enum my_enum { AA, AB, AC } e;
  int main() {
    enum my_local_enum { A, B, C };
    return 0;
  }

This example can be compiled with the flag `-fno-eliminate-unused-debug-types` :

  bin/clang local-retained.c -c -fno-eliminate-unused-debug-types -O0 -g -emit-llvm

That's what metadata looks like:

  !2 = distinct !DICompileUnit(language: DW_LANG_C11, file: !3, retainedTypes: !11 ...
  !5 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "my_enum", ...
  !11 = !{!5, !12}
  !12 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "my_local_enum", scope: !13, ...
  !13 = distinct !DISubprogram(name: "main", retainedNodes: !17, ...
  !17 = !{!12}

Here `my_local_enum`, which is local to the subprogram, is referenced by both CU and Subprogram. I haven't encountered such a situation in real-world metadata since I haven't got much experience dealing with DebugInfo.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D155818/new/

https://reviews.llvm.org/D155818



More information about the llvm-commits mailing list