[PATCH] D97311: [DebugInfo] Introduce DIConstant metadata for representing named constants

Adrian Prantl via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 26 10:31:42 PST 2021


aprantl added a comment.

Here's an example that seems to work:

  source_filename = "globalconst.c"
  target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
  target triple = "x86_64-apple-macosx10.13.0"
  
  !llvm.dbg.cu = !{!2}
  !llvm.module.flags = !{!10, !11, !12, !13}
  
  !2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5)
  !3 = !DIFile(filename: "globalconst.c", directory: "/")
  !4 = !{}
  !5 = !{!16}
  !7 = distinct !DIGlobalVariable(name: "constant", scope: !2, file: !3, line: 2, type: !8, isLocal: false, isDefinition: true)
  !8 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !9, size: 64)
  !9 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
  !10 = !{i32 2, !"Dwarf Version", i32 4}
  !11 = !{i32 2, !"Debug Info Version", i32 3}
  !12 = !{i32 1, !"wchar_size", i32 4}
  !13 = !{i32 7, !"PIC Level", i32 2}
  !16 = !DIGlobalVariableExpression(var: !7, expr: !DIExpression(DW_OP_constu, 1, DW_OP_stack_value))



  $ bin/llc -filetype=obj /tmp/globalconst.ll -o - | dwarfdump -
  0x0000001e:   DW_TAG_variable
                  DW_AT_name	("constant")
                  DW_AT_type	(0x0000002a "int*")
                  DW_AT_external	(true)
                  DW_AT_decl_file	("globalconst.c")
                  DW_AT_decl_line	(2)
                  DW_AT_const_value	(1)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97311



More information about the llvm-commits mailing list