[lld] [lld][WebAssembly] Return 0 for synthetic function offsets (PR #96134)

Heejin Ahn via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 20 00:41:05 PDT 2024


https://github.com/aheejin updated https://github.com/llvm/llvm-project/pull/96134

>From d5ba71ee8431cad2fc8bd9bc2dddf6da805f75a7 Mon Sep 17 00:00:00 2001
From: Heejin Ahn <aheejin at gmail.com>
Date: Thu, 20 Jun 2024 01:36:20 +0000
Subject: [PATCH 01/10] [lld][WebAssembly] Return 0 for synthetic function
 offsets

When two or more functions' signatures differ, one of them is selected
and for other signatures `unreachable` stubs are generated:
https://github.com/llvm/llvm-project/blob/57778ec36c9c7e96b76a167f19dccbe00d49c9d4/lld/wasm/SymbolTable.cpp#L975
https://github.com/llvm/llvm-project/blob/57778ec36c9c7e96b76a167f19dccbe00d49c9d4/lld/wasm/SymbolTable.cpp#L852-L870

And when these `SyntheticFunction`s are generated, this constructor is
used,
https://github.com/llvm/llvm-project/blob/57778ec36c9c7e96b76a167f19dccbe00d49c9d4/lld/wasm/InputChunks.h#L266-L269
which does not set its `function` field:
https://github.com/llvm/llvm-project/blob/57778ec36c9c7e96b76a167f19dccbe00d49c9d4/lld/wasm/InputChunks.h#L304
As a result, the `function` field contains a garbage value for these
stub functions.

`InputFunction::getFunctionCodeOffset()` is called when relocations are
resolved for `.debug_info` section to get functions' PC locations. But
because these stub functions don't have their `function` field set, this
function segfaults:
https://github.com/llvm/llvm-project/blob/57778ec36c9c7e96b76a167f19dccbe00d49c9d4/lld/wasm/InputChunks.h#L282

This PR initializes the field with `nullptr`, and in
`InputFunction::getFunctionCodeOffset`, checks if `function` is
`nullptr`, and if so, just returns 0. This function is called only for
resolving relocations in the `.debug_info` section, and addresses of
these stub functions, which are not the functions users wrote in the
first place, are not really meaningful anyway.
---
 .../Inputs/signature-mismatch-debug-info-a.ll | 31 +++++++++++++++++++
 .../Inputs/signature-mismatch-debug-info-b.ll | 31 +++++++++++++++++++
 .../signature-mismatch-debug-info-main.ll     | 30 ++++++++++++++++++
 .../wasm/signature-mismatch-debug-info.test   |  8 +++++
 lld/wasm/InputChunks.h                        | 11 +++++--
 5 files changed, 109 insertions(+), 2 deletions(-)
 create mode 100644 lld/test/wasm/Inputs/signature-mismatch-debug-info-a.ll
 create mode 100644 lld/test/wasm/Inputs/signature-mismatch-debug-info-b.ll
 create mode 100644 lld/test/wasm/Inputs/signature-mismatch-debug-info-main.ll
 create mode 100644 lld/test/wasm/signature-mismatch-debug-info.test

diff --git a/lld/test/wasm/Inputs/signature-mismatch-debug-info-a.ll b/lld/test/wasm/Inputs/signature-mismatch-debug-info-a.ll
new file mode 100644
index 0000000000000..9ebc5c4b9c922
--- /dev/null
+++ b/lld/test/wasm/Inputs/signature-mismatch-debug-info-a.ll
@@ -0,0 +1,31 @@
+target triple = "wasm32-unknown-emscripten"
+
+define void @foo(i32 %a) !dbg !6 {
+  ret void
+}
+
+define void @test0() !dbg !10 {
+entry:
+  call void @foo(i32 3), !dbg !13
+  ret void, !dbg !14
+}
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!2, !3, !4}
+!llvm.ident = !{!5}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C11, file: !1, producer: "clang version 19.0.0git", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None)
+!1 = !DIFile(filename: "a.c", directory: "")
+!2 = !{i32 7, !"Dwarf Version", i32 4}
+!3 = !{i32 2, !"Debug Info Version", i32 3}
+!4 = !{i32 1, !"wchar_size", i32 4}
+!5 = !{!"clang version 19.0.0git"}
+!6 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 3, type: !7, scopeLine: 3, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0)
+!7 = !DISubroutineType(types: !8)
+!8 = !{null, !9}
+!9 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!10 = distinct !DISubprogram(name: "test0", scope: !1, file: !1, line: 7, type: !11, scopeLine: 7, spFlags: DISPFlagDefinition, unit: !0)
+!11 = !DISubroutineType(types: !12)
+!12 = !{null}
+!13 = !DILocation(line: 8, column: 3, scope: !10)
+!14 = !DILocation(line: 9, column: 1, scope: !10)
diff --git a/lld/test/wasm/Inputs/signature-mismatch-debug-info-b.ll b/lld/test/wasm/Inputs/signature-mismatch-debug-info-b.ll
new file mode 100644
index 0000000000000..7b8295363c802
--- /dev/null
+++ b/lld/test/wasm/Inputs/signature-mismatch-debug-info-b.ll
@@ -0,0 +1,31 @@
+target triple = "wasm32-unknown-emscripten"
+
+define void @foo(i32 %a, i32 %b) !dbg !6 {
+  ret void
+}
+
+define void @test1() !dbg !10 {
+entry:
+  call void @foo(i32 4, i32 5), !dbg !13
+  ret void, !dbg !14
+}
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!2, !3, !4}
+!llvm.ident = !{!5}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C11, file: !1, producer: "clang version 19.0.0git", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None)
+!1 = !DIFile(filename: "b.c", directory: "")
+!2 = !{i32 7, !"Dwarf Version", i32 4}
+!3 = !{i32 2, !"Debug Info Version", i32 3}
+!4 = !{i32 1, !"wchar_size", i32 4}
+!5 = !{!"clang version 19.0.0git"}
+!6 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 3, type: !7, scopeLine: 3, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0)
+!7 = !DISubroutineType(types: !8)
+!8 = !{null, !9, !9}
+!9 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!10 = distinct !DISubprogram(name: "test1", scope: !1, file: !1, line: 7, type: !11, scopeLine: 7, spFlags: DISPFlagDefinition, unit: !0)
+!11 = !DISubroutineType(types: !12)
+!12 = !{null}
+!13 = !DILocation(line: 8, column: 3, scope: !10)
+!14 = !DILocation(line: 9, column: 1, scope: !10)
diff --git a/lld/test/wasm/Inputs/signature-mismatch-debug-info-main.ll b/lld/test/wasm/Inputs/signature-mismatch-debug-info-main.ll
new file mode 100644
index 0000000000000..3d2f8c2e0a941
--- /dev/null
+++ b/lld/test/wasm/Inputs/signature-mismatch-debug-info-main.ll
@@ -0,0 +1,30 @@
+target triple = "wasm32-unknown-emscripten"
+
+define i32 @main() !dbg !6 {
+entry:
+  call void @test0(), !dbg !10
+  call void @test1(), !dbg !11
+  ret i32 0, !dbg !12
+}
+
+declare void @test0()
+
+declare void @test1()
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!2, !3, !4}
+!llvm.ident = !{!5}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C11, file: !1, producer: "clang version 19.0.0git", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None)
+!1 = !DIFile(filename: "main.c", directory: "")
+!2 = !{i32 7, !"Dwarf Version", i32 4}
+!3 = !{i32 2, !"Debug Info Version", i32 3}
+!4 = !{i32 1, !"wchar_size", i32 4}
+!5 = !{!"clang version 19.0.0git"}
+!6 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 4, type: !7, scopeLine: 4, spFlags: DISPFlagDefinition, unit: !0)
+!7 = !DISubroutineType(types: !8)
+!8 = !{!9}
+!9 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!10 = !DILocation(line: 5, column: 3, scope: !6)
+!11 = !DILocation(line: 6, column: 3, scope: !6)
+!12 = !DILocation(line: 7, column: 3, scope: !6)
diff --git a/lld/test/wasm/signature-mismatch-debug-info.test b/lld/test/wasm/signature-mismatch-debug-info.test
new file mode 100644
index 0000000000000..fe1e8c2dbe579
--- /dev/null
+++ b/lld/test/wasm/signature-mismatch-debug-info.test
@@ -0,0 +1,8 @@
+# This is a regression test that checks whether a function signature mismatch
+# in functions with debug info does not cause does not cause a segmentation
+# fault when writing .debug_info section.
+
+; RUN: llc -filetype=obj %p/Inputs/signature-mismatch-debug-info-a.ll -o %t.a.o
+; RUN: llc -filetype=obj %p/Inputs/signature-mismatch-debug-info-b.ll -o %t.b.o
+; RUN: llc -filetype=obj %p/Inputs/signature-mismatch-debug-info-main.ll -o %t.main.o
+; RUN: wasm-ld -o %t.wasm %t.a.o %t.b.o %t.main.o --export=main --no-entry
diff --git a/lld/wasm/InputChunks.h b/lld/wasm/InputChunks.h
index cf8a5249b19a0..5174439facc67 100644
--- a/lld/wasm/InputChunks.h
+++ b/lld/wasm/InputChunks.h
@@ -279,7 +279,14 @@ class InputFunction : public InputChunk {
   }
   void setExportName(std::string exportName) { this->exportName = exportName; }
   uint32_t getFunctionInputOffset() const { return getInputSectionOffset(); }
-  uint32_t getFunctionCodeOffset() const { return function->CodeOffset; }
+  uint32_t getFunctionCodeOffset() const {
+    // For generated synthetic functions, such as unreachable stubs generated
+    // for signature mismatches, 'function' reference does not exist. This
+    // function is used to get function offsets for .debug_info section, and for
+    // those generated stubs function offsets are not meaningful anyway. So just
+    // return 0 in those cases.
+    return function ? function->CodeOffset : 0;
+  }
   uint32_t getFunctionIndex() const { return *functionIndex; }
   bool hasFunctionIndex() const { return functionIndex.has_value(); }
   void setFunctionIndex(uint32_t index);
@@ -301,7 +308,7 @@ class InputFunction : public InputChunk {
     return compressedSize;
   }
 
-  const WasmFunction *function;
+  const WasmFunction *function = nullptr;
 
 protected:
   std::optional<std::string> exportName;

>From f463f91c2ec23750179ebd67a9b662247eda99dc Mon Sep 17 00:00:00 2001
From: Heejin Ahn <aheejin at gmail.com>
Date: Thu, 20 Jun 2024 02:47:29 +0000
Subject: [PATCH 02/10] Remove `entry`

---
 lld/test/wasm/Inputs/signature-mismatch-debug-info-a.ll    | 1 -
 lld/test/wasm/Inputs/signature-mismatch-debug-info-b.ll    | 1 -
 lld/test/wasm/Inputs/signature-mismatch-debug-info-main.ll | 2 --
 3 files changed, 4 deletions(-)

diff --git a/lld/test/wasm/Inputs/signature-mismatch-debug-info-a.ll b/lld/test/wasm/Inputs/signature-mismatch-debug-info-a.ll
index 9ebc5c4b9c922..220a2903b24bd 100644
--- a/lld/test/wasm/Inputs/signature-mismatch-debug-info-a.ll
+++ b/lld/test/wasm/Inputs/signature-mismatch-debug-info-a.ll
@@ -5,7 +5,6 @@ define void @foo(i32 %a) !dbg !6 {
 }
 
 define void @test0() !dbg !10 {
-entry:
   call void @foo(i32 3), !dbg !13
   ret void, !dbg !14
 }
diff --git a/lld/test/wasm/Inputs/signature-mismatch-debug-info-b.ll b/lld/test/wasm/Inputs/signature-mismatch-debug-info-b.ll
index 7b8295363c802..55e3f27aec89a 100644
--- a/lld/test/wasm/Inputs/signature-mismatch-debug-info-b.ll
+++ b/lld/test/wasm/Inputs/signature-mismatch-debug-info-b.ll
@@ -5,7 +5,6 @@ define void @foo(i32 %a, i32 %b) !dbg !6 {
 }
 
 define void @test1() !dbg !10 {
-entry:
   call void @foo(i32 4, i32 5), !dbg !13
   ret void, !dbg !14
 }
diff --git a/lld/test/wasm/Inputs/signature-mismatch-debug-info-main.ll b/lld/test/wasm/Inputs/signature-mismatch-debug-info-main.ll
index 3d2f8c2e0a941..78df815bce225 100644
--- a/lld/test/wasm/Inputs/signature-mismatch-debug-info-main.ll
+++ b/lld/test/wasm/Inputs/signature-mismatch-debug-info-main.ll
@@ -1,14 +1,12 @@
 target triple = "wasm32-unknown-emscripten"
 
 define i32 @main() !dbg !6 {
-entry:
   call void @test0(), !dbg !10
   call void @test1(), !dbg !11
   ret i32 0, !dbg !12
 }
 
 declare void @test0()
-
 declare void @test1()
 
 !llvm.dbg.cu = !{!0}

>From 88a48b217392315a159a3fa413e8357fc0c9d993 Mon Sep 17 00:00:00 2001
From: Heejin Ahn <aheejin at gmail.com>
Date: Thu, 20 Jun 2024 06:36:31 +0000
Subject: [PATCH 03/10] Add 'weak' linkage to duplicate functions

---
 lld/test/wasm/Inputs/signature-mismatch-debug-info-a.ll | 2 +-
 lld/test/wasm/Inputs/signature-mismatch-debug-info-b.ll | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/lld/test/wasm/Inputs/signature-mismatch-debug-info-a.ll b/lld/test/wasm/Inputs/signature-mismatch-debug-info-a.ll
index 220a2903b24bd..3e864022db9e7 100644
--- a/lld/test/wasm/Inputs/signature-mismatch-debug-info-a.ll
+++ b/lld/test/wasm/Inputs/signature-mismatch-debug-info-a.ll
@@ -1,6 +1,6 @@
 target triple = "wasm32-unknown-emscripten"
 
-define void @foo(i32 %a) !dbg !6 {
+define weak void @foo(i32 %a) !dbg !6 {
   ret void
 }
 
diff --git a/lld/test/wasm/Inputs/signature-mismatch-debug-info-b.ll b/lld/test/wasm/Inputs/signature-mismatch-debug-info-b.ll
index 55e3f27aec89a..562f0514d30c3 100644
--- a/lld/test/wasm/Inputs/signature-mismatch-debug-info-b.ll
+++ b/lld/test/wasm/Inputs/signature-mismatch-debug-info-b.ll
@@ -1,6 +1,6 @@
 target triple = "wasm32-unknown-emscripten"
 
-define void @foo(i32 %a, i32 %b) !dbg !6 {
+define weak void @foo(i32 %a, i32 %b) !dbg !6 {
   ret void
 }
 

>From ea4eb9aa7ee129f08b16d9813f2e90cc2f86f709 Mon Sep 17 00:00:00 2001
From: Heejin Ahn <aheejin at gmail.com>
Date: Thu, 20 Jun 2024 06:38:31 +0000
Subject: [PATCH 04/10] Remove DILocations

---
 lld/test/wasm/Inputs/signature-mismatch-debug-info-a.ll  | 6 ++----
 lld/test/wasm/Inputs/signature-mismatch-debug-info-b.ll  | 6 ++----
 .../wasm/Inputs/signature-mismatch-debug-info-main.ll    | 9 +++------
 3 files changed, 7 insertions(+), 14 deletions(-)

diff --git a/lld/test/wasm/Inputs/signature-mismatch-debug-info-a.ll b/lld/test/wasm/Inputs/signature-mismatch-debug-info-a.ll
index 3e864022db9e7..050b0f2baa2d5 100644
--- a/lld/test/wasm/Inputs/signature-mismatch-debug-info-a.ll
+++ b/lld/test/wasm/Inputs/signature-mismatch-debug-info-a.ll
@@ -5,8 +5,8 @@ define weak void @foo(i32 %a) !dbg !6 {
 }
 
 define void @test0() !dbg !10 {
-  call void @foo(i32 3), !dbg !13
-  ret void, !dbg !14
+  call void @foo(i32 3)
+  ret void
 }
 
 !llvm.dbg.cu = !{!0}
@@ -26,5 +26,3 @@ define void @test0() !dbg !10 {
 !10 = distinct !DISubprogram(name: "test0", scope: !1, file: !1, line: 7, type: !11, scopeLine: 7, spFlags: DISPFlagDefinition, unit: !0)
 !11 = !DISubroutineType(types: !12)
 !12 = !{null}
-!13 = !DILocation(line: 8, column: 3, scope: !10)
-!14 = !DILocation(line: 9, column: 1, scope: !10)
diff --git a/lld/test/wasm/Inputs/signature-mismatch-debug-info-b.ll b/lld/test/wasm/Inputs/signature-mismatch-debug-info-b.ll
index 562f0514d30c3..4e9e57205d7a9 100644
--- a/lld/test/wasm/Inputs/signature-mismatch-debug-info-b.ll
+++ b/lld/test/wasm/Inputs/signature-mismatch-debug-info-b.ll
@@ -5,8 +5,8 @@ define weak void @foo(i32 %a, i32 %b) !dbg !6 {
 }
 
 define void @test1() !dbg !10 {
-  call void @foo(i32 4, i32 5), !dbg !13
-  ret void, !dbg !14
+  call void @foo(i32 4, i32 5)
+  ret void
 }
 
 !llvm.dbg.cu = !{!0}
@@ -26,5 +26,3 @@ define void @test1() !dbg !10 {
 !10 = distinct !DISubprogram(name: "test1", scope: !1, file: !1, line: 7, type: !11, scopeLine: 7, spFlags: DISPFlagDefinition, unit: !0)
 !11 = !DISubroutineType(types: !12)
 !12 = !{null}
-!13 = !DILocation(line: 8, column: 3, scope: !10)
-!14 = !DILocation(line: 9, column: 1, scope: !10)
diff --git a/lld/test/wasm/Inputs/signature-mismatch-debug-info-main.ll b/lld/test/wasm/Inputs/signature-mismatch-debug-info-main.ll
index 78df815bce225..f929e0d6e55f2 100644
--- a/lld/test/wasm/Inputs/signature-mismatch-debug-info-main.ll
+++ b/lld/test/wasm/Inputs/signature-mismatch-debug-info-main.ll
@@ -1,9 +1,9 @@
 target triple = "wasm32-unknown-emscripten"
 
 define i32 @main() !dbg !6 {
-  call void @test0(), !dbg !10
-  call void @test1(), !dbg !11
-  ret i32 0, !dbg !12
+  call void @test0()
+  call void @test1()
+  ret i32 0
 }
 
 declare void @test0()
@@ -23,6 +23,3 @@ declare void @test1()
 !7 = !DISubroutineType(types: !8)
 !8 = !{!9}
 !9 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
-!10 = !DILocation(line: 5, column: 3, scope: !6)
-!11 = !DILocation(line: 6, column: 3, scope: !6)
-!12 = !DILocation(line: 7, column: 3, scope: !6)

>From 6f7d8cd358c1ab130f4ed25740b64e8bb26561f4 Mon Sep 17 00:00:00 2001
From: Heejin Ahn <aheejin at gmail.com>
Date: Thu, 20 Jun 2024 06:50:10 +0000
Subject: [PATCH 05/10] Add s files

---
 .../Inputs/signature-mismatch-debug-info-a.s  | 175 +++++++++++++++++
 .../Inputs/signature-mismatch-debug-info-b.s  | 176 ++++++++++++++++++
 .../signature-mismatch-debug-info-main.s      | 155 +++++++++++++++
 .../wasm/signature-mismatch-debug-info.test   |   6 +-
 4 files changed, 509 insertions(+), 3 deletions(-)
 create mode 100644 lld/test/wasm/Inputs/signature-mismatch-debug-info-a.s
 create mode 100644 lld/test/wasm/Inputs/signature-mismatch-debug-info-b.s
 create mode 100644 lld/test/wasm/Inputs/signature-mismatch-debug-info-main.s

diff --git a/lld/test/wasm/Inputs/signature-mismatch-debug-info-a.s b/lld/test/wasm/Inputs/signature-mismatch-debug-info-a.s
new file mode 100644
index 0000000000000..4087c6c9b317c
--- /dev/null
+++ b/lld/test/wasm/Inputs/signature-mismatch-debug-info-a.s
@@ -0,0 +1,175 @@
+  .globaltype __stack_pointer, i32
+  .text
+  .file  "signature-mismatch-debug-info-a.ll"
+  .functype  foo (i32) -> ()
+  .functype  test0 () -> ()
+  .section  .text.foo,"",@
+  .weak  foo                             # -- Begin function foo
+  .type  foo, at function
+foo:                                    # @foo
+.Lfunc_begin0:
+  .functype  foo (i32) -> ()
+# %bb.0:
+                                        # fallthrough-return
+  end_function
+.Lfunc_end0:
+                                        # -- End function
+  .section  .text.test0,"",@
+  .globl  test0                           # -- Begin function test0
+  .type  test0, at function
+test0:                                  # @test0
+.Lfunc_begin1:
+  .functype  test0 () -> ()
+# %bb.0:
+  i32.const  3
+  call  foo
+                                        # fallthrough-return
+  end_function
+.Lfunc_end1:
+                                        # -- End function
+  .file  1 "a.c"
+  .section  .debug_abbrev,"",@
+  .int8  1                               # Abbreviation Code
+  .int8  17                              # DW_TAG_compile_unit
+  .int8  1                               # DW_CHILDREN_yes
+  .int8  37                              # DW_AT_producer
+  .int8  14                              # DW_FORM_strp
+  .int8  19                              # DW_AT_language
+  .int8  5                               # DW_FORM_data2
+  .int8  3                               # DW_AT_name
+  .int8  14                              # DW_FORM_strp
+  .int8  16                              # DW_AT_stmt_list
+  .int8  23                              # DW_FORM_sec_offset
+  .int8  17                              # DW_AT_low_pc
+  .int8  1                               # DW_FORM_addr
+  .int8  85                              # DW_AT_ranges
+  .int8  23                              # DW_FORM_sec_offset
+  .int8  0                               # EOM(1)
+  .int8  0                               # EOM(2)
+  .int8  2                               # Abbreviation Code
+  .int8  46                              # DW_TAG_subprogram
+  .int8  0                               # DW_CHILDREN_no
+  .int8  17                              # DW_AT_low_pc
+  .int8  1                               # DW_FORM_addr
+  .int8  18                              # DW_AT_high_pc
+  .int8  6                               # DW_FORM_data4
+  .int8  64                              # DW_AT_frame_base
+  .int8  24                              # DW_FORM_exprloc
+  .int8  3                               # DW_AT_name
+  .int8  14                              # DW_FORM_strp
+  .int8  58                              # DW_AT_decl_file
+  .int8  11                              # DW_FORM_data1
+  .int8  59                              # DW_AT_decl_line
+  .int8  11                              # DW_FORM_data1
+  .int8  39                              # DW_AT_prototyped
+  .int8  25                              # DW_FORM_flag_present
+  .int8  63                              # DW_AT_external
+  .int8  25                              # DW_FORM_flag_present
+  .int8  0                               # EOM(1)
+  .int8  0                               # EOM(2)
+  .int8  3                               # Abbreviation Code
+  .int8  46                              # DW_TAG_subprogram
+  .int8  0                               # DW_CHILDREN_no
+  .int8  17                              # DW_AT_low_pc
+  .int8  1                               # DW_FORM_addr
+  .int8  18                              # DW_AT_high_pc
+  .int8  6                               # DW_FORM_data4
+  .int8  64                              # DW_AT_frame_base
+  .int8  24                              # DW_FORM_exprloc
+  .int8  3                               # DW_AT_name
+  .int8  14                              # DW_FORM_strp
+  .int8  58                              # DW_AT_decl_file
+  .int8  11                              # DW_FORM_data1
+  .int8  59                              # DW_AT_decl_line
+  .int8  11                              # DW_FORM_data1
+  .int8  63                              # DW_AT_external
+  .int8  25                              # DW_FORM_flag_present
+  .int8  0                               # EOM(1)
+  .int8  0                               # EOM(2)
+  .int8  0                               # EOM(3)
+  .section  .debug_info,"",@
+.Lcu_begin0:
+  .int32  .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit
+.Ldebug_info_start0:
+  .int16  4                               # DWARF version number
+  .int32  .debug_abbrev0                  # Offset Into Abbrev. Section
+  .int8  4                               # Address Size (in bytes)
+  .int8  1                               # Abbrev [1] 0xb:0x46 DW_TAG_compile_unit
+  .int32  .Linfo_string0                  # DW_AT_producer
+  .int16  29                              # DW_AT_language
+  .int32  .Linfo_string1                  # DW_AT_name
+  .int32  .Lline_table_start0             # DW_AT_stmt_list
+  .int32  0                               # DW_AT_low_pc
+  .int32  .Ldebug_ranges0                 # DW_AT_ranges
+  .int8  2                               # Abbrev [2] 0x22:0x17 DW_TAG_subprogram
+  .int32  .Lfunc_begin0                   # DW_AT_low_pc
+  .int32  .Lfunc_end0-.Lfunc_begin0       # DW_AT_high_pc
+  .int8  7                               # DW_AT_frame_base
+  .int8  237
+  .int8  3
+  .int32  __stack_pointer
+  .int8  159
+  .int32  .Linfo_string2                  # DW_AT_name
+  .int8  1                               # DW_AT_decl_file
+  .int8  3                               # DW_AT_decl_line
+                                        # DW_AT_prototyped
+                                        # DW_AT_external
+  .int8  3                               # Abbrev [3] 0x39:0x17 DW_TAG_subprogram
+  .int32  .Lfunc_begin1                   # DW_AT_low_pc
+  .int32  .Lfunc_end1-.Lfunc_begin1       # DW_AT_high_pc
+  .int8  7                               # DW_AT_frame_base
+  .int8  237
+  .int8  3
+  .int32  __stack_pointer
+  .int8  159
+  .int32  .Linfo_string3                  # DW_AT_name
+  .int8  1                               # DW_AT_decl_file
+  .int8  7                               # DW_AT_decl_line
+                                        # DW_AT_external
+  .int8  0                               # End Of Children Mark
+.Ldebug_info_end0:
+  .section  .debug_ranges,"",@
+.Ldebug_ranges0:
+  .int32  .Lfunc_begin0
+  .int32  .Lfunc_end0
+  .int32  .Lfunc_begin1
+  .int32  .Lfunc_end1
+  .int32  0
+  .int32  0
+  .section  .debug_str,"S",@
+.Linfo_string0:
+  .asciz  "clang version 19.0.0git"       # string offset=0
+.Linfo_string1:
+  .asciz  "a.c"                           # string offset=24
+.Linfo_string2:
+  .asciz  "foo"                           # string offset=28
+.Linfo_string3:
+  .asciz  "test0"                         # string offset=32
+  .ident  "clang version 19.0.0git"
+  .section  .custom_section.producers,"",@
+  .int8  2
+  .int8  8
+  .ascii  "language"
+  .int8  1
+  .int8  3
+  .ascii  "C11"
+  .int8  0
+  .int8  12
+  .ascii  "processed-by"
+  .int8  1
+  .int8  5
+  .ascii  "clang"
+  .int8  9
+  .ascii  "19.0.0git"
+  .section  .debug_str,"S",@
+  .section  .custom_section.target_features,"",@
+  .int8  2
+  .int8  43
+  .int8  15
+  .ascii  "mutable-globals"
+  .int8  43
+  .int8  8
+  .ascii  "sign-ext"
+  .section  .debug_str,"S",@
+  .section  .debug_line,"",@
+.Lline_table_start0:
diff --git a/lld/test/wasm/Inputs/signature-mismatch-debug-info-b.s b/lld/test/wasm/Inputs/signature-mismatch-debug-info-b.s
new file mode 100644
index 0000000000000..746342edfff9e
--- /dev/null
+++ b/lld/test/wasm/Inputs/signature-mismatch-debug-info-b.s
@@ -0,0 +1,176 @@
+  .globaltype __stack_pointer, i32
+  .text
+  .file  "signature-mismatch-debug-info-b.ll"
+  .functype  foo (i32, i32) -> ()
+  .functype  test1 () -> ()
+  .section  .text.foo,"",@
+  .weak  foo                             # -- Begin function foo
+  .type  foo, at function
+foo:                                    # @foo
+.Lfunc_begin0:
+  .functype  foo (i32, i32) -> ()
+# %bb.0:
+                                        # fallthrough-return
+  end_function
+.Lfunc_end0:
+                                        # -- End function
+  .section  .text.test1,"",@
+  .globl  test1                           # -- Begin function test1
+  .type  test1, at function
+test1:                                  # @test1
+.Lfunc_begin1:
+  .functype  test1 () -> ()
+# %bb.0:
+  i32.const  4
+  i32.const  5
+  call  foo
+                                        # fallthrough-return
+  end_function
+.Lfunc_end1:
+                                        # -- End function
+  .file  1 "b.c"
+  .section  .debug_abbrev,"",@
+  .int8  1                               # Abbreviation Code
+  .int8  17                              # DW_TAG_compile_unit
+  .int8  1                               # DW_CHILDREN_yes
+  .int8  37                              # DW_AT_producer
+  .int8  14                              # DW_FORM_strp
+  .int8  19                              # DW_AT_language
+  .int8  5                               # DW_FORM_data2
+  .int8  3                               # DW_AT_name
+  .int8  14                              # DW_FORM_strp
+  .int8  16                              # DW_AT_stmt_list
+  .int8  23                              # DW_FORM_sec_offset
+  .int8  17                              # DW_AT_low_pc
+  .int8  1                               # DW_FORM_addr
+  .int8  85                              # DW_AT_ranges
+  .int8  23                              # DW_FORM_sec_offset
+  .int8  0                               # EOM(1)
+  .int8  0                               # EOM(2)
+  .int8  2                               # Abbreviation Code
+  .int8  46                              # DW_TAG_subprogram
+  .int8  0                               # DW_CHILDREN_no
+  .int8  17                              # DW_AT_low_pc
+  .int8  1                               # DW_FORM_addr
+  .int8  18                              # DW_AT_high_pc
+  .int8  6                               # DW_FORM_data4
+  .int8  64                              # DW_AT_frame_base
+  .int8  24                              # DW_FORM_exprloc
+  .int8  3                               # DW_AT_name
+  .int8  14                              # DW_FORM_strp
+  .int8  58                              # DW_AT_decl_file
+  .int8  11                              # DW_FORM_data1
+  .int8  59                              # DW_AT_decl_line
+  .int8  11                              # DW_FORM_data1
+  .int8  39                              # DW_AT_prototyped
+  .int8  25                              # DW_FORM_flag_present
+  .int8  63                              # DW_AT_external
+  .int8  25                              # DW_FORM_flag_present
+  .int8  0                               # EOM(1)
+  .int8  0                               # EOM(2)
+  .int8  3                               # Abbreviation Code
+  .int8  46                              # DW_TAG_subprogram
+  .int8  0                               # DW_CHILDREN_no
+  .int8  17                              # DW_AT_low_pc
+  .int8  1                               # DW_FORM_addr
+  .int8  18                              # DW_AT_high_pc
+  .int8  6                               # DW_FORM_data4
+  .int8  64                              # DW_AT_frame_base
+  .int8  24                              # DW_FORM_exprloc
+  .int8  3                               # DW_AT_name
+  .int8  14                              # DW_FORM_strp
+  .int8  58                              # DW_AT_decl_file
+  .int8  11                              # DW_FORM_data1
+  .int8  59                              # DW_AT_decl_line
+  .int8  11                              # DW_FORM_data1
+  .int8  63                              # DW_AT_external
+  .int8  25                              # DW_FORM_flag_present
+  .int8  0                               # EOM(1)
+  .int8  0                               # EOM(2)
+  .int8  0                               # EOM(3)
+  .section  .debug_info,"",@
+.Lcu_begin0:
+  .int32  .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit
+.Ldebug_info_start0:
+  .int16  4                               # DWARF version number
+  .int32  .debug_abbrev0                  # Offset Into Abbrev. Section
+  .int8  4                               # Address Size (in bytes)
+  .int8  1                               # Abbrev [1] 0xb:0x46 DW_TAG_compile_unit
+  .int32  .Linfo_string0                  # DW_AT_producer
+  .int16  29                              # DW_AT_language
+  .int32  .Linfo_string1                  # DW_AT_name
+  .int32  .Lline_table_start0             # DW_AT_stmt_list
+  .int32  0                               # DW_AT_low_pc
+  .int32  .Ldebug_ranges0                 # DW_AT_ranges
+  .int8  2                               # Abbrev [2] 0x22:0x17 DW_TAG_subprogram
+  .int32  .Lfunc_begin0                   # DW_AT_low_pc
+  .int32  .Lfunc_end0-.Lfunc_begin0       # DW_AT_high_pc
+  .int8  7                               # DW_AT_frame_base
+  .int8  237
+  .int8  3
+  .int32  __stack_pointer
+  .int8  159
+  .int32  .Linfo_string2                  # DW_AT_name
+  .int8  1                               # DW_AT_decl_file
+  .int8  3                               # DW_AT_decl_line
+                                        # DW_AT_prototyped
+                                        # DW_AT_external
+  .int8  3                               # Abbrev [3] 0x39:0x17 DW_TAG_subprogram
+  .int32  .Lfunc_begin1                   # DW_AT_low_pc
+  .int32  .Lfunc_end1-.Lfunc_begin1       # DW_AT_high_pc
+  .int8  7                               # DW_AT_frame_base
+  .int8  237
+  .int8  3
+  .int32  __stack_pointer
+  .int8  159
+  .int32  .Linfo_string3                  # DW_AT_name
+  .int8  1                               # DW_AT_decl_file
+  .int8  7                               # DW_AT_decl_line
+                                        # DW_AT_external
+  .int8  0                               # End Of Children Mark
+.Ldebug_info_end0:
+  .section  .debug_ranges,"",@
+.Ldebug_ranges0:
+  .int32  .Lfunc_begin0
+  .int32  .Lfunc_end0
+  .int32  .Lfunc_begin1
+  .int32  .Lfunc_end1
+  .int32  0
+  .int32  0
+  .section  .debug_str,"S",@
+.Linfo_string0:
+  .asciz  "clang version 19.0.0git"       # string offset=0
+.Linfo_string1:
+  .asciz  "b.c"                           # string offset=24
+.Linfo_string2:
+  .asciz  "foo"                           # string offset=28
+.Linfo_string3:
+  .asciz  "test1"                         # string offset=32
+  .ident  "clang version 19.0.0git"
+  .section  .custom_section.producers,"",@
+  .int8  2
+  .int8  8
+  .ascii  "language"
+  .int8  1
+  .int8  3
+  .ascii  "C11"
+  .int8  0
+  .int8  12
+  .ascii  "processed-by"
+  .int8  1
+  .int8  5
+  .ascii  "clang"
+  .int8  9
+  .ascii  "19.0.0git"
+  .section  .debug_str,"S",@
+  .section  .custom_section.target_features,"",@
+  .int8  2
+  .int8  43
+  .int8  15
+  .ascii  "mutable-globals"
+  .int8  43
+  .int8  8
+  .ascii  "sign-ext"
+  .section  .debug_str,"S",@
+  .section  .debug_line,"",@
+.Lline_table_start0:
diff --git a/lld/test/wasm/Inputs/signature-mismatch-debug-info-main.s b/lld/test/wasm/Inputs/signature-mismatch-debug-info-main.s
new file mode 100644
index 0000000000000..7f78055d2bf4b
--- /dev/null
+++ b/lld/test/wasm/Inputs/signature-mismatch-debug-info-main.s
@@ -0,0 +1,155 @@
+  .globaltype __stack_pointer, i32
+  .text
+  .file  "signature-mismatch-debug-info-main.ll"
+  .functype  __original_main () -> (i32)
+  .functype  test0 () -> ()
+  .functype  test1 () -> ()
+  .functype  main (i32, i32) -> (i32)
+  .section  .text.__original_main,"",@
+  .globl  __original_main                 # -- Begin function __original_main
+  .type  __original_main, at function
+__original_main:                        # @__original_main
+.Lfunc_begin0:
+  .functype  __original_main () -> (i32)
+# %bb.0:
+  call  test0
+  call  test1
+  i32.const  0
+                                        # fallthrough-return
+  end_function
+.Lfunc_end0:
+                                        # -- End function
+  .section  .text.main,"",@
+  .globl  main                            # -- Begin function main
+  .type  main, at function
+main:                                   # @main
+.Lfunc_begin1:
+  .functype  main (i32, i32) -> (i32)
+# %bb.0:                                # %body
+  call  __original_main
+                                        # fallthrough-return
+  end_function
+.Lfunc_end1:
+                                        # -- End function
+  .file  1 "main.c"
+  .section  .debug_abbrev,"",@
+  .int8  1                               # Abbreviation Code
+  .int8  17                              # DW_TAG_compile_unit
+  .int8  1                               # DW_CHILDREN_yes
+  .int8  37                              # DW_AT_producer
+  .int8  14                              # DW_FORM_strp
+  .int8  19                              # DW_AT_language
+  .int8  5                               # DW_FORM_data2
+  .int8  3                               # DW_AT_name
+  .int8  14                              # DW_FORM_strp
+  .int8  16                              # DW_AT_stmt_list
+  .int8  23                              # DW_FORM_sec_offset
+  .int8  17                              # DW_AT_low_pc
+  .int8  1                               # DW_FORM_addr
+  .int8  18                              # DW_AT_high_pc
+  .int8  6                               # DW_FORM_data4
+  .int8  0                               # EOM(1)
+  .int8  0                               # EOM(2)
+  .int8  2                               # Abbreviation Code
+  .int8  46                              # DW_TAG_subprogram
+  .int8  0                               # DW_CHILDREN_no
+  .int8  17                              # DW_AT_low_pc
+  .int8  1                               # DW_FORM_addr
+  .int8  18                              # DW_AT_high_pc
+  .int8  6                               # DW_FORM_data4
+  .int8  64                              # DW_AT_frame_base
+  .int8  24                              # DW_FORM_exprloc
+  .int8  3                               # DW_AT_name
+  .int8  14                              # DW_FORM_strp
+  .int8  58                              # DW_AT_decl_file
+  .int8  11                              # DW_FORM_data1
+  .int8  59                              # DW_AT_decl_line
+  .int8  11                              # DW_FORM_data1
+  .int8  73                              # DW_AT_type
+  .int8  19                              # DW_FORM_ref4
+  .int8  63                              # DW_AT_external
+  .int8  25                              # DW_FORM_flag_present
+  .int8  0                               # EOM(1)
+  .int8  0                               # EOM(2)
+  .int8  3                               # Abbreviation Code
+  .int8  36                              # DW_TAG_base_type
+  .int8  0                               # DW_CHILDREN_no
+  .int8  3                               # DW_AT_name
+  .int8  14                              # DW_FORM_strp
+  .int8  62                              # DW_AT_encoding
+  .int8  11                              # DW_FORM_data1
+  .int8  11                              # DW_AT_byte_size
+  .int8  11                              # DW_FORM_data1
+  .int8  0                               # EOM(1)
+  .int8  0                               # EOM(2)
+  .int8  0                               # EOM(3)
+  .section  .debug_info,"",@
+.Lcu_begin0:
+  .int32  .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit
+.Ldebug_info_start0:
+  .int16  4                               # DWARF version number
+  .int32  .debug_abbrev0                  # Offset Into Abbrev. Section
+  .int8  4                               # Address Size (in bytes)
+  .int8  1                               # Abbrev [1] 0xb:0x3a DW_TAG_compile_unit
+  .int32  .Linfo_string0                  # DW_AT_producer
+  .int16  29                              # DW_AT_language
+  .int32  .Linfo_string1                  # DW_AT_name
+  .int32  .Lline_table_start0             # DW_AT_stmt_list
+  .int32  .Lfunc_begin0                   # DW_AT_low_pc
+  .int32  .Lfunc_end0-.Lfunc_begin0       # DW_AT_high_pc
+  .int8  2                               # Abbrev [2] 0x22:0x1b DW_TAG_subprogram
+  .int32  .Lfunc_begin0                   # DW_AT_low_pc
+  .int32  .Lfunc_end0-.Lfunc_begin0       # DW_AT_high_pc
+  .int8  7                               # DW_AT_frame_base
+  .int8  237
+  .int8  3
+  .int32  __stack_pointer
+  .int8  159
+  .int32  .Linfo_string2                  # DW_AT_name
+  .int8  1                               # DW_AT_decl_file
+  .int8  4                               # DW_AT_decl_line
+  .int32  61                              # DW_AT_type
+                                        # DW_AT_external
+  .int8  3                               # Abbrev [3] 0x3d:0x7 DW_TAG_base_type
+  .int32  .Linfo_string3                  # DW_AT_name
+  .int8  5                               # DW_AT_encoding
+  .int8  4                               # DW_AT_byte_size
+  .int8  0                               # End Of Children Mark
+.Ldebug_info_end0:
+  .section  .debug_str,"S",@
+.Linfo_string0:
+  .asciz  "clang version 19.0.0git"       # string offset=0
+.Linfo_string1:
+  .asciz  "main.c"                        # string offset=24
+.Linfo_string2:
+  .asciz  "main"                          # string offset=31
+.Linfo_string3:
+  .asciz  "int"                           # string offset=36
+  .ident  "clang version 19.0.0git"
+  .section  .custom_section.producers,"",@
+  .int8  2
+  .int8  8
+  .ascii  "language"
+  .int8  1
+  .int8  3
+  .ascii  "C11"
+  .int8  0
+  .int8  12
+  .ascii  "processed-by"
+  .int8  1
+  .int8  5
+  .ascii  "clang"
+  .int8  9
+  .ascii  "19.0.0git"
+  .section  .debug_str,"S",@
+  .section  .custom_section.target_features,"",@
+  .int8  2
+  .int8  43
+  .int8  15
+  .ascii  "mutable-globals"
+  .int8  43
+  .int8  8
+  .ascii  "sign-ext"
+  .section  .debug_str,"S",@
+  .section  .debug_line,"",@
+.Lline_table_start0:
diff --git a/lld/test/wasm/signature-mismatch-debug-info.test b/lld/test/wasm/signature-mismatch-debug-info.test
index fe1e8c2dbe579..4121527be9fc0 100644
--- a/lld/test/wasm/signature-mismatch-debug-info.test
+++ b/lld/test/wasm/signature-mismatch-debug-info.test
@@ -2,7 +2,7 @@
 # in functions with debug info does not cause does not cause a segmentation
 # fault when writing .debug_info section.
 
-; RUN: llc -filetype=obj %p/Inputs/signature-mismatch-debug-info-a.ll -o %t.a.o
-; RUN: llc -filetype=obj %p/Inputs/signature-mismatch-debug-info-b.ll -o %t.b.o
-; RUN: llc -filetype=obj %p/Inputs/signature-mismatch-debug-info-main.ll -o %t.main.o
+; RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/signature-mismatch-debug-info-a.s -o %t.a.o
+; RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/signature-mismatch-debug-info-b.s -o %t.b.o
+; RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/signature-mismatch-debug-info-main.s -o %t.main.o
 ; RUN: wasm-ld -o %t.wasm %t.a.o %t.b.o %t.main.o --export=main --no-entry

>From 607b92ab4c01dce8a50d18ce44bbabef0baf610f Mon Sep 17 00:00:00 2001
From: Heejin Ahn <aheejin at gmail.com>
Date: Thu, 20 Jun 2024 07:12:22 +0000
Subject: [PATCH 06/10] Simplify .s files a little

---
 .../Inputs/signature-mismatch-debug-info-a.s  | 47 -------------------
 .../Inputs/signature-mismatch-debug-info-b.s  | 47 -------------------
 .../signature-mismatch-debug-info-main.s      | 39 ---------------
 3 files changed, 133 deletions(-)

diff --git a/lld/test/wasm/Inputs/signature-mismatch-debug-info-a.s b/lld/test/wasm/Inputs/signature-mismatch-debug-info-a.s
index 4087c6c9b317c..547b9d855c676 100644
--- a/lld/test/wasm/Inputs/signature-mismatch-debug-info-a.s
+++ b/lld/test/wasm/Inputs/signature-mismatch-debug-info-a.s
@@ -1,6 +1,4 @@
   .globaltype __stack_pointer, i32
-  .text
-  .file  "signature-mismatch-debug-info-a.ll"
   .functype  foo (i32) -> ()
   .functype  test0 () -> ()
   .section  .text.foo,"",@
@@ -128,48 +126,3 @@ test0:                                  # @test0
                                         # DW_AT_external
   .int8  0                               # End Of Children Mark
 .Ldebug_info_end0:
-  .section  .debug_ranges,"",@
-.Ldebug_ranges0:
-  .int32  .Lfunc_begin0
-  .int32  .Lfunc_end0
-  .int32  .Lfunc_begin1
-  .int32  .Lfunc_end1
-  .int32  0
-  .int32  0
-  .section  .debug_str,"S",@
-.Linfo_string0:
-  .asciz  "clang version 19.0.0git"       # string offset=0
-.Linfo_string1:
-  .asciz  "a.c"                           # string offset=24
-.Linfo_string2:
-  .asciz  "foo"                           # string offset=28
-.Linfo_string3:
-  .asciz  "test0"                         # string offset=32
-  .ident  "clang version 19.0.0git"
-  .section  .custom_section.producers,"",@
-  .int8  2
-  .int8  8
-  .ascii  "language"
-  .int8  1
-  .int8  3
-  .ascii  "C11"
-  .int8  0
-  .int8  12
-  .ascii  "processed-by"
-  .int8  1
-  .int8  5
-  .ascii  "clang"
-  .int8  9
-  .ascii  "19.0.0git"
-  .section  .debug_str,"S",@
-  .section  .custom_section.target_features,"",@
-  .int8  2
-  .int8  43
-  .int8  15
-  .ascii  "mutable-globals"
-  .int8  43
-  .int8  8
-  .ascii  "sign-ext"
-  .section  .debug_str,"S",@
-  .section  .debug_line,"",@
-.Lline_table_start0:
diff --git a/lld/test/wasm/Inputs/signature-mismatch-debug-info-b.s b/lld/test/wasm/Inputs/signature-mismatch-debug-info-b.s
index 746342edfff9e..ef1018f882216 100644
--- a/lld/test/wasm/Inputs/signature-mismatch-debug-info-b.s
+++ b/lld/test/wasm/Inputs/signature-mismatch-debug-info-b.s
@@ -1,6 +1,4 @@
   .globaltype __stack_pointer, i32
-  .text
-  .file  "signature-mismatch-debug-info-b.ll"
   .functype  foo (i32, i32) -> ()
   .functype  test1 () -> ()
   .section  .text.foo,"",@
@@ -129,48 +127,3 @@ test1:                                  # @test1
                                         # DW_AT_external
   .int8  0                               # End Of Children Mark
 .Ldebug_info_end0:
-  .section  .debug_ranges,"",@
-.Ldebug_ranges0:
-  .int32  .Lfunc_begin0
-  .int32  .Lfunc_end0
-  .int32  .Lfunc_begin1
-  .int32  .Lfunc_end1
-  .int32  0
-  .int32  0
-  .section  .debug_str,"S",@
-.Linfo_string0:
-  .asciz  "clang version 19.0.0git"       # string offset=0
-.Linfo_string1:
-  .asciz  "b.c"                           # string offset=24
-.Linfo_string2:
-  .asciz  "foo"                           # string offset=28
-.Linfo_string3:
-  .asciz  "test1"                         # string offset=32
-  .ident  "clang version 19.0.0git"
-  .section  .custom_section.producers,"",@
-  .int8  2
-  .int8  8
-  .ascii  "language"
-  .int8  1
-  .int8  3
-  .ascii  "C11"
-  .int8  0
-  .int8  12
-  .ascii  "processed-by"
-  .int8  1
-  .int8  5
-  .ascii  "clang"
-  .int8  9
-  .ascii  "19.0.0git"
-  .section  .debug_str,"S",@
-  .section  .custom_section.target_features,"",@
-  .int8  2
-  .int8  43
-  .int8  15
-  .ascii  "mutable-globals"
-  .int8  43
-  .int8  8
-  .ascii  "sign-ext"
-  .section  .debug_str,"S",@
-  .section  .debug_line,"",@
-.Lline_table_start0:
diff --git a/lld/test/wasm/Inputs/signature-mismatch-debug-info-main.s b/lld/test/wasm/Inputs/signature-mismatch-debug-info-main.s
index 7f78055d2bf4b..0adb0abf6d539 100644
--- a/lld/test/wasm/Inputs/signature-mismatch-debug-info-main.s
+++ b/lld/test/wasm/Inputs/signature-mismatch-debug-info-main.s
@@ -1,6 +1,4 @@
   .globaltype __stack_pointer, i32
-  .text
-  .file  "signature-mismatch-debug-info-main.ll"
   .functype  __original_main () -> (i32)
   .functype  test0 () -> ()
   .functype  test1 () -> ()
@@ -116,40 +114,3 @@ main:                                   # @main
   .int8  4                               # DW_AT_byte_size
   .int8  0                               # End Of Children Mark
 .Ldebug_info_end0:
-  .section  .debug_str,"S",@
-.Linfo_string0:
-  .asciz  "clang version 19.0.0git"       # string offset=0
-.Linfo_string1:
-  .asciz  "main.c"                        # string offset=24
-.Linfo_string2:
-  .asciz  "main"                          # string offset=31
-.Linfo_string3:
-  .asciz  "int"                           # string offset=36
-  .ident  "clang version 19.0.0git"
-  .section  .custom_section.producers,"",@
-  .int8  2
-  .int8  8
-  .ascii  "language"
-  .int8  1
-  .int8  3
-  .ascii  "C11"
-  .int8  0
-  .int8  12
-  .ascii  "processed-by"
-  .int8  1
-  .int8  5
-  .ascii  "clang"
-  .int8  9
-  .ascii  "19.0.0git"
-  .section  .debug_str,"S",@
-  .section  .custom_section.target_features,"",@
-  .int8  2
-  .int8  43
-  .int8  15
-  .ascii  "mutable-globals"
-  .int8  43
-  .int8  8
-  .ascii  "sign-ext"
-  .section  .debug_str,"S",@
-  .section  .debug_line,"",@
-.Lline_table_start0:

>From 165246a00a7cf1c992566dffd745bd44dce57f09 Mon Sep 17 00:00:00 2001
From: Heejin Ahn <aheejin at gmail.com>
Date: Thu, 20 Jun 2024 07:28:43 +0000
Subject: [PATCH 07/10] Simplify .s files very much

---
 .../Inputs/signature-mismatch-debug-info-a.s  | 124 ++----------------
 .../Inputs/signature-mismatch-debug-info-b.s  | 123 ++---------------
 .../signature-mismatch-debug-info-main.s      | 117 ++---------------
 3 files changed, 26 insertions(+), 338 deletions(-)

diff --git a/lld/test/wasm/Inputs/signature-mismatch-debug-info-a.s b/lld/test/wasm/Inputs/signature-mismatch-debug-info-a.s
index 547b9d855c676..7da9a3de622d2 100644
--- a/lld/test/wasm/Inputs/signature-mismatch-debug-info-a.s
+++ b/lld/test/wasm/Inputs/signature-mismatch-debug-info-a.s
@@ -1,128 +1,22 @@
-  .globaltype __stack_pointer, i32
   .functype  foo (i32) -> ()
   .functype  test0 () -> ()
+
   .section  .text.foo,"",@
-  .weak  foo                             # -- Begin function foo
+  .weak  foo
   .type  foo, at function
-foo:                                    # @foo
-.Lfunc_begin0:
+foo:
   .functype  foo (i32) -> ()
-# %bb.0:
-                                        # fallthrough-return
   end_function
-.Lfunc_end0:
-                                        # -- End function
+
   .section  .text.test0,"",@
-  .globl  test0                           # -- Begin function test0
+  .globl  test0
   .type  test0, at function
-test0:                                  # @test0
-.Lfunc_begin1:
+test0:
   .functype  test0 () -> ()
-# %bb.0:
   i32.const  3
   call  foo
-                                        # fallthrough-return
   end_function
-.Lfunc_end1:
-                                        # -- End function
-  .file  1 "a.c"
-  .section  .debug_abbrev,"",@
-  .int8  1                               # Abbreviation Code
-  .int8  17                              # DW_TAG_compile_unit
-  .int8  1                               # DW_CHILDREN_yes
-  .int8  37                              # DW_AT_producer
-  .int8  14                              # DW_FORM_strp
-  .int8  19                              # DW_AT_language
-  .int8  5                               # DW_FORM_data2
-  .int8  3                               # DW_AT_name
-  .int8  14                              # DW_FORM_strp
-  .int8  16                              # DW_AT_stmt_list
-  .int8  23                              # DW_FORM_sec_offset
-  .int8  17                              # DW_AT_low_pc
-  .int8  1                               # DW_FORM_addr
-  .int8  85                              # DW_AT_ranges
-  .int8  23                              # DW_FORM_sec_offset
-  .int8  0                               # EOM(1)
-  .int8  0                               # EOM(2)
-  .int8  2                               # Abbreviation Code
-  .int8  46                              # DW_TAG_subprogram
-  .int8  0                               # DW_CHILDREN_no
-  .int8  17                              # DW_AT_low_pc
-  .int8  1                               # DW_FORM_addr
-  .int8  18                              # DW_AT_high_pc
-  .int8  6                               # DW_FORM_data4
-  .int8  64                              # DW_AT_frame_base
-  .int8  24                              # DW_FORM_exprloc
-  .int8  3                               # DW_AT_name
-  .int8  14                              # DW_FORM_strp
-  .int8  58                              # DW_AT_decl_file
-  .int8  11                              # DW_FORM_data1
-  .int8  59                              # DW_AT_decl_line
-  .int8  11                              # DW_FORM_data1
-  .int8  39                              # DW_AT_prototyped
-  .int8  25                              # DW_FORM_flag_present
-  .int8  63                              # DW_AT_external
-  .int8  25                              # DW_FORM_flag_present
-  .int8  0                               # EOM(1)
-  .int8  0                               # EOM(2)
-  .int8  3                               # Abbreviation Code
-  .int8  46                              # DW_TAG_subprogram
-  .int8  0                               # DW_CHILDREN_no
-  .int8  17                              # DW_AT_low_pc
-  .int8  1                               # DW_FORM_addr
-  .int8  18                              # DW_AT_high_pc
-  .int8  6                               # DW_FORM_data4
-  .int8  64                              # DW_AT_frame_base
-  .int8  24                              # DW_FORM_exprloc
-  .int8  3                               # DW_AT_name
-  .int8  14                              # DW_FORM_strp
-  .int8  58                              # DW_AT_decl_file
-  .int8  11                              # DW_FORM_data1
-  .int8  59                              # DW_AT_decl_line
-  .int8  11                              # DW_FORM_data1
-  .int8  63                              # DW_AT_external
-  .int8  25                              # DW_FORM_flag_present
-  .int8  0                               # EOM(1)
-  .int8  0                               # EOM(2)
-  .int8  0                               # EOM(3)
+
   .section  .debug_info,"",@
-.Lcu_begin0:
-  .int32  .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit
-.Ldebug_info_start0:
-  .int16  4                               # DWARF version number
-  .int32  .debug_abbrev0                  # Offset Into Abbrev. Section
-  .int8  4                               # Address Size (in bytes)
-  .int8  1                               # Abbrev [1] 0xb:0x46 DW_TAG_compile_unit
-  .int32  .Linfo_string0                  # DW_AT_producer
-  .int16  29                              # DW_AT_language
-  .int32  .Linfo_string1                  # DW_AT_name
-  .int32  .Lline_table_start0             # DW_AT_stmt_list
-  .int32  0                               # DW_AT_low_pc
-  .int32  .Ldebug_ranges0                 # DW_AT_ranges
-  .int8  2                               # Abbrev [2] 0x22:0x17 DW_TAG_subprogram
-  .int32  .Lfunc_begin0                   # DW_AT_low_pc
-  .int32  .Lfunc_end0-.Lfunc_begin0       # DW_AT_high_pc
-  .int8  7                               # DW_AT_frame_base
-  .int8  237
-  .int8  3
-  .int32  __stack_pointer
-  .int8  159
-  .int32  .Linfo_string2                  # DW_AT_name
-  .int8  1                               # DW_AT_decl_file
-  .int8  3                               # DW_AT_decl_line
-                                        # DW_AT_prototyped
-                                        # DW_AT_external
-  .int8  3                               # Abbrev [3] 0x39:0x17 DW_TAG_subprogram
-  .int32  .Lfunc_begin1                   # DW_AT_low_pc
-  .int32  .Lfunc_end1-.Lfunc_begin1       # DW_AT_high_pc
-  .int8  7                               # DW_AT_frame_base
-  .int8  237
-  .int8  3
-  .int32  __stack_pointer
-  .int8  159
-  .int32  .Linfo_string3                  # DW_AT_name
-  .int8  1                               # DW_AT_decl_file
-  .int8  7                               # DW_AT_decl_line
-                                        # DW_AT_external
-  .int8  0                               # End Of Children Mark
-.Ldebug_info_end0:
+  .int32 foo
+  .int32 test0
diff --git a/lld/test/wasm/Inputs/signature-mismatch-debug-info-b.s b/lld/test/wasm/Inputs/signature-mismatch-debug-info-b.s
index ef1018f882216..6777306e286f5 100644
--- a/lld/test/wasm/Inputs/signature-mismatch-debug-info-b.s
+++ b/lld/test/wasm/Inputs/signature-mismatch-debug-info-b.s
@@ -1,129 +1,22 @@
-  .globaltype __stack_pointer, i32
   .functype  foo (i32, i32) -> ()
   .functype  test1 () -> ()
   .section  .text.foo,"",@
-  .weak  foo                             # -- Begin function foo
+  .weak  foo
   .type  foo, at function
-foo:                                    # @foo
-.Lfunc_begin0:
+foo:
   .functype  foo (i32, i32) -> ()
-# %bb.0:
-                                        # fallthrough-return
   end_function
-.Lfunc_end0:
-                                        # -- End function
+
   .section  .text.test1,"",@
-  .globl  test1                           # -- Begin function test1
+  .globl  test1
   .type  test1, at function
-test1:                                  # @test1
-.Lfunc_begin1:
+test1:
   .functype  test1 () -> ()
-# %bb.0:
   i32.const  4
   i32.const  5
   call  foo
-                                        # fallthrough-return
   end_function
-.Lfunc_end1:
-                                        # -- End function
-  .file  1 "b.c"
-  .section  .debug_abbrev,"",@
-  .int8  1                               # Abbreviation Code
-  .int8  17                              # DW_TAG_compile_unit
-  .int8  1                               # DW_CHILDREN_yes
-  .int8  37                              # DW_AT_producer
-  .int8  14                              # DW_FORM_strp
-  .int8  19                              # DW_AT_language
-  .int8  5                               # DW_FORM_data2
-  .int8  3                               # DW_AT_name
-  .int8  14                              # DW_FORM_strp
-  .int8  16                              # DW_AT_stmt_list
-  .int8  23                              # DW_FORM_sec_offset
-  .int8  17                              # DW_AT_low_pc
-  .int8  1                               # DW_FORM_addr
-  .int8  85                              # DW_AT_ranges
-  .int8  23                              # DW_FORM_sec_offset
-  .int8  0                               # EOM(1)
-  .int8  0                               # EOM(2)
-  .int8  2                               # Abbreviation Code
-  .int8  46                              # DW_TAG_subprogram
-  .int8  0                               # DW_CHILDREN_no
-  .int8  17                              # DW_AT_low_pc
-  .int8  1                               # DW_FORM_addr
-  .int8  18                              # DW_AT_high_pc
-  .int8  6                               # DW_FORM_data4
-  .int8  64                              # DW_AT_frame_base
-  .int8  24                              # DW_FORM_exprloc
-  .int8  3                               # DW_AT_name
-  .int8  14                              # DW_FORM_strp
-  .int8  58                              # DW_AT_decl_file
-  .int8  11                              # DW_FORM_data1
-  .int8  59                              # DW_AT_decl_line
-  .int8  11                              # DW_FORM_data1
-  .int8  39                              # DW_AT_prototyped
-  .int8  25                              # DW_FORM_flag_present
-  .int8  63                              # DW_AT_external
-  .int8  25                              # DW_FORM_flag_present
-  .int8  0                               # EOM(1)
-  .int8  0                               # EOM(2)
-  .int8  3                               # Abbreviation Code
-  .int8  46                              # DW_TAG_subprogram
-  .int8  0                               # DW_CHILDREN_no
-  .int8  17                              # DW_AT_low_pc
-  .int8  1                               # DW_FORM_addr
-  .int8  18                              # DW_AT_high_pc
-  .int8  6                               # DW_FORM_data4
-  .int8  64                              # DW_AT_frame_base
-  .int8  24                              # DW_FORM_exprloc
-  .int8  3                               # DW_AT_name
-  .int8  14                              # DW_FORM_strp
-  .int8  58                              # DW_AT_decl_file
-  .int8  11                              # DW_FORM_data1
-  .int8  59                              # DW_AT_decl_line
-  .int8  11                              # DW_FORM_data1
-  .int8  63                              # DW_AT_external
-  .int8  25                              # DW_FORM_flag_present
-  .int8  0                               # EOM(1)
-  .int8  0                               # EOM(2)
-  .int8  0                               # EOM(3)
+
   .section  .debug_info,"",@
-.Lcu_begin0:
-  .int32  .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit
-.Ldebug_info_start0:
-  .int16  4                               # DWARF version number
-  .int32  .debug_abbrev0                  # Offset Into Abbrev. Section
-  .int8  4                               # Address Size (in bytes)
-  .int8  1                               # Abbrev [1] 0xb:0x46 DW_TAG_compile_unit
-  .int32  .Linfo_string0                  # DW_AT_producer
-  .int16  29                              # DW_AT_language
-  .int32  .Linfo_string1                  # DW_AT_name
-  .int32  .Lline_table_start0             # DW_AT_stmt_list
-  .int32  0                               # DW_AT_low_pc
-  .int32  .Ldebug_ranges0                 # DW_AT_ranges
-  .int8  2                               # Abbrev [2] 0x22:0x17 DW_TAG_subprogram
-  .int32  .Lfunc_begin0                   # DW_AT_low_pc
-  .int32  .Lfunc_end0-.Lfunc_begin0       # DW_AT_high_pc
-  .int8  7                               # DW_AT_frame_base
-  .int8  237
-  .int8  3
-  .int32  __stack_pointer
-  .int8  159
-  .int32  .Linfo_string2                  # DW_AT_name
-  .int8  1                               # DW_AT_decl_file
-  .int8  3                               # DW_AT_decl_line
-                                        # DW_AT_prototyped
-                                        # DW_AT_external
-  .int8  3                               # Abbrev [3] 0x39:0x17 DW_TAG_subprogram
-  .int32  .Lfunc_begin1                   # DW_AT_low_pc
-  .int32  .Lfunc_end1-.Lfunc_begin1       # DW_AT_high_pc
-  .int8  7                               # DW_AT_frame_base
-  .int8  237
-  .int8  3
-  .int32  __stack_pointer
-  .int8  159
-  .int32  .Linfo_string3                  # DW_AT_name
-  .int8  1                               # DW_AT_decl_file
-  .int8  7                               # DW_AT_decl_line
-                                        # DW_AT_external
-  .int8  0                               # End Of Children Mark
-.Ldebug_info_end0:
+  .int32 foo
+  .int32 test1
diff --git a/lld/test/wasm/Inputs/signature-mismatch-debug-info-main.s b/lld/test/wasm/Inputs/signature-mismatch-debug-info-main.s
index 0adb0abf6d539..303ed68f249e4 100644
--- a/lld/test/wasm/Inputs/signature-mismatch-debug-info-main.s
+++ b/lld/test/wasm/Inputs/signature-mismatch-debug-info-main.s
@@ -1,116 +1,17 @@
-  .globaltype __stack_pointer, i32
-  .functype  __original_main () -> (i32)
   .functype  test0 () -> ()
   .functype  test1 () -> ()
   .functype  main (i32, i32) -> (i32)
-  .section  .text.__original_main,"",@
-  .globl  __original_main                 # -- Begin function __original_main
-  .type  __original_main, at function
-__original_main:                        # @__original_main
-.Lfunc_begin0:
-  .functype  __original_main () -> (i32)
-# %bb.0:
-  call  test0
-  call  test1
-  i32.const  0
-                                        # fallthrough-return
-  end_function
-.Lfunc_end0:
-                                        # -- End function
+
   .section  .text.main,"",@
-  .globl  main                            # -- Begin function main
+  .globl  main
   .type  main, at function
-main:                                   # @main
-.Lfunc_begin1:
+main:
   .functype  main (i32, i32) -> (i32)
-# %bb.0:                                # %body
-  call  __original_main
-                                        # fallthrough-return
+  call  test0
+  call  test1
+  i32.const  0
   end_function
-.Lfunc_end1:
-                                        # -- End function
-  .file  1 "main.c"
-  .section  .debug_abbrev,"",@
-  .int8  1                               # Abbreviation Code
-  .int8  17                              # DW_TAG_compile_unit
-  .int8  1                               # DW_CHILDREN_yes
-  .int8  37                              # DW_AT_producer
-  .int8  14                              # DW_FORM_strp
-  .int8  19                              # DW_AT_language
-  .int8  5                               # DW_FORM_data2
-  .int8  3                               # DW_AT_name
-  .int8  14                              # DW_FORM_strp
-  .int8  16                              # DW_AT_stmt_list
-  .int8  23                              # DW_FORM_sec_offset
-  .int8  17                              # DW_AT_low_pc
-  .int8  1                               # DW_FORM_addr
-  .int8  18                              # DW_AT_high_pc
-  .int8  6                               # DW_FORM_data4
-  .int8  0                               # EOM(1)
-  .int8  0                               # EOM(2)
-  .int8  2                               # Abbreviation Code
-  .int8  46                              # DW_TAG_subprogram
-  .int8  0                               # DW_CHILDREN_no
-  .int8  17                              # DW_AT_low_pc
-  .int8  1                               # DW_FORM_addr
-  .int8  18                              # DW_AT_high_pc
-  .int8  6                               # DW_FORM_data4
-  .int8  64                              # DW_AT_frame_base
-  .int8  24                              # DW_FORM_exprloc
-  .int8  3                               # DW_AT_name
-  .int8  14                              # DW_FORM_strp
-  .int8  58                              # DW_AT_decl_file
-  .int8  11                              # DW_FORM_data1
-  .int8  59                              # DW_AT_decl_line
-  .int8  11                              # DW_FORM_data1
-  .int8  73                              # DW_AT_type
-  .int8  19                              # DW_FORM_ref4
-  .int8  63                              # DW_AT_external
-  .int8  25                              # DW_FORM_flag_present
-  .int8  0                               # EOM(1)
-  .int8  0                               # EOM(2)
-  .int8  3                               # Abbreviation Code
-  .int8  36                              # DW_TAG_base_type
-  .int8  0                               # DW_CHILDREN_no
-  .int8  3                               # DW_AT_name
-  .int8  14                              # DW_FORM_strp
-  .int8  62                              # DW_AT_encoding
-  .int8  11                              # DW_FORM_data1
-  .int8  11                              # DW_AT_byte_size
-  .int8  11                              # DW_FORM_data1
-  .int8  0                               # EOM(1)
-  .int8  0                               # EOM(2)
-  .int8  0                               # EOM(3)
+
   .section  .debug_info,"",@
-.Lcu_begin0:
-  .int32  .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit
-.Ldebug_info_start0:
-  .int16  4                               # DWARF version number
-  .int32  .debug_abbrev0                  # Offset Into Abbrev. Section
-  .int8  4                               # Address Size (in bytes)
-  .int8  1                               # Abbrev [1] 0xb:0x3a DW_TAG_compile_unit
-  .int32  .Linfo_string0                  # DW_AT_producer
-  .int16  29                              # DW_AT_language
-  .int32  .Linfo_string1                  # DW_AT_name
-  .int32  .Lline_table_start0             # DW_AT_stmt_list
-  .int32  .Lfunc_begin0                   # DW_AT_low_pc
-  .int32  .Lfunc_end0-.Lfunc_begin0       # DW_AT_high_pc
-  .int8  2                               # Abbrev [2] 0x22:0x1b DW_TAG_subprogram
-  .int32  .Lfunc_begin0                   # DW_AT_low_pc
-  .int32  .Lfunc_end0-.Lfunc_begin0       # DW_AT_high_pc
-  .int8  7                               # DW_AT_frame_base
-  .int8  237
-  .int8  3
-  .int32  __stack_pointer
-  .int8  159
-  .int32  .Linfo_string2                  # DW_AT_name
-  .int8  1                               # DW_AT_decl_file
-  .int8  4                               # DW_AT_decl_line
-  .int32  61                              # DW_AT_type
-                                        # DW_AT_external
-  .int8  3                               # Abbrev [3] 0x3d:0x7 DW_TAG_base_type
-  .int32  .Linfo_string3                  # DW_AT_name
-  .int8  5                               # DW_AT_encoding
-  .int8  4                               # DW_AT_byte_size
-  .int8  0                               # End Of Children Mark
-.Ldebug_info_end0:
+  .int32 test0
+  .int32 test1

>From dc1ad4cd696042f41b2b03c66f846c34cd156be1 Mon Sep 17 00:00:00 2001
From: Heejin Ahn <aheejin at gmail.com>
Date: Thu, 20 Jun 2024 07:33:38 +0000
Subject: [PATCH 08/10] Remove .ll files

---
 .../Inputs/signature-mismatch-debug-info-a.ll | 28 -------------------
 .../Inputs/signature-mismatch-debug-info-b.ll | 28 -------------------
 .../signature-mismatch-debug-info-main.ll     | 25 -----------------
 3 files changed, 81 deletions(-)
 delete mode 100644 lld/test/wasm/Inputs/signature-mismatch-debug-info-a.ll
 delete mode 100644 lld/test/wasm/Inputs/signature-mismatch-debug-info-b.ll
 delete mode 100644 lld/test/wasm/Inputs/signature-mismatch-debug-info-main.ll

diff --git a/lld/test/wasm/Inputs/signature-mismatch-debug-info-a.ll b/lld/test/wasm/Inputs/signature-mismatch-debug-info-a.ll
deleted file mode 100644
index 050b0f2baa2d5..0000000000000
--- a/lld/test/wasm/Inputs/signature-mismatch-debug-info-a.ll
+++ /dev/null
@@ -1,28 +0,0 @@
-target triple = "wasm32-unknown-emscripten"
-
-define weak void @foo(i32 %a) !dbg !6 {
-  ret void
-}
-
-define void @test0() !dbg !10 {
-  call void @foo(i32 3)
-  ret void
-}
-
-!llvm.dbg.cu = !{!0}
-!llvm.module.flags = !{!2, !3, !4}
-!llvm.ident = !{!5}
-
-!0 = distinct !DICompileUnit(language: DW_LANG_C11, file: !1, producer: "clang version 19.0.0git", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None)
-!1 = !DIFile(filename: "a.c", directory: "")
-!2 = !{i32 7, !"Dwarf Version", i32 4}
-!3 = !{i32 2, !"Debug Info Version", i32 3}
-!4 = !{i32 1, !"wchar_size", i32 4}
-!5 = !{!"clang version 19.0.0git"}
-!6 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 3, type: !7, scopeLine: 3, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0)
-!7 = !DISubroutineType(types: !8)
-!8 = !{null, !9}
-!9 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
-!10 = distinct !DISubprogram(name: "test0", scope: !1, file: !1, line: 7, type: !11, scopeLine: 7, spFlags: DISPFlagDefinition, unit: !0)
-!11 = !DISubroutineType(types: !12)
-!12 = !{null}
diff --git a/lld/test/wasm/Inputs/signature-mismatch-debug-info-b.ll b/lld/test/wasm/Inputs/signature-mismatch-debug-info-b.ll
deleted file mode 100644
index 4e9e57205d7a9..0000000000000
--- a/lld/test/wasm/Inputs/signature-mismatch-debug-info-b.ll
+++ /dev/null
@@ -1,28 +0,0 @@
-target triple = "wasm32-unknown-emscripten"
-
-define weak void @foo(i32 %a, i32 %b) !dbg !6 {
-  ret void
-}
-
-define void @test1() !dbg !10 {
-  call void @foo(i32 4, i32 5)
-  ret void
-}
-
-!llvm.dbg.cu = !{!0}
-!llvm.module.flags = !{!2, !3, !4}
-!llvm.ident = !{!5}
-
-!0 = distinct !DICompileUnit(language: DW_LANG_C11, file: !1, producer: "clang version 19.0.0git", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None)
-!1 = !DIFile(filename: "b.c", directory: "")
-!2 = !{i32 7, !"Dwarf Version", i32 4}
-!3 = !{i32 2, !"Debug Info Version", i32 3}
-!4 = !{i32 1, !"wchar_size", i32 4}
-!5 = !{!"clang version 19.0.0git"}
-!6 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 3, type: !7, scopeLine: 3, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0)
-!7 = !DISubroutineType(types: !8)
-!8 = !{null, !9, !9}
-!9 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
-!10 = distinct !DISubprogram(name: "test1", scope: !1, file: !1, line: 7, type: !11, scopeLine: 7, spFlags: DISPFlagDefinition, unit: !0)
-!11 = !DISubroutineType(types: !12)
-!12 = !{null}
diff --git a/lld/test/wasm/Inputs/signature-mismatch-debug-info-main.ll b/lld/test/wasm/Inputs/signature-mismatch-debug-info-main.ll
deleted file mode 100644
index f929e0d6e55f2..0000000000000
--- a/lld/test/wasm/Inputs/signature-mismatch-debug-info-main.ll
+++ /dev/null
@@ -1,25 +0,0 @@
-target triple = "wasm32-unknown-emscripten"
-
-define i32 @main() !dbg !6 {
-  call void @test0()
-  call void @test1()
-  ret i32 0
-}
-
-declare void @test0()
-declare void @test1()
-
-!llvm.dbg.cu = !{!0}
-!llvm.module.flags = !{!2, !3, !4}
-!llvm.ident = !{!5}
-
-!0 = distinct !DICompileUnit(language: DW_LANG_C11, file: !1, producer: "clang version 19.0.0git", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None)
-!1 = !DIFile(filename: "main.c", directory: "")
-!2 = !{i32 7, !"Dwarf Version", i32 4}
-!3 = !{i32 2, !"Debug Info Version", i32 3}
-!4 = !{i32 1, !"wchar_size", i32 4}
-!5 = !{!"clang version 19.0.0git"}
-!6 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 4, type: !7, scopeLine: 4, spFlags: DISPFlagDefinition, unit: !0)
-!7 = !DISubroutineType(types: !8)
-!8 = !{!9}
-!9 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)

>From 9cd679058f1dcfab7d9ce237576e1db54b9631b0 Mon Sep 17 00:00:00 2001
From: Heejin Ahn <aheejin at gmail.com>
Date: Thu, 20 Jun 2024 07:35:03 +0000
Subject: [PATCH 09/10] Test comment fix

---
 lld/test/wasm/signature-mismatch-debug-info.test | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lld/test/wasm/signature-mismatch-debug-info.test b/lld/test/wasm/signature-mismatch-debug-info.test
index 4121527be9fc0..71e6e4b655dfe 100644
--- a/lld/test/wasm/signature-mismatch-debug-info.test
+++ b/lld/test/wasm/signature-mismatch-debug-info.test
@@ -1,6 +1,6 @@
-# This is a regression test that checks whether a function signature mismatch
-# in functions with debug info does not cause does not cause a segmentation
-# fault when writing .debug_info section.
+# This is a regression test that ensures a function signature mismatch in
+# functions with debug info does not cause does not cause a segmentation fault
+# when writing .debug_info section.
 
 ; RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/signature-mismatch-debug-info-a.s -o %t.a.o
 ; RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/signature-mismatch-debug-info-b.s -o %t.b.o

>From 98d924315c8924f702f9c900d6b5c9b01272883a Mon Sep 17 00:00:00 2001
From: Heejin Ahn <aheejin at gmail.com>
Date: Thu, 20 Jun 2024 07:40:46 +0000
Subject: [PATCH 10/10] Add newline in test

---
 lld/test/wasm/Inputs/signature-mismatch-debug-info-b.s | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lld/test/wasm/Inputs/signature-mismatch-debug-info-b.s b/lld/test/wasm/Inputs/signature-mismatch-debug-info-b.s
index 6777306e286f5..8a1b9f8750f43 100644
--- a/lld/test/wasm/Inputs/signature-mismatch-debug-info-b.s
+++ b/lld/test/wasm/Inputs/signature-mismatch-debug-info-b.s
@@ -1,5 +1,6 @@
   .functype  foo (i32, i32) -> ()
   .functype  test1 () -> ()
+
   .section  .text.foo,"",@
   .weak  foo
   .type  foo, at function



More information about the llvm-commits mailing list