[llvm] Fix test (PR #158352)

Peter Rong via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 12 12:38:42 PDT 2025


https://github.com/DataCorrupted created https://github.com/llvm/llvm-project/pull/158352

None

>From dbbf5298fbad497987b6fa1ae3e9345213431264 Mon Sep 17 00:00:00 2001
From: Peter Rong <PeterRong at meta.com>
Date: Mon, 8 Sep 2025 11:25:14 -0700
Subject: [PATCH 1/6] [DebugLine] Correct debug line emittion

Signed-off-by: Peter Rong <PeterRong at meta.com>
---
 llvm/lib/MC/MCDwarf.cpp                       | 30 ++++++----
 .../X86/DW_AT_LLVM_stmt_seq_sec_offset.ll     | 59 ++++++++++---------
 llvm/test/MC/ELF/debug-loc-label.s            | 54 +++++++++--------
 3 files changed, 79 insertions(+), 64 deletions(-)

diff --git a/llvm/lib/MC/MCDwarf.cpp b/llvm/lib/MC/MCDwarf.cpp
index e7c0d37e8f99b..e8f000a584839 100644
--- a/llvm/lib/MC/MCDwarf.cpp
+++ b/llvm/lib/MC/MCDwarf.cpp
@@ -181,7 +181,7 @@ void MCDwarfLineTable::emitOne(
 
   unsigned FileNum, LastLine, Column, Flags, Isa, Discriminator;
   bool IsAtStartSeq;
-  MCSymbol *LastLabel;
+  MCSymbol *PrevLabel;
   auto init = [&]() {
     FileNum = 1;
     LastLine = 1;
@@ -189,21 +189,31 @@ void MCDwarfLineTable::emitOne(
     Flags = DWARF2_LINE_DEFAULT_IS_STMT ? DWARF2_FLAG_IS_STMT : 0;
     Isa = 0;
     Discriminator = 0;
-    LastLabel = nullptr;
+    PrevLabel = nullptr;
     IsAtStartSeq = true;
   };
   init();
 
   // Loop through each MCDwarfLineEntry and encode the dwarf line number table.
   bool EndEntryEmitted = false;
-  for (const MCDwarfLineEntry &LineEntry : LineEntries) {
-    MCSymbol *Label = LineEntry.getLabel();
+  for (auto It = LineEntries.begin(); It != LineEntries.end(); ++It) {
+    auto LineEntry = *It;
+    MCSymbol *CurrLabel = LineEntry.getLabel();
     const MCAsmInfo *asmInfo = MCOS->getContext().getAsmInfo();
 
     if (LineEntry.LineStreamLabel) {
       if (!IsAtStartSeq) {
-        MCOS->emitDwarfLineEndEntry(Section, LastLabel,
-                                    /*EndLabel =*/LastLabel);
+        auto *Label = CurrLabel;
+        auto NextIt = It + 1;
+        // LineEntry with a null Label is probably a fake LineEntry we added
+        // when `-emit-func-debug-line-table-offsets` in order to terminate the
+        // sequence. Look for the next Label if possible, otherwise we will set
+        // the PC to the end of the section.
+        if (!Label && NextIt != LineEntries.end()) {
+          Label = NextIt->getLabel();
+        }
+        MCOS->emitDwarfLineEndEntry(Section, PrevLabel,
+                                    /*EndLabel =*/Label);
         init();
       }
       MCOS->emitLabel(LineEntry.LineStreamLabel, LineEntry.StreamLabelDefLoc);
@@ -211,7 +221,7 @@ void MCDwarfLineTable::emitOne(
     }
 
     if (LineEntry.IsEndEntry) {
-      MCOS->emitDwarfAdvanceLineAddr(INT64_MAX, LastLabel, Label,
+      MCOS->emitDwarfAdvanceLineAddr(INT64_MAX, PrevLabel, CurrLabel,
                                      asmInfo->getCodePointerSize());
       init();
       EndEntryEmitted = true;
@@ -258,12 +268,12 @@ void MCDwarfLineTable::emitOne(
     // At this point we want to emit/create the sequence to encode the delta in
     // line numbers and the increment of the address from the previous Label
     // and the current Label.
-    MCOS->emitDwarfAdvanceLineAddr(LineDelta, LastLabel, Label,
+    MCOS->emitDwarfAdvanceLineAddr(LineDelta, PrevLabel, CurrLabel,
                                    asmInfo->getCodePointerSize());
 
     Discriminator = 0;
     LastLine = LineEntry.getLine();
-    LastLabel = Label;
+    PrevLabel = CurrLabel;
     IsAtStartSeq = false;
   }
 
@@ -273,7 +283,7 @@ void MCDwarfLineTable::emitOne(
   // does not track ranges nor terminate the line table. In that case,
   // conservatively use the section end symbol to end the line table.
   if (!EndEntryEmitted && !IsAtStartSeq)
-    MCOS->emitDwarfLineEndEntry(Section, LastLabel);
+    MCOS->emitDwarfLineEndEntry(Section, PrevLabel);
 }
 
 void MCDwarfLineTable::endCurrentSeqAndEmitLineStreamLabel(MCStreamer *MCOS,
diff --git a/llvm/test/DebugInfo/X86/DW_AT_LLVM_stmt_seq_sec_offset.ll b/llvm/test/DebugInfo/X86/DW_AT_LLVM_stmt_seq_sec_offset.ll
index 58f6495924b90..10059b7b30c20 100644
--- a/llvm/test/DebugInfo/X86/DW_AT_LLVM_stmt_seq_sec_offset.ll
+++ b/llvm/test/DebugInfo/X86/DW_AT_LLVM_stmt_seq_sec_offset.ll
@@ -14,38 +14,39 @@
 ; STMT_SEQ:       DW_AT_LLVM_stmt_sequence [DW_FORM_sec_offset]	(0x00000043)
 ; STMT_SEQ:   DW_AT_name {{.*}}func01
 ; STMT_SEQ:   DW_TAG_subprogram [[[ABBREV_CODE2]]]
-; STMT_SEQ:       DW_AT_LLVM_stmt_sequence [DW_FORM_sec_offset]	(0x00000056)
+; STMT_SEQ:       DW_AT_LLVM_stmt_sequence [DW_FORM_sec_offset]	(0x00000058)
 ; STMT_SEQ:   DW_AT_name {{.*}}main
 
 ;; Check the entire line sequence to see that it's correct
-; STMT_SEQ:                   Address            Line   Column File   ISA Discriminator OpIndex Flags
-; STMT_SEQ-NEXT:              ------------------ ------ ------ ------ --- ------------- ------- -------------
-; STMT_SEQ-NEXT:  0x00000043: 04 DW_LNS_set_file (0)
-; STMT_SEQ-NEXT:  0x00000045: 05 DW_LNS_set_column (9)
-; STMT_SEQ-NEXT:  0x00000047: 0a DW_LNS_set_prologue_end
-; STMT_SEQ-NEXT:  0x00000048: 00 DW_LNE_set_address (0x00000000)
-; STMT_SEQ-NEXT:  0x0000004f: 16 address += 0,  line += 4,  op-index += 0
-; STMT_SEQ-NEXT:              0x0000000000000000      5      9      0   0             0       0  is_stmt prologue_end
-; STMT_SEQ-NEXT:  0x00000050: 05 DW_LNS_set_column (3)
-; STMT_SEQ-NEXT:  0x00000052: 67 address += 6,  line += 1,  op-index += 0
-; STMT_SEQ-NEXT:              0x0000000000000006      6      3      0   0             0       0  is_stmt
-; STMT_SEQ-NEXT:  0x00000053: 00 DW_LNE_end_sequence
-; STMT_SEQ-NEXT:              0x0000000000000006      6      3      0   0             0       0  is_stmt end_sequence
-; STMT_SEQ-NEXT:  0x00000056: 04 DW_LNS_set_file (0)
-; STMT_SEQ-NEXT:  0x00000058: 00 DW_LNE_set_address (0x00000008)
-; STMT_SEQ-NEXT:  0x0000005f: 03 DW_LNS_advance_line (10)
-; STMT_SEQ-NEXT:  0x00000061: 01 DW_LNS_copy
-; STMT_SEQ-NEXT:              0x0000000000000008     10      0      0   0             0       0  is_stmt
-; STMT_SEQ-NEXT:  0x00000062: 05 DW_LNS_set_column (10)
-; STMT_SEQ-NEXT:  0x00000064: 0a DW_LNS_set_prologue_end
-; STMT_SEQ-NEXT:  0x00000065: 83 address += 8,  line += 1,  op-index += 0
-; STMT_SEQ-NEXT:              0x0000000000000010     11     10      0   0             0       0  is_stmt prologue_end
-; STMT_SEQ-NEXT:  0x00000066: 05 DW_LNS_set_column (3)
-; STMT_SEQ-NEXT:  0x00000068: 9f address += 10,  line += 1,  op-index += 0
-; STMT_SEQ-NEXT:              0x000000000000001a     12      3      0   0             0       0  is_stmt
-; STMT_SEQ-NEXT:  0x00000069: 02 DW_LNS_advance_pc (addr += 5, op-index += 0)
-; STMT_SEQ-NEXT:  0x0000006b: 00 DW_LNE_end_sequence
-; STMT_SEQ-NEXT:              0x000000000000001f     12      3      0   0             0       0  is_stmt end_sequence
+; STMT_SEQ:                  Address            Line   Column File   ISA Discriminator OpIndex Flags
+; STMT_SEQ-NEXT:             ------------------ ------ ------ ------ --- ------------- ------- -------------
+; STMT_SEQ-NEXT: 0x00000043: 04 DW_LNS_set_file (0)
+; STMT_SEQ-NEXT: 0x00000045: 05 DW_LNS_set_column (9)
+; STMT_SEQ-NEXT: 0x00000047: 0a DW_LNS_set_prologue_end
+; STMT_SEQ-NEXT: 0x00000048: 00 DW_LNE_set_address (0x00000000)
+; STMT_SEQ-NEXT: 0x0000004f: 16 address += 0,  line += 4,  op-index += 0
+; STMT_SEQ-NEXT:             0x0000000000000000      5      9      0   0             0       0  is_stmt prologue_end
+; STMT_SEQ-NEXT: 0x00000050: 05 DW_LNS_set_column (3)
+; STMT_SEQ-NEXT: 0x00000052: 67 address += 6,  line += 1,  op-index += 0
+; STMT_SEQ-NEXT:             0x0000000000000006      6      3      0   0             0       0  is_stmt
+; STMT_SEQ-NEXT: 0x00000053: 02 DW_LNS_advance_pc (addr += 2, op-index += 0)
+; STMT_SEQ-NEXT: 0x00000055: 00 DW_LNE_end_sequence
+; STMT_SEQ-NEXT:             0x0000000000000008      6      3      0   0             0       0  is_stmt end_sequence
+; STMT_SEQ-NEXT: 0x00000058: 04 DW_LNS_set_file (0)
+; STMT_SEQ-NEXT: 0x0000005a: 00 DW_LNE_set_address (0x00000008)
+; STMT_SEQ-NEXT: 0x00000061: 03 DW_LNS_advance_line (10)
+; STMT_SEQ-NEXT: 0x00000063: 01 DW_LNS_copy
+; STMT_SEQ-NEXT:             0x0000000000000008     10      0      0   0             0       0  is_stmt
+; STMT_SEQ-NEXT: 0x00000064: 05 DW_LNS_set_column (10)
+; STMT_SEQ-NEXT: 0x00000066: 0a DW_LNS_set_prologue_end
+; STMT_SEQ-NEXT: 0x00000067: 83 address += 8,  line += 1,  op-index += 0
+; STMT_SEQ-NEXT:             0x0000000000000010     11     10      0   0             0       0  is_stmt prologue_end
+; STMT_SEQ-NEXT: 0x00000068: 05 DW_LNS_set_column (3)
+; STMT_SEQ-NEXT: 0x0000006a: 9f address += 10,  line += 1,  op-index += 0
+; STMT_SEQ-NEXT:             0x000000000000001a     12      3      0   0             0       0  is_stmt
+; STMT_SEQ-NEXT: 0x0000006b: 02 DW_LNS_advance_pc (addr += 5, op-index += 0)
+; STMT_SEQ-NEXT: 0x0000006d: 00 DW_LNE_end_sequence
+; STMT_SEQ-NEXT:             0x000000000000001f     12      3      0   0             0       0  is_stmt end_sequence
 
 ; generated from:
 ; clang -Oz -g -S -emit-llvm test.c -o test.ll
diff --git a/llvm/test/MC/ELF/debug-loc-label.s b/llvm/test/MC/ELF/debug-loc-label.s
index 6b5d04777bef4..4200b1192107b 100644
--- a/llvm/test/MC/ELF/debug-loc-label.s
+++ b/llvm/test/MC/ELF/debug-loc-label.s
@@ -17,43 +17,47 @@
 # CHECK-LINE-TABLE-NEXT: 0x0000002a: 00 DW_LNE_set_address (0x0000000000000000)
 # CHECK-LINE-TABLE-NEXT: 0x00000035: 01 DW_LNS_copy
 # CHECK-LINE-TABLE-NEXT:             0x0000000000000000      1      1      1   0             0       0  is_stmt
-# CHECK-LINE-TABLE-NEXT: 0x00000036: 00 DW_LNE_end_sequence
-# CHECK-LINE-TABLE-NEXT:             0x0000000000000000      1      1      1   0             0       0  is_stmt end_sequence
-# CHECK-LINE-TABLE-NEXT: 0x00000039: 05 DW_LNS_set_column (2)
-# CHECK-LINE-TABLE-NEXT: 0x0000003b: 00 DW_LNE_set_address (0x0000000000000008)
-# CHECK-LINE-TABLE-NEXT: 0x00000046: 01 DW_LNS_copy
+# CHECK-LINE-TABLE-NEXT: 0x00000036: 02 DW_LNS_advance_pc (addr += 8, op-index += 0)
+# CHECK-LINE-TABLE-NEXT: 0x00000038: 00 DW_LNE_end_sequence
+# CHECK-LINE-TABLE-NEXT:             0x0000000000000008      1      1      1   0             0       0  is_stmt end_sequence
+# CHECK-LINE-TABLE-NEXT: 0x0000003b: 05 DW_LNS_set_column (2)
+# CHECK-LINE-TABLE-NEXT: 0x0000003d: 00 DW_LNE_set_address (0x0000000000000008)
+# CHECK-LINE-TABLE-NEXT: 0x00000048: 01 DW_LNS_copy
 # CHECK-LINE-TABLE-NEXT:             0x0000000000000008      1      2      1   0             0       0  is_stmt
-# CHECK-LINE-TABLE-NEXT: 0x00000047: 00 DW_LNE_end_sequence
-# CHECK-LINE-TABLE-NEXT:             0x0000000000000008      1      2      1   0             0       0  is_stmt end_sequence
-# CHECK-LINE-TABLE-NEXT: 0x0000004a: 05 DW_LNS_set_column (3)
-# CHECK-LINE-TABLE-NEXT: 0x0000004c: 00 DW_LNE_set_address (0x0000000000000010)
-# CHECK-LINE-TABLE-NEXT: 0x00000057: 01 DW_LNS_copy
+# CHECK-LINE-TABLE-NEXT: 0x00000049: 02 DW_LNS_advance_pc (addr += 8, op-index += 0)
+# CHECK-LINE-TABLE-NEXT: 0x0000004b: 00 DW_LNE_end_sequence
+# CHECK-LINE-TABLE-NEXT:             0x0000000000000010      1      2      1   0             0       0  is_stmt end_sequence
+# CHECK-LINE-TABLE-NEXT: 0x0000004e: 05 DW_LNS_set_column (3)
+# CHECK-LINE-TABLE-NEXT: 0x00000050: 00 DW_LNE_set_address (0x0000000000000010)
+# CHECK-LINE-TABLE-NEXT: 0x0000005b: 01 DW_LNS_copy
 # CHECK-LINE-TABLE-NEXT:             0x0000000000000010      1      3      1   0             0       0  is_stmt
-# CHECK-LINE-TABLE-NEXT: 0x00000058: 00 DW_LNE_end_sequence
-# CHECK-LINE-TABLE-NEXT:             0x0000000000000010      1      3      1   0             0       0  is_stmt end_sequence
-# CHECK-LINE-TABLE-NEXT: 0x0000005b: 05 DW_LNS_set_column (4)
-# CHECK-LINE-TABLE-NEXT: 0x0000005d: 00 DW_LNE_set_address (0x0000000000000018)
-# CHECK-LINE-TABLE-NEXT: 0x00000068: 01 DW_LNS_copy
+# CHECK-LINE-TABLE-NEXT: 0x0000005c: 02 DW_LNS_advance_pc (addr += 8, op-index += 0)
+# CHECK-LINE-TABLE-NEXT: 0x0000005e: 00 DW_LNE_end_sequence
+# CHECK-LINE-TABLE-NEXT:             0x0000000000000018      1      3      1   0             0       0  is_stmt end_sequence
+# CHECK-LINE-TABLE-NEXT: 0x00000061: 05 DW_LNS_set_column (4)
+# CHECK-LINE-TABLE-NEXT: 0x00000063: 00 DW_LNE_set_address (0x0000000000000018)
+# CHECK-LINE-TABLE-NEXT: 0x0000006e: 01 DW_LNS_copy
 # CHECK-LINE-TABLE-NEXT:             0x0000000000000018      1      4      1   0             0       0  is_stmt
-# CHECK-LINE-TABLE-NEXT: 0x00000069: 05 DW_LNS_set_column (5)
-# CHECK-LINE-TABLE-NEXT: 0x0000006b: 01 DW_LNS_copy
+# CHECK-LINE-TABLE-NEXT: 0x0000006f: 05 DW_LNS_set_column (5)
+# CHECK-LINE-TABLE-NEXT: 0x00000071: 01 DW_LNS_copy
 # CHECK-LINE-TABLE-NEXT:             0x0000000000000018      1      5      1   0             0       0  is_stmt
-# CHECK-LINE-TABLE-NEXT: 0x0000006c: 00 DW_LNE_end_sequence
-# CHECK-LINE-TABLE-NEXT:             0x0000000000000018      1      5      1   0             0       0  is_stmt end_sequence
+# CHECK-LINE-TABLE-NEXT: 0x00000072: 02 DW_LNS_advance_pc (addr += 8, op-index += 0)
+# CHECK-LINE-TABLE-NEXT: 0x00000074: 00 DW_LNE_end_sequence
+# CHECK-LINE-TABLE-NEXT:             0x0000000000000020      1      5      1   0             0       0  is_stmt end_sequence
 
 # CHECK-SYM:      Symbol table '.symtab' contains 9 entries:
 # CHECK-SYM-NEXT:    Num:    Value          Size Type    Bind   Vis       Ndx Name
 # CHECK-SYM-NEXT:      0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT   UND
 # CHECK-SYM-NEXT:      1: 0000000000000000     0 FILE    LOCAL  DEFAULT   ABS test.c
 # CHECK-SYM-NEXT:      2: 0000000000000000     0 SECTION LOCAL  DEFAULT     2 .text
-# CHECK-SYM-NEXT:      3: 0000000000000039     0 NOTYPE  LOCAL  DEFAULT     3 my_label_02
-# CHECK-SYM-NEXT:      4: 000000000000004a     0 NOTYPE  LOCAL  DEFAULT     3 my_label_03
-# CHECK-SYM-NEXT:      5: 000000000000005b     0 NOTYPE  LOCAL  DEFAULT     3 my_label_04
-# CHECK-SYM-NEXT:      6: 000000000000004a     0 NOTYPE  LOCAL  DEFAULT     3 my_label_03.1
-# CHECK-SYM-NEXT:      7: 000000000000006f     0 NOTYPE  LOCAL  DEFAULT     3 my_label_05
+# CHECK-SYM-NEXT:      3: 000000000000003b     0 NOTYPE  LOCAL  DEFAULT     3 my_label_02
+# CHECK-SYM-NEXT:      4: 000000000000004e     0 NOTYPE  LOCAL  DEFAULT     3 my_label_03
+# CHECK-SYM-NEXT:      5: 0000000000000061     0 NOTYPE  LOCAL  DEFAULT     3 my_label_04
+# CHECK-SYM-NEXT:      6: 000000000000004e     0 NOTYPE  LOCAL  DEFAULT     3 my_label_03.1
+# CHECK-SYM-NEXT:      7: 0000000000000077     0 NOTYPE  LOCAL  DEFAULT     3 my_label_05
 # CHECK-SYM-NEXT:      8: 0000000000000000     0 FUNC    GLOBAL DEFAULT     2 foo
 
-# CHECK-OFFSETS: 0000 39000000 4a000000 5b000000
+# CHECK-OFFSETS: 0000 3b000000 4e000000 61000000
 
 	.text
 	.file	"test.c"

>From ba688a874d37f7b60fbf3067c36ef3e4e08bc39d Mon Sep 17 00:00:00 2001
From: Peter Rong <PeterRong at meta.com>
Date: Mon, 8 Sep 2025 11:39:42 -0700
Subject: [PATCH 2/6] Format test to reduce diff size

Signed-off-by: Peter Rong <PeterRong at meta.com>
---
 .../X86/DW_AT_LLVM_stmt_seq_sec_offset.ll     | 58 +++++++++----------
 1 file changed, 29 insertions(+), 29 deletions(-)

diff --git a/llvm/test/DebugInfo/X86/DW_AT_LLVM_stmt_seq_sec_offset.ll b/llvm/test/DebugInfo/X86/DW_AT_LLVM_stmt_seq_sec_offset.ll
index 10059b7b30c20..f17c6e5429b6b 100644
--- a/llvm/test/DebugInfo/X86/DW_AT_LLVM_stmt_seq_sec_offset.ll
+++ b/llvm/test/DebugInfo/X86/DW_AT_LLVM_stmt_seq_sec_offset.ll
@@ -18,35 +18,35 @@
 ; STMT_SEQ:   DW_AT_name {{.*}}main
 
 ;; Check the entire line sequence to see that it's correct
-; STMT_SEQ:                  Address            Line   Column File   ISA Discriminator OpIndex Flags
-; STMT_SEQ-NEXT:             ------------------ ------ ------ ------ --- ------------- ------- -------------
-; STMT_SEQ-NEXT: 0x00000043: 04 DW_LNS_set_file (0)
-; STMT_SEQ-NEXT: 0x00000045: 05 DW_LNS_set_column (9)
-; STMT_SEQ-NEXT: 0x00000047: 0a DW_LNS_set_prologue_end
-; STMT_SEQ-NEXT: 0x00000048: 00 DW_LNE_set_address (0x00000000)
-; STMT_SEQ-NEXT: 0x0000004f: 16 address += 0,  line += 4,  op-index += 0
-; STMT_SEQ-NEXT:             0x0000000000000000      5      9      0   0             0       0  is_stmt prologue_end
-; STMT_SEQ-NEXT: 0x00000050: 05 DW_LNS_set_column (3)
-; STMT_SEQ-NEXT: 0x00000052: 67 address += 6,  line += 1,  op-index += 0
-; STMT_SEQ-NEXT:             0x0000000000000006      6      3      0   0             0       0  is_stmt
-; STMT_SEQ-NEXT: 0x00000053: 02 DW_LNS_advance_pc (addr += 2, op-index += 0)
-; STMT_SEQ-NEXT: 0x00000055: 00 DW_LNE_end_sequence
-; STMT_SEQ-NEXT:             0x0000000000000008      6      3      0   0             0       0  is_stmt end_sequence
-; STMT_SEQ-NEXT: 0x00000058: 04 DW_LNS_set_file (0)
-; STMT_SEQ-NEXT: 0x0000005a: 00 DW_LNE_set_address (0x00000008)
-; STMT_SEQ-NEXT: 0x00000061: 03 DW_LNS_advance_line (10)
-; STMT_SEQ-NEXT: 0x00000063: 01 DW_LNS_copy
-; STMT_SEQ-NEXT:             0x0000000000000008     10      0      0   0             0       0  is_stmt
-; STMT_SEQ-NEXT: 0x00000064: 05 DW_LNS_set_column (10)
-; STMT_SEQ-NEXT: 0x00000066: 0a DW_LNS_set_prologue_end
-; STMT_SEQ-NEXT: 0x00000067: 83 address += 8,  line += 1,  op-index += 0
-; STMT_SEQ-NEXT:             0x0000000000000010     11     10      0   0             0       0  is_stmt prologue_end
-; STMT_SEQ-NEXT: 0x00000068: 05 DW_LNS_set_column (3)
-; STMT_SEQ-NEXT: 0x0000006a: 9f address += 10,  line += 1,  op-index += 0
-; STMT_SEQ-NEXT:             0x000000000000001a     12      3      0   0             0       0  is_stmt
-; STMT_SEQ-NEXT: 0x0000006b: 02 DW_LNS_advance_pc (addr += 5, op-index += 0)
-; STMT_SEQ-NEXT: 0x0000006d: 00 DW_LNE_end_sequence
-; STMT_SEQ-NEXT:             0x000000000000001f     12      3      0   0             0       0  is_stmt end_sequence
+; STMT_SEQ:                   Address            Line   Column File   ISA Discriminator OpIndex Flags
+; STMT_SEQ-NEXT:              ------------------ ------ ------ ------ --- ------------- ------- -------------
+; STMT_SEQ-NEXT:  0x00000043: 04 DW_LNS_set_file (0)
+; STMT_SEQ-NEXT:  0x00000045: 05 DW_LNS_set_column (9)
+; STMT_SEQ-NEXT:  0x00000047: 0a DW_LNS_set_prologue_end
+; STMT_SEQ-NEXT:  0x00000048: 00 DW_LNE_set_address (0x00000000)
+; STMT_SEQ-NEXT:  0x0000004f: 16 address += 0,  line += 4,  op-index += 0
+; STMT_SEQ-NEXT:              0x0000000000000000      5      9      0   0             0       0  is_stmt prologue_end
+; STMT_SEQ-NEXT:  0x00000050: 05 DW_LNS_set_column (3)
+; STMT_SEQ-NEXT:  0x00000052: 67 address += 6,  line += 1,  op-index += 0
+; STMT_SEQ-NEXT:              0x0000000000000006      6      3      0   0             0       0  is_stmt
+; STMT_SEQ-NEXT:  0x00000053: 02 DW_LNS_advance_pc (addr += 2, op-index += 0)
+; STMT_SEQ-NEXT:  0x00000055: 00 DW_LNE_end_sequence
+; STMT_SEQ-NEXT:              0x0000000000000008      6      3      0   0             0       0  is_stmt end_sequence
+; STMT_SEQ-NEXT:  0x00000058: 04 DW_LNS_set_file (0)
+; STMT_SEQ-NEXT:  0x0000005a: 00 DW_LNE_set_address (0x00000008)
+; STMT_SEQ-NEXT:  0x00000061: 03 DW_LNS_advance_line (10)
+; STMT_SEQ-NEXT:  0x00000063: 01 DW_LNS_copy
+; STMT_SEQ-NEXT:              0x0000000000000008     10      0      0   0             0       0  is_stmt
+; STMT_SEQ-NEXT:  0x00000064: 05 DW_LNS_set_column (10)
+; STMT_SEQ-NEXT:  0x00000066: 0a DW_LNS_set_prologue_end
+; STMT_SEQ-NEXT:  0x00000067: 83 address += 8,  line += 1,  op-index += 0
+; STMT_SEQ-NEXT:              0x0000000000000010     11     10      0   0             0       0  is_stmt prologue_end
+; STMT_SEQ-NEXT:  0x00000068: 05 DW_LNS_set_column (3)
+; STMT_SEQ-NEXT:  0x0000006a: 9f address += 10,  line += 1,  op-index += 0
+; STMT_SEQ-NEXT:              0x000000000000001a     12      3      0   0             0       0  is_stmt
+; STMT_SEQ-NEXT:  0x0000006b: 02 DW_LNS_advance_pc (addr += 5, op-index += 0)
+; STMT_SEQ-NEXT:  0x0000006d: 00 DW_LNE_end_sequence
+; STMT_SEQ-NEXT:              0x000000000000001f     12      3      0   0             0       0  is_stmt end_sequence
 
 ; generated from:
 ; clang -Oz -g -S -emit-llvm test.c -o test.ll

>From 34bf79b56847b8e827e2230fb8c76fc5e7085224 Mon Sep 17 00:00:00 2001
From: Peter Rong <PeterRong at meta.com>
Date: Mon, 8 Sep 2025 16:29:53 -0700
Subject: [PATCH 3/6] Add a test for macho

---
 llvm/test/DebugInfo/ARM/stmt_seq_macho.test | 238 ++++++++++++++++++++
 1 file changed, 238 insertions(+)
 create mode 100644 llvm/test/DebugInfo/ARM/stmt_seq_macho.test

diff --git a/llvm/test/DebugInfo/ARM/stmt_seq_macho.test b/llvm/test/DebugInfo/ARM/stmt_seq_macho.test
new file mode 100644
index 0000000000000..a5733833edf79
--- /dev/null
+++ b/llvm/test/DebugInfo/ARM/stmt_seq_macho.test
@@ -0,0 +1,238 @@
+// RUN: split-file %s %t
+
+// RUN: clang++ --target=arm64-apple-macos11 \
+// RUN:   -x c++ %t/stmt_seq_macho.cpp \
+// RUN:   -o %t/stmt_seq_macho.o \
+// RUN:   -g -Oz -gdwarf-4 -c \
+// RUN:   -mllvm -emit-func-debug-line-table-offsets \
+// RUN:   -fdebug-compilation-dir=/private/tmp/stmt_seq \
+// RUN:   -fno-unwind-tables -fno-exceptions \
+// RUN:   -mno-outline
+
+// RUN: llvm-dwarfdump -all -v %t/stmt_seq_macho.o | FileCheck %s
+
+// CHECK: .debug_info
+// CHECK: DW_AT_LLVM_stmt_sequence [DW_FORM_sec_offset]    ([[EMPTY1:0x[0-9a-fA-F]{8}]])
+// CHECK: DW_AT_name [DW_FORM_strp]  ({{.*}} = "function_empty_1")
+
+// CHECK: DW_AT_LLVM_stmt_sequence [DW_FORM_sec_offset]    ([[EMPTY2:0x[0-9a-fA-F]{8}]])
+// CHECK: DW_AT_name [DW_FORM_strp]  ({{.*}} = "function_empty_2")
+
+// CHECK: DW_AT_LLVM_stmt_sequence [DW_FORM_sec_offset]    ([[EMPTY3:0x[0-9a-fA-F]{8}]])
+// CHECK: DW_AT_name [DW_FORM_strp]  ({{.*}} = "function_empty_3")
+
+// CHECK: DW_AT_LLVM_stmt_sequence [DW_FORM_sec_offset]    ([[F1CPY1:0x[0-9a-fA-F]{8}]])
+// CHECK: DW_AT_name [DW_FORM_strp]  ({{.*}} = "function1_copy1")
+
+// CHECK: DW_AT_LLVM_stmt_sequence [DW_FORM_sec_offset]    ([[F3CPY1:0x[0-9a-fA-F]{8}]])
+// CHECK: DW_AT_name [DW_FORM_strp]  ({{.*}} = "function3_copy1")
+
+// CHECK: DW_AT_LLVM_stmt_sequence [DW_FORM_sec_offset]    ([[F2CPY1:0x[0-9a-fA-F]{8}]])
+// CHECK: DW_AT_name [DW_FORM_strp]  ({{.*}} = "function2_copy1")
+
+// CHECK: DW_AT_LLVM_stmt_sequence [DW_FORM_sec_offset]    ([[F3CPY2:0x[0-9a-fA-F]{8}]])
+// CHECK: DW_AT_name [DW_FORM_strp]  ({{.*}} = "function3_copy2")
+
+// CHECK: DW_AT_LLVM_stmt_sequence [DW_FORM_sec_offset]    ([[F2CPY2:0x[0-9a-fA-F]{8}]])
+// CHECK: DW_AT_name [DW_FORM_strp]  ({{.*}} = "function2_copy2")
+
+// CHECK: DW_AT_LLVM_stmt_sequence [DW_FORM_sec_offset]    ([[FNMAIN:0x[0-9a-fA-F]{8}]])
+// CHECK: DW_AT_name [DW_FORM_strp]  ({{.*}} = "main")
+
+// CHECK: DW_AT_LLVM_stmt_sequence [DW_FORM_sec_offset]    ([[ERRLOG:0x[0-9a-fA-F]{8}]])
+// CHECK: DW_AT_linkage_name [DW_FORM_strp]  ({{.*}} = "_ZN12length_errorC1EPKc")
+
+// CHECK: DW_AT_LLVM_stmt_sequence [DW_FORM_sec_offset]    ([[ERRLEN:0x[0-9a-fA-F]{8}]])
+// CHECK: DW_AT_linkage_name [DW_FORM_strp]  ({{.*}} = "_ZN12length_errorC2EPKc")
+
+// CHECK:                  Address            Line   Column File   ISA Discriminator OpIndex Flags
+// CHECK-NEXT:             ------------------ ------ ------ ------ --- ------------- ------- -------------
+// CHECK-NEXT: [[EMPTY1]]: 05 DW_LNS_set_column (33)
+// CHECK-NEXT: 0x00000091: 0a DW_LNS_set_prologue_end
+// CHECK-NEXT: 0x00000092: 00 DW_LNE_set_address (0x0000000000000000)
+// CHECK-NEXT: 0x0000009d: 13 address += 0,  line += 1,  op-index += 0
+// CHECK-NEXT:             0x0000000000000000      2     33      1   0             0       0  is_stmt prologue_end
+// CHECK-NEXT: 0x0000009e: 02 DW_LNS_advance_pc (addr += 4, op-index += 0)
+// CHECK-NEXT: 0x000000a0: 00 DW_LNE_end_sequence
+// CHECK-NEXT:             0x0000000000000004      2     33      1   0             0       0  is_stmt end_sequence
+// CHECK-NEXT: [[EMPTY2]]: 05 DW_LNS_set_column (33)
+// CHECK-NEXT: 0x000000a5: 0a DW_LNS_set_prologue_end
+// CHECK-NEXT: 0x000000a6: 00 DW_LNE_set_address (0x0000000000000004)
+// CHECK-NEXT: 0x000000b1: 14 address += 0,  line += 2,  op-index += 0
+// CHECK-NEXT:             0x0000000000000004      3     33      1   0             0       0  is_stmt prologue_end
+// CHECK-NEXT: 0x000000b2: 02 DW_LNS_advance_pc (addr += 4, op-index += 0)
+// CHECK-NEXT: 0x000000b4: 00 DW_LNE_end_sequence
+// CHECK-NEXT:             0x0000000000000008      3     33      1   0             0       0  is_stmt end_sequence
+// CHECK-NEXT: [[EMPTY3]]: 05 DW_LNS_set_column (33)
+// CHECK-NEXT: 0x000000b9: 0a DW_LNS_set_prologue_end
+// CHECK-NEXT: 0x000000ba: 00 DW_LNE_set_address (0x0000000000000008)
+// CHECK-NEXT: 0x000000c5: 15 address += 0,  line += 3,  op-index += 0
+// CHECK-NEXT:             0x0000000000000008      4     33      1   0             0       0  is_stmt prologue_end
+// CHECK-NEXT: 0x000000c6: 02 DW_LNS_advance_pc (addr += 4, op-index += 0)
+// CHECK-NEXT: 0x000000c8: 00 DW_LNE_end_sequence
+// CHECK-NEXT:             0x000000000000000c      4     33      1   0             0       0  is_stmt end_sequence
+// CHECK-NEXT: [[F1CPY1]]: 05 DW_LNS_set_column (10)
+// CHECK-NEXT: 0x000000cd: 0a DW_LNS_set_prologue_end
+// CHECK-NEXT: 0x000000ce: 00 DW_LNE_set_address (0x000000000000000c)
+// CHECK-NEXT: 0x000000d9: 18 address += 0,  line += 6,  op-index += 0
+// CHECK-NEXT:             0x000000000000000c      7     10      1   0             0       0  is_stmt prologue_end
+// CHECK-NEXT: 0x000000da: 05 DW_LNS_set_column (3)
+// CHECK-NEXT: 0x000000dc: 06 DW_LNS_negate_stmt
+// CHECK-NEXT: 0x000000dd: 4a address += 4,  line += 0,  op-index += 0
+// CHECK-NEXT:             0x0000000000000010      7      3      1   0             0       0
+// CHECK-NEXT: 0x000000de: 02 DW_LNS_advance_pc (addr += 4, op-index += 0)
+// CHECK-NEXT: 0x000000e0: 00 DW_LNE_end_sequence
+// CHECK-NEXT:             0x0000000000000014      7      3      1   0             0       0  end_sequence
+// CHECK-NEXT: [[F3CPY1]]: 05 DW_LNS_set_column (14)
+// CHECK-NEXT: 0x000000e5: 0a DW_LNS_set_prologue_end
+// CHECK-NEXT: 0x000000e6: 00 DW_LNE_set_address (0x0000000000000014)
+// CHECK-NEXT: 0x000000f1: 03 DW_LNS_advance_line (12)
+// CHECK-NEXT: 0x000000f3: 01 DW_LNS_copy
+// CHECK-NEXT:             0x0000000000000014     12     14      1   0             0       0  is_stmt prologue_end
+// CHECK-NEXT: 0x000000f4: 05 DW_LNS_set_column (5)
+// CHECK-NEXT: 0x000000f6: 06 DW_LNS_negate_stmt
+// CHECK-NEXT: 0x000000f7: 4a address += 4,  line += 0,  op-index += 0
+// CHECK-NEXT:             0x0000000000000018     12      5      1   0             0       0
+// CHECK-NEXT: 0x000000f8: 02 DW_LNS_advance_pc (addr += 4, op-index += 0)
+// CHECK-NEXT: 0x000000fa: 00 DW_LNE_end_sequence
+// CHECK-NEXT:             0x000000000000001c     12      5      1   0             0       0  end_sequence
+// CHECK-NEXT: [[F2CPY1]]: 05 DW_LNS_set_column (14)
+// CHECK-NEXT: 0x000000ff: 0a DW_LNS_set_prologue_end
+// CHECK-NEXT: 0x00000100: 00 DW_LNE_set_address (0x000000000000001c)
+// CHECK-NEXT: 0x0000010b: 03 DW_LNS_advance_line (16)
+// CHECK-NEXT: 0x0000010d: 01 DW_LNS_copy
+// CHECK-NEXT:             0x000000000000001c     16     14      1   0             0       0  is_stmt prologue_end
+// CHECK-NEXT: 0x0000010e: 05 DW_LNS_set_column (5)
+// CHECK-NEXT: 0x00000110: 06 DW_LNS_negate_stmt
+// CHECK-NEXT: 0x00000111: 4a address += 4,  line += 0,  op-index += 0
+// CHECK-NEXT:             0x0000000000000020     16      5      1   0             0       0
+// CHECK-NEXT: 0x00000112: 02 DW_LNS_advance_pc (addr += 4, op-index += 0)
+// CHECK-NEXT: 0x00000114: 00 DW_LNE_end_sequence
+// CHECK-NEXT:             0x0000000000000024     16      5      1   0             0       0  end_sequence
+// CHECK-NEXT: [[F3CPY2]]: 05 DW_LNS_set_column (14)
+// CHECK-NEXT: 0x00000119: 0a DW_LNS_set_prologue_end
+// CHECK-NEXT: 0x0000011a: 00 DW_LNE_set_address (0x0000000000000024)
+// CHECK-NEXT: 0x00000125: 03 DW_LNS_advance_line (21)
+// CHECK-NEXT: 0x00000127: 01 DW_LNS_copy
+// CHECK-NEXT:             0x0000000000000024     21     14      1   0             0       0  is_stmt prologue_end
+// CHECK-NEXT: 0x00000128: 05 DW_LNS_set_column (5)
+// CHECK-NEXT: 0x0000012a: 06 DW_LNS_negate_stmt
+// CHECK-NEXT: 0x0000012b: 4a address += 4,  line += 0,  op-index += 0
+// CHECK-NEXT:             0x0000000000000028     21      5      1   0             0       0
+// CHECK-NEXT: 0x0000012c: 02 DW_LNS_advance_pc (addr += 4, op-index += 0)
+// CHECK-NEXT: 0x0000012e: 00 DW_LNE_end_sequence
+// CHECK-NEXT:             0x000000000000002c     21      5      1   0             0       0  end_sequence
+// CHECK-NEXT: [[F2CPY2]]: 05 DW_LNS_set_column (20)
+// CHECK-NEXT: 0x00000133: 0a DW_LNS_set_prologue_end
+// CHECK-NEXT: 0x00000134: 00 DW_LNE_set_address (0x000000000000002c)
+// CHECK-NEXT: 0x0000013f: 03 DW_LNS_advance_line (25)
+// CHECK-NEXT: 0x00000141: 01 DW_LNS_copy
+// CHECK-NEXT:             0x000000000000002c     25     20      1   0             0       0  is_stmt prologue_end
+// CHECK-NEXT: 0x00000142: 05 DW_LNS_set_column (5)
+// CHECK-NEXT: 0x00000144: 4b address += 4,  line += 1,  op-index += 0
+// CHECK-NEXT:             0x0000000000000030     26      5      1   0             0       0  is_stmt
+// CHECK-NEXT: 0x00000145: 02 DW_LNS_advance_pc (addr += 4, op-index += 0)
+// CHECK-NEXT: 0x00000147: 00 DW_LNE_end_sequence
+// CHECK-NEXT:             0x0000000000000034     26      5      1   0             0       0  is_stmt end_sequence
+// CHECK-NEXT: [[FNMAIN]]: 00 DW_LNE_set_address (0x0000000000000034)
+// CHECK-NEXT: 0x00000155: 03 DW_LNS_advance_line (37)
+// CHECK-NEXT: 0x00000157: 01 DW_LNS_copy
+// CHECK-NEXT:             0x0000000000000034     37      0      1   0             0       0  is_stmt
+// CHECK-NEXT: 0x00000158: 05 DW_LNS_set_column (12)
+// CHECK-NEXT: 0x0000015a: 0a DW_LNS_set_prologue_end
+// CHECK-NEXT: 0x0000015b: f4 address += 16,  line += 2,  op-index += 0
+// CHECK-NEXT:             0x0000000000000044     39     12      1   0             0       0  is_stmt prologue_end
+// CHECK-NEXT: 0x0000015c: bb address += 12,  line += 1,  op-index += 0
+// CHECK-NEXT:             0x0000000000000050     40     12      1   0             0       0  is_stmt
+// CHECK-NEXT: 0x0000015d: 05 DW_LNS_set_column (9)
+// CHECK-NEXT: 0x0000015f: 82 address += 8,  line += 0,  op-index += 0
+// CHECK-NEXT:             0x0000000000000058     40      9      1   0             0       0  is_stmt
+// CHECK-NEXT: 0x00000160: 05 DW_LNS_set_column (12)
+// CHECK-NEXT: 0x00000162: 4b address += 4,  line += 1,  op-index += 0
+// CHECK-NEXT:             0x000000000000005c     41     12      1   0             0       0  is_stmt
+// CHECK-NEXT: 0x00000163: bb address += 12,  line += 1,  op-index += 0
+// CHECK-NEXT:             0x0000000000000068     42     12      1   0             0       0  is_stmt
+// CHECK-NEXT: 0x00000164: 05 DW_LNS_set_column (9)
+// CHECK-NEXT: 0x00000166: 81 address += 8,  line += -1,  op-index += 0
+// CHECK-NEXT:             0x0000000000000070     41      9      1   0             0       0  is_stmt
+// CHECK-NEXT: 0x00000167: 05 DW_LNS_set_column (18)
+// CHECK-NEXT: 0x00000169: 4f address += 4,  line += 5,  op-index += 0
+// CHECK-NEXT:             0x0000000000000074     46     18      1   0             0       0  is_stmt
+// CHECK-NEXT: 0x0000016a: 05 DW_LNS_set_column (9)
+// CHECK-NEXT: 0x0000016c: ee address += 16,  line += -4,  op-index += 0
+// CHECK-NEXT:             0x0000000000000084     42      9      1   0             0       0  is_stmt
+// CHECK-NEXT: 0x0000016d: 05 DW_LNS_set_column (5)
+// CHECK-NEXT: 0x0000016f: 0b DW_LNS_set_epilogue_begin
+// CHECK-NEXT: 0x00000170: 4f address += 4,  line += 5,  op-index += 0
+// CHECK-NEXT:             0x0000000000000088     47      5      1   0             0       0  is_stmt epilogue_begin
+// CHECK-NEXT: 0x00000171: 02 DW_LNS_advance_pc (addr += 16, op-index += 0)
+// CHECK-NEXT: 0x00000173: 00 DW_LNE_end_sequence
+// CHECK-NEXT:             0x0000000000000098     47      5      1   0             0       0  is_stmt end_sequence
+// CHECK-NEXT: [[ERRLOG]]: 05 DW_LNS_set_column (85)
+// CHECK-NEXT: 0x00000178: 0a DW_LNS_set_prologue_end
+// CHECK-NEXT: 0x00000179: 00 DW_LNE_set_address (0x0000000000000098)
+// CHECK-NEXT: 0x00000184: 03 DW_LNS_advance_line (34)
+// CHECK-NEXT: 0x00000186: 01 DW_LNS_copy
+// CHECK-NEXT:             0x0000000000000098     34     85      1   0             0       0  is_stmt prologue_end
+// CHECK-NEXT: 0x00000187: 02 DW_LNS_advance_pc (addr += 4, op-index += 0)
+// CHECK-NEXT: 0x00000189: 00 DW_LNE_end_sequence
+// CHECK-NEXT:             0x000000000000009c     34     85      1   0             0       0  is_stmt end_sequence
+// CHECK-NEXT: [[ERRLEN]]: 05 DW_LNS_set_column (86)
+// CHECK-NEXT: 0x0000018e: 0a DW_LNS_set_prologue_end
+// CHECK-NEXT: 0x0000018f: 00 DW_LNE_set_address (0x000000000000009c)
+// CHECK-NEXT: 0x0000019a: 03 DW_LNS_advance_line (34)
+// CHECK-NEXT: 0x0000019c: 01 DW_LNS_copy
+// CHECK-NEXT:             0x000000000000009c     34     86      1   0             0       0  is_stmt prologue_end
+// CHECK-NEXT: 0x0000019d: 02 DW_LNS_advance_pc (addr += 4, op-index += 0)
+// CHECK-NEXT: 0x0000019f: 00 DW_LNE_end_sequence
+// CHECK-NEXT: 0x00000000000000a0     34     86      1   0             0       0  is_stmt end_sequence
+
+#--- stmt_seq_macho.cpp
+#define ATTRIB extern "C" __attribute__((noinline))
+ATTRIB void function_empty_1() {}
+ATTRIB void function_empty_2() {}
+ATTRIB void function_empty_3() {}
+
+ATTRIB int function1_copy1(int a) {
+  return ++a;
+}
+
+ATTRIB int function3_copy1(int a) {
+    int b = a + 3;
+    return b + 1;
+}
+
+ATTRIB int function2_copy1(int a) {
+    return a - 22;
+}
+
+ATTRIB int function3_copy2(int a) {
+    int b = a + 3;
+    return b + 1;
+}
+
+ATTRIB int function2_copy2(int a) {
+    int result = a - 22;
+    return result;
+}
+
+struct logic_error {
+    logic_error(const char* s) {}
+};
+
+struct length_error : public logic_error {
+    __attribute__((noinline)) explicit length_error(const char* s) : logic_error(s) {}
+};
+
+int main() {
+    int sum = 0;
+    sum += function2_copy2(3);
+    sum += function3_copy2(41);
+    sum += function2_copy1(11);
+    sum += function1_copy1(42);
+    function_empty_1();
+    function_empty_2();
+    function_empty_3();
+    length_error e("test");
+    return sum;
+}

>From a3a64e65e2c0aeee0ba655255b65eeb665c6c654 Mon Sep 17 00:00:00 2001
From: Peter Rong <PeterRong at meta.com>
Date: Mon, 8 Sep 2025 20:31:27 -0700
Subject: [PATCH 4/6] Verify metadata

---
 llvm/test/DebugInfo/ARM/stmt_seq_macho.test | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/llvm/test/DebugInfo/ARM/stmt_seq_macho.test b/llvm/test/DebugInfo/ARM/stmt_seq_macho.test
index a5733833edf79..2a3dbbc3b43e0 100644
--- a/llvm/test/DebugInfo/ARM/stmt_seq_macho.test
+++ b/llvm/test/DebugInfo/ARM/stmt_seq_macho.test
@@ -45,6 +45,20 @@
 // CHECK: DW_AT_LLVM_stmt_sequence [DW_FORM_sec_offset]    ([[ERRLEN:0x[0-9a-fA-F]{8}]])
 // CHECK: DW_AT_linkage_name [DW_FORM_strp]  ({{.*}} = "_ZN12length_errorC2EPKc")
 
+// CHECK:      .debug_line contents:
+// CHECK-NEXT: debug_line[0x00000000]
+// CHECK-NEXT: Line table prologue:
+// CHECK-NEXT:     total_length: 0x0000019e
+// CHECK-NEXT:           format: DWARF32
+// CHECK-NEXT:          version: 4
+// CHECK-NEXT:  prologue_length: 0x00000085
+// CHECK-NEXT:  min_inst_length: 1
+// CHECK-NEXT: max_ops_per_inst: 1
+// CHECK-NEXT:  default_is_stmt: 1
+// CHECK-NEXT:        line_base: -5
+// CHECK-NEXT:       line_range: 14
+// CHECK-NEXT:      opcode_base: 13
+
 // CHECK:                  Address            Line   Column File   ISA Discriminator OpIndex Flags
 // CHECK-NEXT:             ------------------ ------ ------ ------ --- ------------- ------- -------------
 // CHECK-NEXT: [[EMPTY1]]: 05 DW_LNS_set_column (33)

>From 5445f546f60a4b12acbadfeaa4342d53952cba26 Mon Sep 17 00:00:00 2001
From: Peter Rong <PeterRong at meta.com>
Date: Mon, 8 Sep 2025 21:27:22 -0700
Subject: [PATCH 5/6] Update test

---
 llvm/test/DebugInfo/ARM/stmt_seq_macho.test | 162 +-------------------
 1 file changed, 4 insertions(+), 158 deletions(-)

diff --git a/llvm/test/DebugInfo/ARM/stmt_seq_macho.test b/llvm/test/DebugInfo/ARM/stmt_seq_macho.test
index 2a3dbbc3b43e0..f0874bfc45ed2 100644
--- a/llvm/test/DebugInfo/ARM/stmt_seq_macho.test
+++ b/llvm/test/DebugInfo/ARM/stmt_seq_macho.test
@@ -1,205 +1,51 @@
 // RUN: split-file %s %t
 
 // RUN: clang++ --target=arm64-apple-macos11 \
-// RUN:   -x c++ %t/stmt_seq_macho.cpp \
-// RUN:   -o %t/stmt_seq_macho.o \
-// RUN:   -g -Oz -gdwarf-4 -c \
+// RUN:   %t/stmt_seq_macho.cpp -o %t/stmt_seq_macho.o \
+// RUN:   -g -Oz -gdwarf-4 -c -mno-outline \
 // RUN:   -mllvm -emit-func-debug-line-table-offsets \
 // RUN:   -fdebug-compilation-dir=/private/tmp/stmt_seq \
-// RUN:   -fno-unwind-tables -fno-exceptions \
-// RUN:   -mno-outline
+// RUN:   -fno-unwind-tables -fno-exceptions
 
-// RUN: llvm-dwarfdump -all -v %t/stmt_seq_macho.o | FileCheck %s
-
-// CHECK: .debug_info
-// CHECK: DW_AT_LLVM_stmt_sequence [DW_FORM_sec_offset]    ([[EMPTY1:0x[0-9a-fA-F]{8}]])
-// CHECK: DW_AT_name [DW_FORM_strp]  ({{.*}} = "function_empty_1")
-
-// CHECK: DW_AT_LLVM_stmt_sequence [DW_FORM_sec_offset]    ([[EMPTY2:0x[0-9a-fA-F]{8}]])
-// CHECK: DW_AT_name [DW_FORM_strp]  ({{.*}} = "function_empty_2")
-
-// CHECK: DW_AT_LLVM_stmt_sequence [DW_FORM_sec_offset]    ([[EMPTY3:0x[0-9a-fA-F]{8}]])
-// CHECK: DW_AT_name [DW_FORM_strp]  ({{.*}} = "function_empty_3")
-
-// CHECK: DW_AT_LLVM_stmt_sequence [DW_FORM_sec_offset]    ([[F1CPY1:0x[0-9a-fA-F]{8}]])
-// CHECK: DW_AT_name [DW_FORM_strp]  ({{.*}} = "function1_copy1")
-
-// CHECK: DW_AT_LLVM_stmt_sequence [DW_FORM_sec_offset]    ([[F3CPY1:0x[0-9a-fA-F]{8}]])
-// CHECK: DW_AT_name [DW_FORM_strp]  ({{.*}} = "function3_copy1")
-
-// CHECK: DW_AT_LLVM_stmt_sequence [DW_FORM_sec_offset]    ([[F2CPY1:0x[0-9a-fA-F]{8}]])
-// CHECK: DW_AT_name [DW_FORM_strp]  ({{.*}} = "function2_copy1")
-
-// CHECK: DW_AT_LLVM_stmt_sequence [DW_FORM_sec_offset]    ([[F3CPY2:0x[0-9a-fA-F]{8}]])
-// CHECK: DW_AT_name [DW_FORM_strp]  ({{.*}} = "function3_copy2")
-
-// CHECK: DW_AT_LLVM_stmt_sequence [DW_FORM_sec_offset]    ([[F2CPY2:0x[0-9a-fA-F]{8}]])
-// CHECK: DW_AT_name [DW_FORM_strp]  ({{.*}} = "function2_copy2")
-
-// CHECK: DW_AT_LLVM_stmt_sequence [DW_FORM_sec_offset]    ([[FNMAIN:0x[0-9a-fA-F]{8}]])
-// CHECK: DW_AT_name [DW_FORM_strp]  ({{.*}} = "main")
-
-// CHECK: DW_AT_LLVM_stmt_sequence [DW_FORM_sec_offset]    ([[ERRLOG:0x[0-9a-fA-F]{8}]])
-// CHECK: DW_AT_linkage_name [DW_FORM_strp]  ({{.*}} = "_ZN12length_errorC1EPKc")
-
-// CHECK: DW_AT_LLVM_stmt_sequence [DW_FORM_sec_offset]    ([[ERRLEN:0x[0-9a-fA-F]{8}]])
-// CHECK: DW_AT_linkage_name [DW_FORM_strp]  ({{.*}} = "_ZN12length_errorC2EPKc")
-
-// CHECK:      .debug_line contents:
-// CHECK-NEXT: debug_line[0x00000000]
-// CHECK-NEXT: Line table prologue:
-// CHECK-NEXT:     total_length: 0x0000019e
-// CHECK-NEXT:           format: DWARF32
-// CHECK-NEXT:          version: 4
-// CHECK-NEXT:  prologue_length: 0x00000085
-// CHECK-NEXT:  min_inst_length: 1
-// CHECK-NEXT: max_ops_per_inst: 1
-// CHECK-NEXT:  default_is_stmt: 1
-// CHECK-NEXT:        line_base: -5
-// CHECK-NEXT:       line_range: 14
-// CHECK-NEXT:      opcode_base: 13
+// RUN: llvm-dwarfdump -all %t/stmt_seq_macho.o | FileCheck %s
 
 // CHECK:                  Address            Line   Column File   ISA Discriminator OpIndex Flags
 // CHECK-NEXT:             ------------------ ------ ------ ------ --- ------------- ------- -------------
-// CHECK-NEXT: [[EMPTY1]]: 05 DW_LNS_set_column (33)
-// CHECK-NEXT: 0x00000091: 0a DW_LNS_set_prologue_end
-// CHECK-NEXT: 0x00000092: 00 DW_LNE_set_address (0x0000000000000000)
-// CHECK-NEXT: 0x0000009d: 13 address += 0,  line += 1,  op-index += 0
 // CHECK-NEXT:             0x0000000000000000      2     33      1   0             0       0  is_stmt prologue_end
-// CHECK-NEXT: 0x0000009e: 02 DW_LNS_advance_pc (addr += 4, op-index += 0)
-// CHECK-NEXT: 0x000000a0: 00 DW_LNE_end_sequence
 // CHECK-NEXT:             0x0000000000000004      2     33      1   0             0       0  is_stmt end_sequence
-// CHECK-NEXT: [[EMPTY2]]: 05 DW_LNS_set_column (33)
-// CHECK-NEXT: 0x000000a5: 0a DW_LNS_set_prologue_end
-// CHECK-NEXT: 0x000000a6: 00 DW_LNE_set_address (0x0000000000000004)
-// CHECK-NEXT: 0x000000b1: 14 address += 0,  line += 2,  op-index += 0
 // CHECK-NEXT:             0x0000000000000004      3     33      1   0             0       0  is_stmt prologue_end
-// CHECK-NEXT: 0x000000b2: 02 DW_LNS_advance_pc (addr += 4, op-index += 0)
-// CHECK-NEXT: 0x000000b4: 00 DW_LNE_end_sequence
 // CHECK-NEXT:             0x0000000000000008      3     33      1   0             0       0  is_stmt end_sequence
-// CHECK-NEXT: [[EMPTY3]]: 05 DW_LNS_set_column (33)
-// CHECK-NEXT: 0x000000b9: 0a DW_LNS_set_prologue_end
-// CHECK-NEXT: 0x000000ba: 00 DW_LNE_set_address (0x0000000000000008)
-// CHECK-NEXT: 0x000000c5: 15 address += 0,  line += 3,  op-index += 0
 // CHECK-NEXT:             0x0000000000000008      4     33      1   0             0       0  is_stmt prologue_end
-// CHECK-NEXT: 0x000000c6: 02 DW_LNS_advance_pc (addr += 4, op-index += 0)
-// CHECK-NEXT: 0x000000c8: 00 DW_LNE_end_sequence
 // CHECK-NEXT:             0x000000000000000c      4     33      1   0             0       0  is_stmt end_sequence
-// CHECK-NEXT: [[F1CPY1]]: 05 DW_LNS_set_column (10)
-// CHECK-NEXT: 0x000000cd: 0a DW_LNS_set_prologue_end
-// CHECK-NEXT: 0x000000ce: 00 DW_LNE_set_address (0x000000000000000c)
-// CHECK-NEXT: 0x000000d9: 18 address += 0,  line += 6,  op-index += 0
 // CHECK-NEXT:             0x000000000000000c      7     10      1   0             0       0  is_stmt prologue_end
-// CHECK-NEXT: 0x000000da: 05 DW_LNS_set_column (3)
-// CHECK-NEXT: 0x000000dc: 06 DW_LNS_negate_stmt
-// CHECK-NEXT: 0x000000dd: 4a address += 4,  line += 0,  op-index += 0
 // CHECK-NEXT:             0x0000000000000010      7      3      1   0             0       0
-// CHECK-NEXT: 0x000000de: 02 DW_LNS_advance_pc (addr += 4, op-index += 0)
-// CHECK-NEXT: 0x000000e0: 00 DW_LNE_end_sequence
 // CHECK-NEXT:             0x0000000000000014      7      3      1   0             0       0  end_sequence
-// CHECK-NEXT: [[F3CPY1]]: 05 DW_LNS_set_column (14)
-// CHECK-NEXT: 0x000000e5: 0a DW_LNS_set_prologue_end
-// CHECK-NEXT: 0x000000e6: 00 DW_LNE_set_address (0x0000000000000014)
-// CHECK-NEXT: 0x000000f1: 03 DW_LNS_advance_line (12)
-// CHECK-NEXT: 0x000000f3: 01 DW_LNS_copy
 // CHECK-NEXT:             0x0000000000000014     12     14      1   0             0       0  is_stmt prologue_end
-// CHECK-NEXT: 0x000000f4: 05 DW_LNS_set_column (5)
-// CHECK-NEXT: 0x000000f6: 06 DW_LNS_negate_stmt
-// CHECK-NEXT: 0x000000f7: 4a address += 4,  line += 0,  op-index += 0
 // CHECK-NEXT:             0x0000000000000018     12      5      1   0             0       0
-// CHECK-NEXT: 0x000000f8: 02 DW_LNS_advance_pc (addr += 4, op-index += 0)
-// CHECK-NEXT: 0x000000fa: 00 DW_LNE_end_sequence
 // CHECK-NEXT:             0x000000000000001c     12      5      1   0             0       0  end_sequence
-// CHECK-NEXT: [[F2CPY1]]: 05 DW_LNS_set_column (14)
-// CHECK-NEXT: 0x000000ff: 0a DW_LNS_set_prologue_end
-// CHECK-NEXT: 0x00000100: 00 DW_LNE_set_address (0x000000000000001c)
-// CHECK-NEXT: 0x0000010b: 03 DW_LNS_advance_line (16)
-// CHECK-NEXT: 0x0000010d: 01 DW_LNS_copy
 // CHECK-NEXT:             0x000000000000001c     16     14      1   0             0       0  is_stmt prologue_end
-// CHECK-NEXT: 0x0000010e: 05 DW_LNS_set_column (5)
-// CHECK-NEXT: 0x00000110: 06 DW_LNS_negate_stmt
-// CHECK-NEXT: 0x00000111: 4a address += 4,  line += 0,  op-index += 0
 // CHECK-NEXT:             0x0000000000000020     16      5      1   0             0       0
-// CHECK-NEXT: 0x00000112: 02 DW_LNS_advance_pc (addr += 4, op-index += 0)
-// CHECK-NEXT: 0x00000114: 00 DW_LNE_end_sequence
 // CHECK-NEXT:             0x0000000000000024     16      5      1   0             0       0  end_sequence
-// CHECK-NEXT: [[F3CPY2]]: 05 DW_LNS_set_column (14)
-// CHECK-NEXT: 0x00000119: 0a DW_LNS_set_prologue_end
-// CHECK-NEXT: 0x0000011a: 00 DW_LNE_set_address (0x0000000000000024)
-// CHECK-NEXT: 0x00000125: 03 DW_LNS_advance_line (21)
-// CHECK-NEXT: 0x00000127: 01 DW_LNS_copy
 // CHECK-NEXT:             0x0000000000000024     21     14      1   0             0       0  is_stmt prologue_end
-// CHECK-NEXT: 0x00000128: 05 DW_LNS_set_column (5)
-// CHECK-NEXT: 0x0000012a: 06 DW_LNS_negate_stmt
-// CHECK-NEXT: 0x0000012b: 4a address += 4,  line += 0,  op-index += 0
 // CHECK-NEXT:             0x0000000000000028     21      5      1   0             0       0
-// CHECK-NEXT: 0x0000012c: 02 DW_LNS_advance_pc (addr += 4, op-index += 0)
-// CHECK-NEXT: 0x0000012e: 00 DW_LNE_end_sequence
 // CHECK-NEXT:             0x000000000000002c     21      5      1   0             0       0  end_sequence
-// CHECK-NEXT: [[F2CPY2]]: 05 DW_LNS_set_column (20)
-// CHECK-NEXT: 0x00000133: 0a DW_LNS_set_prologue_end
-// CHECK-NEXT: 0x00000134: 00 DW_LNE_set_address (0x000000000000002c)
-// CHECK-NEXT: 0x0000013f: 03 DW_LNS_advance_line (25)
-// CHECK-NEXT: 0x00000141: 01 DW_LNS_copy
 // CHECK-NEXT:             0x000000000000002c     25     20      1   0             0       0  is_stmt prologue_end
-// CHECK-NEXT: 0x00000142: 05 DW_LNS_set_column (5)
-// CHECK-NEXT: 0x00000144: 4b address += 4,  line += 1,  op-index += 0
 // CHECK-NEXT:             0x0000000000000030     26      5      1   0             0       0  is_stmt
-// CHECK-NEXT: 0x00000145: 02 DW_LNS_advance_pc (addr += 4, op-index += 0)
-// CHECK-NEXT: 0x00000147: 00 DW_LNE_end_sequence
 // CHECK-NEXT:             0x0000000000000034     26      5      1   0             0       0  is_stmt end_sequence
-// CHECK-NEXT: [[FNMAIN]]: 00 DW_LNE_set_address (0x0000000000000034)
-// CHECK-NEXT: 0x00000155: 03 DW_LNS_advance_line (37)
-// CHECK-NEXT: 0x00000157: 01 DW_LNS_copy
 // CHECK-NEXT:             0x0000000000000034     37      0      1   0             0       0  is_stmt
-// CHECK-NEXT: 0x00000158: 05 DW_LNS_set_column (12)
-// CHECK-NEXT: 0x0000015a: 0a DW_LNS_set_prologue_end
-// CHECK-NEXT: 0x0000015b: f4 address += 16,  line += 2,  op-index += 0
 // CHECK-NEXT:             0x0000000000000044     39     12      1   0             0       0  is_stmt prologue_end
-// CHECK-NEXT: 0x0000015c: bb address += 12,  line += 1,  op-index += 0
 // CHECK-NEXT:             0x0000000000000050     40     12      1   0             0       0  is_stmt
-// CHECK-NEXT: 0x0000015d: 05 DW_LNS_set_column (9)
-// CHECK-NEXT: 0x0000015f: 82 address += 8,  line += 0,  op-index += 0
 // CHECK-NEXT:             0x0000000000000058     40      9      1   0             0       0  is_stmt
-// CHECK-NEXT: 0x00000160: 05 DW_LNS_set_column (12)
-// CHECK-NEXT: 0x00000162: 4b address += 4,  line += 1,  op-index += 0
 // CHECK-NEXT:             0x000000000000005c     41     12      1   0             0       0  is_stmt
-// CHECK-NEXT: 0x00000163: bb address += 12,  line += 1,  op-index += 0
 // CHECK-NEXT:             0x0000000000000068     42     12      1   0             0       0  is_stmt
-// CHECK-NEXT: 0x00000164: 05 DW_LNS_set_column (9)
-// CHECK-NEXT: 0x00000166: 81 address += 8,  line += -1,  op-index += 0
 // CHECK-NEXT:             0x0000000000000070     41      9      1   0             0       0  is_stmt
-// CHECK-NEXT: 0x00000167: 05 DW_LNS_set_column (18)
-// CHECK-NEXT: 0x00000169: 4f address += 4,  line += 5,  op-index += 0
 // CHECK-NEXT:             0x0000000000000074     46     18      1   0             0       0  is_stmt
-// CHECK-NEXT: 0x0000016a: 05 DW_LNS_set_column (9)
-// CHECK-NEXT: 0x0000016c: ee address += 16,  line += -4,  op-index += 0
 // CHECK-NEXT:             0x0000000000000084     42      9      1   0             0       0  is_stmt
-// CHECK-NEXT: 0x0000016d: 05 DW_LNS_set_column (5)
-// CHECK-NEXT: 0x0000016f: 0b DW_LNS_set_epilogue_begin
-// CHECK-NEXT: 0x00000170: 4f address += 4,  line += 5,  op-index += 0
 // CHECK-NEXT:             0x0000000000000088     47      5      1   0             0       0  is_stmt epilogue_begin
-// CHECK-NEXT: 0x00000171: 02 DW_LNS_advance_pc (addr += 16, op-index += 0)
-// CHECK-NEXT: 0x00000173: 00 DW_LNE_end_sequence
 // CHECK-NEXT:             0x0000000000000098     47      5      1   0             0       0  is_stmt end_sequence
-// CHECK-NEXT: [[ERRLOG]]: 05 DW_LNS_set_column (85)
-// CHECK-NEXT: 0x00000178: 0a DW_LNS_set_prologue_end
-// CHECK-NEXT: 0x00000179: 00 DW_LNE_set_address (0x0000000000000098)
-// CHECK-NEXT: 0x00000184: 03 DW_LNS_advance_line (34)
-// CHECK-NEXT: 0x00000186: 01 DW_LNS_copy
 // CHECK-NEXT:             0x0000000000000098     34     85      1   0             0       0  is_stmt prologue_end
-// CHECK-NEXT: 0x00000187: 02 DW_LNS_advance_pc (addr += 4, op-index += 0)
-// CHECK-NEXT: 0x00000189: 00 DW_LNE_end_sequence
 // CHECK-NEXT:             0x000000000000009c     34     85      1   0             0       0  is_stmt end_sequence
-// CHECK-NEXT: [[ERRLEN]]: 05 DW_LNS_set_column (86)
-// CHECK-NEXT: 0x0000018e: 0a DW_LNS_set_prologue_end
-// CHECK-NEXT: 0x0000018f: 00 DW_LNE_set_address (0x000000000000009c)
-// CHECK-NEXT: 0x0000019a: 03 DW_LNS_advance_line (34)
-// CHECK-NEXT: 0x0000019c: 01 DW_LNS_copy
 // CHECK-NEXT:             0x000000000000009c     34     86      1   0             0       0  is_stmt prologue_end
-// CHECK-NEXT: 0x0000019d: 02 DW_LNS_advance_pc (addr += 4, op-index += 0)
-// CHECK-NEXT: 0x0000019f: 00 DW_LNE_end_sequence
-// CHECK-NEXT: 0x00000000000000a0     34     86      1   0             0       0  is_stmt end_sequence
 
 #--- stmt_seq_macho.cpp
 #define ATTRIB extern "C" __attribute__((noinline))

>From 616a04456ecaa983ad90a99f59cafae9a6d1c920 Mon Sep 17 00:00:00 2001
From: Peter Rong <PeterRong at meta.com>
Date: Fri, 12 Sep 2025 12:33:22 -0700
Subject: [PATCH 6/6] [DebugInfo] a test failing because clang++ doesn't exist

Signed-off-by: Peter Rong <PeterRong at meta.com>
---
 llvm/test/DebugInfo/ARM/stmt_seq_macho.test | 246 +++++++++++++++++++-
 1 file changed, 239 insertions(+), 7 deletions(-)

diff --git a/llvm/test/DebugInfo/ARM/stmt_seq_macho.test b/llvm/test/DebugInfo/ARM/stmt_seq_macho.test
index f0874bfc45ed2..8d2f2d7ea6189 100644
--- a/llvm/test/DebugInfo/ARM/stmt_seq_macho.test
+++ b/llvm/test/DebugInfo/ARM/stmt_seq_macho.test
@@ -1,11 +1,8 @@
 // RUN: split-file %s %t
 
-// RUN: clang++ --target=arm64-apple-macos11 \
-// RUN:   %t/stmt_seq_macho.cpp -o %t/stmt_seq_macho.o \
-// RUN:   -g -Oz -gdwarf-4 -c -mno-outline \
-// RUN:   -mllvm -emit-func-debug-line-table-offsets \
-// RUN:   -fdebug-compilation-dir=/private/tmp/stmt_seq \
-// RUN:   -fno-unwind-tables -fno-exceptions
+// RUN: llc -filetype=obj -mtriple=arm64-apple-macos11 \
+// RUN:   %t/stmt_seq_macho.ll -o %t/stmt_seq_macho.o \
+// RUN:   -emit-func-debug-line-table-offsets
 
 // RUN: llvm-dwarfdump -all %t/stmt_seq_macho.o | FileCheck %s
 
@@ -35,7 +32,7 @@
 // CHECK-NEXT:             0x0000000000000034     37      0      1   0             0       0  is_stmt
 // CHECK-NEXT:             0x0000000000000044     39     12      1   0             0       0  is_stmt prologue_end
 // CHECK-NEXT:             0x0000000000000050     40     12      1   0             0       0  is_stmt
-// CHECK-NEXT:             0x0000000000000058     40      9      1   0             0       0  is_stmt
+// CHECK-NEXT:             0x0000000000000058     40      9      1   0             0       0
 // CHECK-NEXT:             0x000000000000005c     41     12      1   0             0       0  is_stmt
 // CHECK-NEXT:             0x0000000000000068     42     12      1   0             0       0  is_stmt
 // CHECK-NEXT:             0x0000000000000070     41      9      1   0             0       0  is_stmt
@@ -47,6 +44,16 @@
 // CHECK-NEXT:             0x000000000000009c     34     85      1   0             0       0  is_stmt end_sequence
 // CHECK-NEXT:             0x000000000000009c     34     86      1   0             0       0  is_stmt prologue_end
 
+
+#--- gen
+clang++ --target=arm64-apple-macos11 \
+  stmt_seq_macho.cpp \
+  -o stmt_seq_macho.ll -S -emit-llvm \
+  -g -Oz -gdwarf-4 -mno-outline \
+  -mllvm -emit-func-debug-line-table-offsets \
+  -fdebug-compilation-dir=/private/tmp/stmt_seq \
+  -fno-unwind-tables -fno-exceptions
+
 #--- stmt_seq_macho.cpp
 #define ATTRIB extern "C" __attribute__((noinline))
 ATTRIB void function_empty_1() {}
@@ -96,3 +103,228 @@ int main() {
     length_error e("test");
     return sum;
 }
+
+#--- stmt_seq_macho.ll
+; ModuleID = 'stmt_seq_macho.cpp'
+source_filename = "stmt_seq_macho.cpp"
+target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-n32:64-S128-Fn32"
+target triple = "arm64-apple-macosx11.0.0"
+
+%struct.length_error = type { i8 }
+
+ at .str = private unnamed_addr constant [5 x i8] c"test\00", align 1, !dbg !0
+
+; Function Attrs: minsize mustprogress nofree noinline norecurse nosync nounwind optsize ssp willreturn memory(none)
+define void @function_empty_1() local_unnamed_addr #0 !dbg !16 {
+  ret void, !dbg !19
+}
+
+; Function Attrs: minsize mustprogress nofree noinline norecurse nosync nounwind optsize ssp willreturn memory(none)
+define void @function_empty_2() local_unnamed_addr #0 !dbg !20 {
+  ret void, !dbg !21
+}
+
+; Function Attrs: minsize mustprogress nofree noinline norecurse nosync nounwind optsize ssp willreturn memory(none)
+define void @function_empty_3() local_unnamed_addr #0 !dbg !22 {
+  ret void, !dbg !23
+}
+
+; Function Attrs: minsize mustprogress nofree noinline norecurse nosync nounwind optsize ssp willreturn memory(none)
+define range(i32 -2147483647, -2147483648) i32 @function1_copy1(i32 noundef %0) local_unnamed_addr #0 !dbg !24 {
+    #dbg_value(i32 %0, !29, !DIExpression(), !30)
+  %2 = add nsw i32 %0, 1, !dbg !31
+    #dbg_value(i32 %2, !29, !DIExpression(), !30)
+  ret i32 %2, !dbg !32
+}
+
+; Function Attrs: minsize mustprogress nofree noinline norecurse nosync nounwind optsize ssp willreturn memory(none)
+define range(i32 -2147483644, -2147483648) i32 @function3_copy1(i32 noundef %0) local_unnamed_addr #0 !dbg !33 {
+    #dbg_value(i32 %0, !35, !DIExpression(), !37)
+    #dbg_value(i32 %0, !36, !DIExpression(DW_OP_plus_uconst, 3, DW_OP_stack_value), !37)
+  %2 = add nsw i32 %0, 4, !dbg !38
+  ret i32 %2, !dbg !39
+}
+
+; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
+declare void @llvm.lifetime.start.p0(i64 immarg, ptr captures(none)) #1
+
+; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
+declare void @llvm.lifetime.end.p0(i64 immarg, ptr captures(none)) #1
+
+; Function Attrs: minsize mustprogress nofree noinline norecurse nosync nounwind optsize ssp willreturn memory(none)
+define range(i32 -2147483648, 2147483626) i32 @function2_copy1(i32 noundef %0) local_unnamed_addr #0 !dbg !40 {
+    #dbg_value(i32 %0, !42, !DIExpression(), !43)
+  %2 = add nsw i32 %0, -22, !dbg !44
+  ret i32 %2, !dbg !45
+}
+
+; Function Attrs: minsize mustprogress nofree noinline norecurse nosync nounwind optsize ssp willreturn memory(none)
+define range(i32 -2147483644, -2147483648) i32 @function3_copy2(i32 noundef %0) local_unnamed_addr #0 !dbg !46 {
+    #dbg_value(i32 %0, !48, !DIExpression(), !50)
+    #dbg_value(i32 %0, !49, !DIExpression(DW_OP_plus_uconst, 3, DW_OP_stack_value), !50)
+  %2 = add nsw i32 %0, 4, !dbg !51
+  ret i32 %2, !dbg !52
+}
+
+; Function Attrs: minsize mustprogress nofree noinline norecurse nosync nounwind optsize ssp willreturn memory(none)
+define range(i32 -2147483648, 2147483626) i32 @function2_copy2(i32 noundef %0) local_unnamed_addr #0 !dbg !53 {
+    #dbg_value(i32 %0, !55, !DIExpression(), !57)
+  %2 = add nsw i32 %0, -22, !dbg !58
+    #dbg_value(i32 %2, !56, !DIExpression(), !57)
+  ret i32 %2, !dbg !59
+}
+
+; Function Attrs: minsize mustprogress norecurse nounwind optsize ssp
+define noundef i32 @main() local_unnamed_addr #2 !dbg !60 {
+  %1 = alloca %struct.length_error, align 1
+    #dbg_value(i32 0, !64, !DIExpression(), !80)
+  %2 = tail call i32 @function2_copy2(i32 noundef 3) #4, !dbg !81
+    #dbg_value(i32 %2, !64, !DIExpression(), !80)
+  %3 = tail call i32 @function3_copy2(i32 noundef 41) #4, !dbg !82
+  %4 = add nsw i32 %3, %2, !dbg !83
+    #dbg_value(i32 %4, !64, !DIExpression(), !80)
+  %5 = tail call i32 @function2_copy1(i32 noundef 11) #4, !dbg !84
+  %6 = add nsw i32 %4, %5, !dbg !85
+    #dbg_value(i32 %6, !64, !DIExpression(), !80)
+  %7 = tail call i32 @function1_copy1(i32 noundef 42) #4, !dbg !86
+  %8 = add nsw i32 %6, %7, !dbg !87
+    #dbg_value(i32 %8, !64, !DIExpression(), !80)
+  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %1) #5, !dbg !88
+    #dbg_declare(ptr %1, !65, !DIExpression(), !89)
+  %9 = call noundef ptr @_ZN12length_errorC1EPKc(ptr noundef nonnull align 1 dereferenceable(1) %1, ptr noundef nonnull @.str) #4, !dbg !89
+  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %1) #5, !dbg !90
+  ret i32 %8, !dbg !91
+}
+
+; Function Attrs: minsize mustprogress noinline nounwind optsize ssp
+define linkonce_odr noundef ptr @_ZN12length_errorC1EPKc(ptr noundef nonnull returned align 1 dereferenceable(1) %0, ptr noundef %1) unnamed_addr #3 !dbg !92 {
+    #dbg_value(ptr %0, !94, !DIExpression(), !97)
+    #dbg_value(ptr %1, !96, !DIExpression(), !97)
+  %3 = tail call noundef ptr @_ZN12length_errorC2EPKc(ptr noundef nonnull align 1 dereferenceable(1) %0, ptr noundef %1) #4, !dbg !98
+  ret ptr %0, !dbg !99
+}
+
+; Function Attrs: minsize mustprogress noinline nounwind optsize ssp
+define linkonce_odr noundef ptr @_ZN12length_errorC2EPKc(ptr noundef nonnull returned align 1 dereferenceable(1) %0, ptr noundef %1) unnamed_addr #3 !dbg !100 {
+    #dbg_value(ptr %0, !102, !DIExpression(), !104)
+    #dbg_value(ptr %1, !103, !DIExpression(), !104)
+  ret ptr %0, !dbg !105
+}
+
+attributes #0 = { minsize mustprogress nofree noinline norecurse nosync nounwind optsize ssp willreturn memory(none) "frame-pointer"="non-leaf" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="apple-m1" "target-features"="+aes,+altnzcv,+ccdp,+ccidx,+ccpp,+complxnum,+crc,+dit,+dotprod,+flagm,+fp-armv8,+fp16fml,+fptoint,+fullfp16,+jsconv,+lse,+neon,+pauth,+perfmon,+predres,+ras,+rcpc,+rdm,+sb,+sha2,+sha3,+specrestrict,+ssbs,+v8.1a,+v8.2a,+v8.3a,+v8.4a,+v8a,+zcm-gpr64,+zcz" }
+attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
+attributes #2 = { minsize mustprogress norecurse nounwind optsize ssp "frame-pointer"="non-leaf" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="apple-m1" "target-features"="+aes,+altnzcv,+ccdp,+ccidx,+ccpp,+complxnum,+crc,+dit,+dotprod,+flagm,+fp-armv8,+fp16fml,+fptoint,+fullfp16,+jsconv,+lse,+neon,+pauth,+perfmon,+predres,+ras,+rcpc,+rdm,+sb,+sha2,+sha3,+specrestrict,+ssbs,+v8.1a,+v8.2a,+v8.3a,+v8.4a,+v8a,+zcm-gpr64,+zcz" }
+attributes #3 = { minsize mustprogress noinline nounwind optsize ssp "frame-pointer"="non-leaf" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="apple-m1" "target-features"="+aes,+altnzcv,+ccdp,+ccidx,+ccpp,+complxnum,+crc,+dit,+dotprod,+flagm,+fp-armv8,+fp16fml,+fptoint,+fullfp16,+jsconv,+lse,+neon,+pauth,+perfmon,+predres,+ras,+rcpc,+rdm,+sb,+sha2,+sha3,+specrestrict,+ssbs,+v8.1a,+v8.2a,+v8.3a,+v8.4a,+v8a,+zcm-gpr64,+zcz" }
+attributes #4 = { minsize optsize }
+attributes #5 = { nounwind }
+
+!llvm.dbg.cu = !{!8}
+!llvm.module.flags = !{!10, !11, !12, !13, !14}
+!llvm.ident = !{!15}
+
+!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
+!1 = distinct !DIGlobalVariable(scope: null, file: !2, line: 46, type: !3, isLocal: true, isDefinition: true)
+!2 = !DIFile(filename: "stmt_seq_macho.cpp", directory: "/private/tmp/stmt_seq")
+!3 = !DICompositeType(tag: DW_TAG_array_type, baseType: !4, size: 40, elements: !6)
+!4 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !5)
+!5 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)
+!6 = !{!7}
+!7 = !DISubrange(count: 5)
+!8 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !2, producer: "Facebook clang version 15.76.0 (https://git.internal.tfbnw.net/repos/git/ro/osmeta/external/llvm-project f40fa6dd3d840937180d389e8d6b902ac45f7134)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, globals: !9, splitDebugInlining: false, nameTableKind: Apple, sysroot: "/")
+!9 = !{!0}
+!10 = !{i32 7, !"Dwarf Version", i32 4}
+!11 = !{i32 2, !"Debug Info Version", i32 3}
+!12 = !{i32 1, !"wchar_size", i32 4}
+!13 = !{i32 8, !"PIC Level", i32 2}
+!14 = !{i32 7, !"frame-pointer", i32 1}
+!15 = !{!"Facebook clang version 15.76.0 (https://git.internal.tfbnw.net/repos/git/ro/osmeta/external/llvm-project f40fa6dd3d840937180d389e8d6b902ac45f7134)"}
+!16 = distinct !DISubprogram(name: "function_empty_1", scope: !2, file: !2, line: 2, type: !17, scopeLine: 2, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !8)
+!17 = !DISubroutineType(types: !18)
+!18 = !{null}
+!19 = !DILocation(line: 2, column: 33, scope: !16)
+!20 = distinct !DISubprogram(name: "function_empty_2", scope: !2, file: !2, line: 3, type: !17, scopeLine: 3, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !8)
+!21 = !DILocation(line: 3, column: 33, scope: !20)
+!22 = distinct !DISubprogram(name: "function_empty_3", scope: !2, file: !2, line: 4, type: !17, scopeLine: 4, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !8)
+!23 = !DILocation(line: 4, column: 33, scope: !22)
+!24 = distinct !DISubprogram(name: "function1_copy1", scope: !2, file: !2, line: 6, type: !25, scopeLine: 6, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !8, retainedNodes: !28)
+!25 = !DISubroutineType(types: !26)
+!26 = !{!27, !27}
+!27 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!28 = !{!29}
+!29 = !DILocalVariable(name: "a", arg: 1, scope: !24, file: !2, line: 6, type: !27)
+!30 = !DILocation(line: 0, scope: !24)
+!31 = !DILocation(line: 7, column: 10, scope: !24)
+!32 = !DILocation(line: 7, column: 3, scope: !24)
+!33 = distinct !DISubprogram(name: "function3_copy1", scope: !2, file: !2, line: 10, type: !25, scopeLine: 10, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !8, retainedNodes: !34)
+!34 = !{!35, !36}
+!35 = !DILocalVariable(name: "a", arg: 1, scope: !33, file: !2, line: 10, type: !27)
+!36 = !DILocalVariable(name: "b", scope: !33, file: !2, line: 11, type: !27)
+!37 = !DILocation(line: 0, scope: !33)
+!38 = !DILocation(line: 12, column: 14, scope: !33)
+!39 = !DILocation(line: 12, column: 5, scope: !33)
+!40 = distinct !DISubprogram(name: "function2_copy1", scope: !2, file: !2, line: 15, type: !25, scopeLine: 15, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !8, retainedNodes: !41)
+!41 = !{!42}
+!42 = !DILocalVariable(name: "a", arg: 1, scope: !40, file: !2, line: 15, type: !27)
+!43 = !DILocation(line: 0, scope: !40)
+!44 = !DILocation(line: 16, column: 14, scope: !40)
+!45 = !DILocation(line: 16, column: 5, scope: !40)
+!46 = distinct !DISubprogram(name: "function3_copy2", scope: !2, file: !2, line: 19, type: !25, scopeLine: 19, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !8, retainedNodes: !47)
+!47 = !{!48, !49}
+!48 = !DILocalVariable(name: "a", arg: 1, scope: !46, file: !2, line: 19, type: !27)
+!49 = !DILocalVariable(name: "b", scope: !46, file: !2, line: 20, type: !27)
+!50 = !DILocation(line: 0, scope: !46)
+!51 = !DILocation(line: 21, column: 14, scope: !46)
+!52 = !DILocation(line: 21, column: 5, scope: !46)
+!53 = distinct !DISubprogram(name: "function2_copy2", scope: !2, file: !2, line: 24, type: !25, scopeLine: 24, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !8, retainedNodes: !54)
+!54 = !{!55, !56}
+!55 = !DILocalVariable(name: "a", arg: 1, scope: !53, file: !2, line: 24, type: !27)
+!56 = !DILocalVariable(name: "result", scope: !53, file: !2, line: 25, type: !27)
+!57 = !DILocation(line: 0, scope: !53)
+!58 = !DILocation(line: 25, column: 20, scope: !53)
+!59 = !DILocation(line: 26, column: 5, scope: !53)
+!60 = distinct !DISubprogram(name: "main", scope: !2, file: !2, line: 37, type: !61, scopeLine: 37, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !8, retainedNodes: !63)
+!61 = !DISubroutineType(types: !62)
+!62 = !{!27}
+!63 = !{!64, !65}
+!64 = !DILocalVariable(name: "sum", scope: !60, file: !2, line: 38, type: !27)
+!65 = !DILocalVariable(name: "e", scope: !60, file: !2, line: 46, type: !66)
+!66 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "length_error", file: !2, line: 33, size: 8, flags: DIFlagTypePassByValue | DIFlagNonTrivial, elements: !67, identifier: "_ZTS12length_error")
+!67 = !{!68, !76}
+!68 = !DIDerivedType(tag: DW_TAG_inheritance, scope: !66, baseType: !69, extraData: i32 0)
+!69 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "logic_error", file: !2, line: 29, size: 8, flags: DIFlagTypePassByValue | DIFlagNonTrivial, elements: !70, identifier: "_ZTS11logic_error")
+!70 = !{!71}
+!71 = !DISubprogram(name: "logic_error", scope: !69, file: !2, line: 30, type: !72, scopeLine: 30, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized)
+!72 = !DISubroutineType(types: !73)
+!73 = !{null, !74, !75}
+!74 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !69, size: 64, flags: DIFlagArtificial | DIFlagObjectPointer)
+!75 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !4, size: 64)
+!76 = !DISubprogram(name: "length_error", scope: !66, file: !2, line: 34, type: !77, scopeLine: 34, flags: DIFlagExplicit | DIFlagPrototyped, spFlags: DISPFlagOptimized)
+!77 = !DISubroutineType(types: !78)
+!78 = !{null, !79, !75}
+!79 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !66, size: 64, flags: DIFlagArtificial | DIFlagObjectPointer)
+!80 = !DILocation(line: 0, scope: !60)
+!81 = !DILocation(line: 39, column: 12, scope: !60)
+!82 = !DILocation(line: 40, column: 12, scope: !60)
+!83 = !DILocation(line: 40, column: 9, scope: !60)
+!84 = !DILocation(line: 41, column: 12, scope: !60)
+!85 = !DILocation(line: 41, column: 9, scope: !60)
+!86 = !DILocation(line: 42, column: 12, scope: !60)
+!87 = !DILocation(line: 42, column: 9, scope: !60)
+!88 = !DILocation(line: 46, column: 5, scope: !60)
+!89 = !DILocation(line: 46, column: 18, scope: !60)
+!90 = !DILocation(line: 48, column: 1, scope: !60)
+!91 = !DILocation(line: 47, column: 5, scope: !60)
+!92 = distinct !DISubprogram(name: "length_error", linkageName: "_ZN12length_errorC1EPKc", scope: !66, file: !2, line: 34, type: !77, scopeLine: 34, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !8, declaration: !76, retainedNodes: !93)
+!93 = !{!94, !96}
+!94 = !DILocalVariable(name: "this", arg: 1, scope: !92, type: !95, flags: DIFlagArtificial | DIFlagObjectPointer)
+!95 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !66, size: 64)
+!96 = !DILocalVariable(name: "s", arg: 2, scope: !92, file: !2, line: 34, type: !75)
+!97 = !DILocation(line: 0, scope: !92)
+!98 = !DILocation(line: 34, column: 85, scope: !92)
+!99 = !DILocation(line: 34, column: 86, scope: !92)
+!100 = distinct !DISubprogram(name: "length_error", linkageName: "_ZN12length_errorC2EPKc", scope: !66, file: !2, line: 34, type: !77, scopeLine: 34, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !8, declaration: !76, retainedNodes: !101)
+!101 = !{!102, !103}
+!102 = !DILocalVariable(name: "this", arg: 1, scope: !100, type: !95, flags: DIFlagArtificial | DIFlagObjectPointer)
+!103 = !DILocalVariable(name: "s", arg: 2, scope: !100, file: !2, line: 34, type: !75)
+!104 = !DILocation(line: 0, scope: !100)
+!105 = !DILocation(line: 34, column: 86, scope: !100)



More information about the llvm-commits mailing list