|
| 1 | +# REQUIRES: x86-registered-target |
| 2 | + |
| 3 | +# Test that DWARF tombstones are correctly detected/respected in wasm |
| 4 | +# 32 bit object files. |
| 5 | + |
| 6 | +# The test case was produced by the following steps: |
| 7 | +# |
| 8 | +# // test-clang.cpp |
| 9 | +# void foo() { |
| 10 | +# } |
| 11 | +# |
| 12 | +# 1) clang --target=wasm32 -S -g test-clang.cpp |
| 13 | +# -o Inputs/wasm-32bit-tombstone.s |
| 14 | +# |
| 15 | +# 2) Creating a single function, tombstoning it in the assembly, by |
| 16 | +# manually changing the DW_AT_low_pc for the DW_TAG_subprogram: |
| 17 | +# .Lfunc_begin0 to 0xffffffff to mark the function as dead code: |
| 18 | +# |
| 19 | +# .int8 2 # Abbrev [2] 0x26:0x1b DW_TAG_subprogram |
| 20 | +# .int32 .Lfunc_begin0 # DW_AT_low_pc <--------- |
| 21 | +# .int32 .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc |
| 22 | + |
| 23 | +# .int8 2 # Abbrev [2] 0x26:0x1b DW_TAG_subprogram |
| 24 | +# .int32 0xffffffff # DW_AT_low_pc <--------- |
| 25 | +# .int32 .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc |
| 26 | + |
| 27 | +# RUN: llvm-mc -arch=wasm32 -filetype=obj \ |
| 28 | +# RUN: %p/wasm-32bit-tombstone.s \ |
| 29 | +# RUN: -o %t.wasm-32bit-tombstone.wasm |
| 30 | + |
| 31 | +# RUN: llvm-debuginfo-analyzer --select-elements=Discarded \ |
| 32 | +# RUN: --print=elements \ |
| 33 | +# RUN: %t.wasm-32bit-tombstone.wasm 2>&1 | \ |
| 34 | +# RUN: FileCheck --strict-whitespace -check-prefix=ONE %s |
| 35 | + |
| 36 | +# ONE: Logical View: |
| 37 | +# ONE-NEXT: {File} '{{.*}}wasm-32bit-tombstone.wasm' |
| 38 | +# ONE-EMPTY: |
| 39 | +# ONE-NEXT: {CompileUnit} 'test-clang.cpp' |
| 40 | +# ONE-NEXT: {Function} not_inlined 'foo' -> 'void' |
| 41 | + |
| 42 | +# RUN: llvm-dwarfdump --debug-info %t.wasm-32bit-tombstone.wasm | \ |
| 43 | +# RUN: FileCheck %s --check-prefix=TWO |
| 44 | + |
| 45 | +# TWO: DW_TAG_subprogram |
| 46 | +# TWO-NEXT: DW_AT_low_pc (dead code) |
| 47 | +# TWO-NEXT: DW_AT_high_pc |
| 48 | +# TWO-NEXT: DW_AT_name ("foo") |
| 49 | + |
| 50 | + .text |
| 51 | + .file "test-clang.cpp" |
| 52 | + .functype _Z3foov () -> () |
| 53 | + .section .text._Z3foov,"",@ |
| 54 | +_Z3foov: # @_Z3foov |
| 55 | +.Lfunc_begin0: |
| 56 | + .functype _Z3foov () -> () |
| 57 | + return |
| 58 | + end_function |
| 59 | +.Lfunc_end0: |
| 60 | + # -- End function |
| 61 | + .section .debug_abbrev,"",@ |
| 62 | + .int8 1 # Abbreviation Code |
| 63 | + .int8 17 # DW_TAG_compile_unit |
| 64 | + .int8 1 # DW_CHILDREN_yes |
| 65 | + .int8 3 # DW_AT_name |
| 66 | + .int8 14 # DW_FORM_strp |
| 67 | + .int8 17 # DW_AT_low_pc |
| 68 | + .int8 1 # DW_FORM_addr |
| 69 | + .int8 18 # DW_AT_high_pc |
| 70 | + .int8 6 # DW_FORM_data4 |
| 71 | + .int8 0 # EOM(1) |
| 72 | + .int8 0 # EOM(2) |
| 73 | + .int8 2 # Abbreviation Code |
| 74 | + .int8 46 # DW_TAG_subprogram |
| 75 | + .int8 0 # DW_CHILDREN_no |
| 76 | + .int8 17 # DW_AT_low_pc |
| 77 | + .int8 1 # DW_FORM_addr |
| 78 | + .int8 18 # DW_AT_high_pc |
| 79 | + .int8 6 # DW_FORM_data4 |
| 80 | + .int8 3 # DW_AT_name |
| 81 | + .int8 14 # DW_FORM_strp |
| 82 | + .int8 0 # EOM(1) |
| 83 | + .int8 0 # EOM(2) |
| 84 | + .int8 0 # EOM(3) |
| 85 | + .section .debug_info,"",@ |
| 86 | +.Lcu_begin0: |
| 87 | + .int32 .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit |
| 88 | +.Ldebug_info_start0: |
| 89 | + .int16 4 # DWARF version number |
| 90 | + .int32 .debug_abbrev0 # Offset Into Abbrev. Section |
| 91 | + .int8 4 # Address Size (in bytes) |
| 92 | + .int8 1 # Abbrev [1] 0xb:0x37 DW_TAG_compile_unit |
| 93 | + .int32 .Linfo_string1 # DW_AT_name |
| 94 | + .int32 .Lfunc_begin0 # DW_AT_low_pc |
| 95 | + .int32 .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc |
| 96 | + .int8 2 # Abbrev [2] 0x26:0x1b DW_TAG_subprogram |
| 97 | + .int32 0xffffffff # DW_AT_low_pc |
| 98 | + .int32 .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc |
| 99 | + .int32 .Linfo_string4 # DW_AT_name |
| 100 | + .int8 0 # End Of Children Mark |
| 101 | +.Ldebug_info_end0: |
| 102 | + .section .debug_str,"S",@ |
| 103 | +.Linfo_string1: |
| 104 | + .asciz "test-clang.cpp" # string offset=176 |
| 105 | +.Linfo_string4: |
| 106 | + .asciz "foo" # string offset=241 |
| 107 | + .ident "clang version 19.0.0" |
0 commit comments