RFC https://discourse.llvm.org/t/rfc-dwarfdebug-fix-and-improve-handling-imported-entities-types-and-static-local-in-subprogram-and-lexical-block-scopes/68544 This patch moves the emission of global variables from `DwarfDebug::beginModule()` to `DwarfDebug::endModule()`. It has the following effects: 1. The order of debug entities in the resulting DWARF changes. 2. Currently, if a DISubprogram requires emission of both concrete out-of-line and inlined subprogram DIEs, and such a subprogram contains a static local variable, the DIE for the variable is emitted into the concrete out-of-line subprogram DIE. As a result, the variable is not available in debugger when breaking at the inlined function instance. It happens because static locals are emitted in `DwarfDebug::beginModule()`, but abstract DIEs for functions that are not completely inlined away are created only later during `DwarfDebug::endFunctionImpl()` calls. With this patch, DIEs for static local variables of subprograms that have both inlined and the concrete out-of-line instances are placed into abstract subprogram DIEs. They become visible in debugger when breaking at concrete out-of-line and inlined function instances. `llvm/test/DebugInfo/Generic/inlined-static-var.ll` illustrates that. 3. It will allow to simplify abstract subprogram DIEs creation by reverting https://github.com/llvm/llvm-project/pull/159104 later. This is needed to simplify DWARF emission in a context of proper support of function-local static variables which comes in the next patch (https://reviews.llvm.org/D144008), making all function-local entities handled in `DwarfDebug::endModuleImpl()`. Authored-by: Kristina Bessonova <kbessonova@accesssoftek.com> Co-authored-by: David Blaikie <dblaikie@gmail.com> Co-authored-by: Vladislav Dzhidzhoev <vdzhidzhoev@accesssoftek.com>
91 lines
3.6 KiB
Plaintext
91 lines
3.6 KiB
Plaintext
RUN: llc -filetype=obj %p/Inputs/debuginfo1.ll -o %t.debuginfo1.o
|
|
RUN: llc -filetype=obj %p/Inputs/debuginfo2.ll -o %t.debuginfo2.o
|
|
RUN: wasm-ld -o %t.wasm %t.debuginfo1.o %t.debuginfo2.o
|
|
RUN: llvm-dwarfdump %t.wasm | FileCheck %s
|
|
|
|
CHECK: file format WASM
|
|
|
|
CHECK: .debug_info contents:
|
|
CHECK: DW_TAG_compile_unit
|
|
CHECK-NEXT: DW_AT_producer ("clang version 7.0.0 (trunk {{.*}})")
|
|
CHECK-NEXT: DW_AT_language (DW_LANG_C99)
|
|
CHECK-NEXT: DW_AT_name ("hi.c")
|
|
|
|
CHECK: DW_TAG_subprogram
|
|
CHECK-NEXT: DW_AT_low_pc
|
|
CHECK-NEXT: DW_AT_high_pc
|
|
CHECK-NEXT: DW_AT_frame_base
|
|
CHECK-NEXT: DW_AT_name ("test")
|
|
CHECK-NEXT: DW_AT_decl_file ("/Users/yury/llvmwasm{{(/|\\)}}hi.c")
|
|
CHECK-NEXT: DW_AT_decl_line (3)
|
|
CHECK-NEXT: DW_AT_prototyped (true)
|
|
|
|
CHECK: DW_TAG_formal_parameter
|
|
CHECK-NEXT: DW_AT_location (DW_OP_WASM_location 0x0 0x0, DW_OP_stack_value)
|
|
CHECK-NEXT: DW_AT_name ("t")
|
|
CHECK-NEXT: DW_AT_decl_file ("/Users/yury/llvmwasm{{(/|\\)}}hi.c")
|
|
CHECK-NEXT: DW_AT_decl_line (3)
|
|
|
|
CHECK: DW_TAG_subprogram
|
|
CHECK-NEXT: DW_AT_low_pc
|
|
CHECK-NEXT: DW_AT_high_pc
|
|
CHECK-NEXT: DW_AT_frame_base
|
|
CHECK-NEXT: DW_AT_name ("_start")
|
|
CHECK-NEXT: DW_AT_decl_file ("/Users/yury/llvmwasm{{(/|\\)}}hi.c")
|
|
CHECK-NEXT: DW_AT_decl_line (7)
|
|
|
|
CHECK: DW_TAG_base_type
|
|
CHECK-NEXT: DW_AT_name ("int")
|
|
CHECK-NEXT: DW_AT_encoding (DW_ATE_signed)
|
|
CHECK-NEXT: DW_AT_byte_size (0x04)
|
|
|
|
CHECK: DW_TAG_compile_unit
|
|
CHECK-NEXT: DW_AT_producer ("clang version 7.0.0 (trunk {{.*}})")
|
|
CHECK-NEXT: DW_AT_language (DW_LANG_C99)
|
|
CHECK-NEXT: DW_AT_name ("hi_foo.c")
|
|
|
|
CHECK: DW_TAG_subprogram
|
|
CHECK-NEXT: DW_AT_low_pc
|
|
CHECK-NEXT: DW_AT_high_pc
|
|
CHECK-NEXT: DW_AT_frame_base
|
|
CHECK-NEXT: DW_AT_name ("foo")
|
|
CHECK-NEXT: DW_AT_decl_file ("{{.*}}hi_foo.c")
|
|
CHECK-NEXT: DW_AT_decl_line (3)
|
|
|
|
CHECK: DW_TAG_formal_parameter
|
|
CHECK-NEXT: DW_AT_location (DW_OP_WASM_location 0x0 0x0, DW_OP_stack_value)
|
|
CHECK-NEXT: DW_AT_name ("p")
|
|
CHECK-NEXT: DW_AT_decl_file ("{{.*}}hi_foo.c")
|
|
CHECK-NEXT: DW_AT_decl_line (3)
|
|
|
|
CHECK: DW_TAG_variable
|
|
CHECK-NEXT: DW_AT_name ("y")
|
|
CHECK-NEXT: DW_AT_type (0x000000d4 "int[2]")
|
|
CHECK-NEXT: DW_AT_external (true)
|
|
CHECK-NEXT: DW_AT_decl_file ("{{.*}}hi_foo.c")
|
|
CHECK-NEXT: DW_AT_decl_line (1)
|
|
CHECK: DW_AT_location (DW_OP_addr 0x10000)
|
|
|
|
CHECK: DW_TAG_array_type
|
|
|
|
CHECK: DW_TAG_subrange_type
|
|
|
|
CHECK: DW_TAG_base_type
|
|
CHECK-NEXT: DW_AT_name ("int")
|
|
CHECK-NEXT: DW_AT_encoding (DW_ATE_signed)
|
|
CHECK-NEXT: DW_AT_byte_size (0x04)
|
|
|
|
CHECK: DW_TAG_base_type
|
|
CHECK-NEXT: DW_AT_name ("__ARRAY_SIZE_TYPE__")
|
|
CHECK-NEXT: DW_AT_byte_size (0x08)
|
|
CHECK-NEXT: DW_AT_encoding (DW_ATE_unsigned)
|
|
|
|
CHECK: DW_TAG_variable
|
|
CHECK-NEXT: DW_AT_name ("z")
|
|
CHECK-NEXT: DW_AT_type (0x000000d4 "int[2]")
|
|
CHECK-NEXT: DW_AT_external (true)
|
|
CHECK-NEXT: DW_AT_decl_file ("{{.*}}hi_foo.c")
|
|
CHECK-NEXT: DW_AT_decl_line (8)
|
|
CHECK-NEXT: DW_AT_location (DW_OP_addr 0xffffffff)
|
|
|