llvm-project/lld/test/wasm/debuginfo.test
Wouter van Oortmerssen 5c38ae36c5 [WebAssembly] Fixed byval args missing DWARF DW_AT_LOCATION
A struct in C passed by value did not get debug information. Such values are currently
lowered to a Wasm local even in -O0 (not to an alloca like on other archs), which becomes
a Target Index operand (TI_LOCAL). The DWARF writing code was not emitting locations
in for TI's specifically if the location is a single range (not a list).

In addition, the ExplicitLocals pass which removes the ARGUMENT pseudo instructions did
not update the associated DBG_VALUEs, and couldn't even find these values since the code
assumed such instructions are adjacent, which is not the case here.

Also fixed asm printing of TIs needed by a test.

Differential Revision: https://reviews.llvm.org/D94140
2021-01-07 10:31:38 -08:00

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_variable
CHECK-NEXT: DW_AT_name ("y")
CHECK-NEXT: DW_AT_type (0x000000ac "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 0x400)
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 (0x000000ac "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)
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)