llvm/lld/test/wasm/debuginfo.test

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)