|
| 1 | +// RUN: split-file %s %t |
| 2 | + |
| 3 | +// RUN: clang++ --target=arm64-apple-macos11 \ |
| 4 | +// RUN: -x c++ %t/stmt_seq_macho.cpp \ |
| 5 | +// RUN: -o %t/stmt_seq_macho.o \ |
| 6 | +// RUN: -g -Oz -gdwarf-4 -c \ |
| 7 | +// RUN: -mllvm -emit-func-debug-line-table-offsets \ |
| 8 | +// RUN: -fdebug-compilation-dir=/private/tmp/stmt_seq \ |
| 9 | +// RUN: -fno-unwind-tables -fno-exceptions \ |
| 10 | +// RUN: -mno-outline |
| 11 | + |
| 12 | +// RUN: llvm-dwarfdump -all -v %t/stmt_seq_macho.o | FileCheck %s |
| 13 | + |
| 14 | +// CHECK: .debug_info |
| 15 | +// CHECK: DW_AT_LLVM_stmt_sequence [DW_FORM_sec_offset] ([[EMPTY1:0x[0-9a-fA-F]{8}]]) |
| 16 | +// CHECK: DW_AT_name [DW_FORM_strp] ({{.*}} = "function_empty_1") |
| 17 | + |
| 18 | +// CHECK: DW_AT_LLVM_stmt_sequence [DW_FORM_sec_offset] ([[EMPTY2:0x[0-9a-fA-F]{8}]]) |
| 19 | +// CHECK: DW_AT_name [DW_FORM_strp] ({{.*}} = "function_empty_2") |
| 20 | + |
| 21 | +// CHECK: DW_AT_LLVM_stmt_sequence [DW_FORM_sec_offset] ([[EMPTY3:0x[0-9a-fA-F]{8}]]) |
| 22 | +// CHECK: DW_AT_name [DW_FORM_strp] ({{.*}} = "function_empty_3") |
| 23 | + |
| 24 | +// CHECK: DW_AT_LLVM_stmt_sequence [DW_FORM_sec_offset] ([[F1CPY1:0x[0-9a-fA-F]{8}]]) |
| 25 | +// CHECK: DW_AT_name [DW_FORM_strp] ({{.*}} = "function1_copy1") |
| 26 | + |
| 27 | +// CHECK: DW_AT_LLVM_stmt_sequence [DW_FORM_sec_offset] ([[F3CPY1:0x[0-9a-fA-F]{8}]]) |
| 28 | +// CHECK: DW_AT_name [DW_FORM_strp] ({{.*}} = "function3_copy1") |
| 29 | + |
| 30 | +// CHECK: DW_AT_LLVM_stmt_sequence [DW_FORM_sec_offset] ([[F2CPY1:0x[0-9a-fA-F]{8}]]) |
| 31 | +// CHECK: DW_AT_name [DW_FORM_strp] ({{.*}} = "function2_copy1") |
| 32 | + |
| 33 | +// CHECK: DW_AT_LLVM_stmt_sequence [DW_FORM_sec_offset] ([[F3CPY2:0x[0-9a-fA-F]{8}]]) |
| 34 | +// CHECK: DW_AT_name [DW_FORM_strp] ({{.*}} = "function3_copy2") |
| 35 | + |
| 36 | +// CHECK: DW_AT_LLVM_stmt_sequence [DW_FORM_sec_offset] ([[F2CPY2:0x[0-9a-fA-F]{8}]]) |
| 37 | +// CHECK: DW_AT_name [DW_FORM_strp] ({{.*}} = "function2_copy2") |
| 38 | + |
| 39 | +// CHECK: DW_AT_LLVM_stmt_sequence [DW_FORM_sec_offset] ([[FNMAIN:0x[0-9a-fA-F]{8}]]) |
| 40 | +// CHECK: DW_AT_name [DW_FORM_strp] ({{.*}} = "main") |
| 41 | + |
| 42 | +// CHECK: DW_AT_LLVM_stmt_sequence [DW_FORM_sec_offset] ([[ERRLOG:0x[0-9a-fA-F]{8}]]) |
| 43 | +// CHECK: DW_AT_linkage_name [DW_FORM_strp] ({{.*}} = "_ZN12length_errorC1EPKc") |
| 44 | + |
| 45 | +// CHECK: DW_AT_LLVM_stmt_sequence [DW_FORM_sec_offset] ([[ERRLEN:0x[0-9a-fA-F]{8}]]) |
| 46 | +// CHECK: DW_AT_linkage_name [DW_FORM_strp] ({{.*}} = "_ZN12length_errorC2EPKc") |
| 47 | + |
| 48 | +// CHECK: Address Line Column File ISA Discriminator OpIndex Flags |
| 49 | +// CHECK-NEXT: ------------------ ------ ------ ------ --- ------------- ------- ------------- |
| 50 | +// CHECK-NEXT: [[EMPTY1]]: 05 DW_LNS_set_column (33) |
| 51 | +// CHECK-NEXT: 0x00000091: 0a DW_LNS_set_prologue_end |
| 52 | +// CHECK-NEXT: 0x00000092: 00 DW_LNE_set_address (0x0000000000000000) |
| 53 | +// CHECK-NEXT: 0x0000009d: 13 address += 0, line += 1, op-index += 0 |
| 54 | +// CHECK-NEXT: 0x0000000000000000 2 33 1 0 0 0 is_stmt prologue_end |
| 55 | +// CHECK-NEXT: 0x0000009e: 02 DW_LNS_advance_pc (addr += 4, op-index += 0) |
| 56 | +// CHECK-NEXT: 0x000000a0: 00 DW_LNE_end_sequence |
| 57 | +// CHECK-NEXT: 0x0000000000000004 2 33 1 0 0 0 is_stmt end_sequence |
| 58 | +// CHECK-NEXT: [[EMPTY2]]: 05 DW_LNS_set_column (33) |
| 59 | +// CHECK-NEXT: 0x000000a5: 0a DW_LNS_set_prologue_end |
| 60 | +// CHECK-NEXT: 0x000000a6: 00 DW_LNE_set_address (0x0000000000000004) |
| 61 | +// CHECK-NEXT: 0x000000b1: 14 address += 0, line += 2, op-index += 0 |
| 62 | +// CHECK-NEXT: 0x0000000000000004 3 33 1 0 0 0 is_stmt prologue_end |
| 63 | +// CHECK-NEXT: 0x000000b2: 02 DW_LNS_advance_pc (addr += 4, op-index += 0) |
| 64 | +// CHECK-NEXT: 0x000000b4: 00 DW_LNE_end_sequence |
| 65 | +// CHECK-NEXT: 0x0000000000000008 3 33 1 0 0 0 is_stmt end_sequence |
| 66 | +// CHECK-NEXT: [[EMPTY3]]: 05 DW_LNS_set_column (33) |
| 67 | +// CHECK-NEXT: 0x000000b9: 0a DW_LNS_set_prologue_end |
| 68 | +// CHECK-NEXT: 0x000000ba: 00 DW_LNE_set_address (0x0000000000000008) |
| 69 | +// CHECK-NEXT: 0x000000c5: 15 address += 0, line += 3, op-index += 0 |
| 70 | +// CHECK-NEXT: 0x0000000000000008 4 33 1 0 0 0 is_stmt prologue_end |
| 71 | +// CHECK-NEXT: 0x000000c6: 02 DW_LNS_advance_pc (addr += 4, op-index += 0) |
| 72 | +// CHECK-NEXT: 0x000000c8: 00 DW_LNE_end_sequence |
| 73 | +// CHECK-NEXT: 0x000000000000000c 4 33 1 0 0 0 is_stmt end_sequence |
| 74 | +// CHECK-NEXT: [[F1CPY1]]: 05 DW_LNS_set_column (10) |
| 75 | +// CHECK-NEXT: 0x000000cd: 0a DW_LNS_set_prologue_end |
| 76 | +// CHECK-NEXT: 0x000000ce: 00 DW_LNE_set_address (0x000000000000000c) |
| 77 | +// CHECK-NEXT: 0x000000d9: 18 address += 0, line += 6, op-index += 0 |
| 78 | +// CHECK-NEXT: 0x000000000000000c 7 10 1 0 0 0 is_stmt prologue_end |
| 79 | +// CHECK-NEXT: 0x000000da: 05 DW_LNS_set_column (3) |
| 80 | +// CHECK-NEXT: 0x000000dc: 06 DW_LNS_negate_stmt |
| 81 | +// CHECK-NEXT: 0x000000dd: 4a address += 4, line += 0, op-index += 0 |
| 82 | +// CHECK-NEXT: 0x0000000000000010 7 3 1 0 0 0 |
| 83 | +// CHECK-NEXT: 0x000000de: 02 DW_LNS_advance_pc (addr += 4, op-index += 0) |
| 84 | +// CHECK-NEXT: 0x000000e0: 00 DW_LNE_end_sequence |
| 85 | +// CHECK-NEXT: 0x0000000000000014 7 3 1 0 0 0 end_sequence |
| 86 | +// CHECK-NEXT: [[F3CPY1]]: 05 DW_LNS_set_column (14) |
| 87 | +// CHECK-NEXT: 0x000000e5: 0a DW_LNS_set_prologue_end |
| 88 | +// CHECK-NEXT: 0x000000e6: 00 DW_LNE_set_address (0x0000000000000014) |
| 89 | +// CHECK-NEXT: 0x000000f1: 03 DW_LNS_advance_line (12) |
| 90 | +// CHECK-NEXT: 0x000000f3: 01 DW_LNS_copy |
| 91 | +// CHECK-NEXT: 0x0000000000000014 12 14 1 0 0 0 is_stmt prologue_end |
| 92 | +// CHECK-NEXT: 0x000000f4: 05 DW_LNS_set_column (5) |
| 93 | +// CHECK-NEXT: 0x000000f6: 06 DW_LNS_negate_stmt |
| 94 | +// CHECK-NEXT: 0x000000f7: 4a address += 4, line += 0, op-index += 0 |
| 95 | +// CHECK-NEXT: 0x0000000000000018 12 5 1 0 0 0 |
| 96 | +// CHECK-NEXT: 0x000000f8: 02 DW_LNS_advance_pc (addr += 4, op-index += 0) |
| 97 | +// CHECK-NEXT: 0x000000fa: 00 DW_LNE_end_sequence |
| 98 | +// CHECK-NEXT: 0x000000000000001c 12 5 1 0 0 0 end_sequence |
| 99 | +// CHECK-NEXT: [[F2CPY1]]: 05 DW_LNS_set_column (14) |
| 100 | +// CHECK-NEXT: 0x000000ff: 0a DW_LNS_set_prologue_end |
| 101 | +// CHECK-NEXT: 0x00000100: 00 DW_LNE_set_address (0x000000000000001c) |
| 102 | +// CHECK-NEXT: 0x0000010b: 03 DW_LNS_advance_line (16) |
| 103 | +// CHECK-NEXT: 0x0000010d: 01 DW_LNS_copy |
| 104 | +// CHECK-NEXT: 0x000000000000001c 16 14 1 0 0 0 is_stmt prologue_end |
| 105 | +// CHECK-NEXT: 0x0000010e: 05 DW_LNS_set_column (5) |
| 106 | +// CHECK-NEXT: 0x00000110: 06 DW_LNS_negate_stmt |
| 107 | +// CHECK-NEXT: 0x00000111: 4a address += 4, line += 0, op-index += 0 |
| 108 | +// CHECK-NEXT: 0x0000000000000020 16 5 1 0 0 0 |
| 109 | +// CHECK-NEXT: 0x00000112: 02 DW_LNS_advance_pc (addr += 4, op-index += 0) |
| 110 | +// CHECK-NEXT: 0x00000114: 00 DW_LNE_end_sequence |
| 111 | +// CHECK-NEXT: 0x0000000000000024 16 5 1 0 0 0 end_sequence |
| 112 | +// CHECK-NEXT: [[F3CPY2]]: 05 DW_LNS_set_column (14) |
| 113 | +// CHECK-NEXT: 0x00000119: 0a DW_LNS_set_prologue_end |
| 114 | +// CHECK-NEXT: 0x0000011a: 00 DW_LNE_set_address (0x0000000000000024) |
| 115 | +// CHECK-NEXT: 0x00000125: 03 DW_LNS_advance_line (21) |
| 116 | +// CHECK-NEXT: 0x00000127: 01 DW_LNS_copy |
| 117 | +// CHECK-NEXT: 0x0000000000000024 21 14 1 0 0 0 is_stmt prologue_end |
| 118 | +// CHECK-NEXT: 0x00000128: 05 DW_LNS_set_column (5) |
| 119 | +// CHECK-NEXT: 0x0000012a: 06 DW_LNS_negate_stmt |
| 120 | +// CHECK-NEXT: 0x0000012b: 4a address += 4, line += 0, op-index += 0 |
| 121 | +// CHECK-NEXT: 0x0000000000000028 21 5 1 0 0 0 |
| 122 | +// CHECK-NEXT: 0x0000012c: 02 DW_LNS_advance_pc (addr += 4, op-index += 0) |
| 123 | +// CHECK-NEXT: 0x0000012e: 00 DW_LNE_end_sequence |
| 124 | +// CHECK-NEXT: 0x000000000000002c 21 5 1 0 0 0 end_sequence |
| 125 | +// CHECK-NEXT: [[F2CPY2]]: 05 DW_LNS_set_column (20) |
| 126 | +// CHECK-NEXT: 0x00000133: 0a DW_LNS_set_prologue_end |
| 127 | +// CHECK-NEXT: 0x00000134: 00 DW_LNE_set_address (0x000000000000002c) |
| 128 | +// CHECK-NEXT: 0x0000013f: 03 DW_LNS_advance_line (25) |
| 129 | +// CHECK-NEXT: 0x00000141: 01 DW_LNS_copy |
| 130 | +// CHECK-NEXT: 0x000000000000002c 25 20 1 0 0 0 is_stmt prologue_end |
| 131 | +// CHECK-NEXT: 0x00000142: 05 DW_LNS_set_column (5) |
| 132 | +// CHECK-NEXT: 0x00000144: 4b address += 4, line += 1, op-index += 0 |
| 133 | +// CHECK-NEXT: 0x0000000000000030 26 5 1 0 0 0 is_stmt |
| 134 | +// CHECK-NEXT: 0x00000145: 02 DW_LNS_advance_pc (addr += 4, op-index += 0) |
| 135 | +// CHECK-NEXT: 0x00000147: 00 DW_LNE_end_sequence |
| 136 | +// CHECK-NEXT: 0x0000000000000034 26 5 1 0 0 0 is_stmt end_sequence |
| 137 | +// CHECK-NEXT: [[FNMAIN]]: 00 DW_LNE_set_address (0x0000000000000034) |
| 138 | +// CHECK-NEXT: 0x00000155: 03 DW_LNS_advance_line (37) |
| 139 | +// CHECK-NEXT: 0x00000157: 01 DW_LNS_copy |
| 140 | +// CHECK-NEXT: 0x0000000000000034 37 0 1 0 0 0 is_stmt |
| 141 | +// CHECK-NEXT: 0x00000158: 05 DW_LNS_set_column (12) |
| 142 | +// CHECK-NEXT: 0x0000015a: 0a DW_LNS_set_prologue_end |
| 143 | +// CHECK-NEXT: 0x0000015b: f4 address += 16, line += 2, op-index += 0 |
| 144 | +// CHECK-NEXT: 0x0000000000000044 39 12 1 0 0 0 is_stmt prologue_end |
| 145 | +// CHECK-NEXT: 0x0000015c: bb address += 12, line += 1, op-index += 0 |
| 146 | +// CHECK-NEXT: 0x0000000000000050 40 12 1 0 0 0 is_stmt |
| 147 | +// CHECK-NEXT: 0x0000015d: 05 DW_LNS_set_column (9) |
| 148 | +// CHECK-NEXT: 0x0000015f: 82 address += 8, line += 0, op-index += 0 |
| 149 | +// CHECK-NEXT: 0x0000000000000058 40 9 1 0 0 0 is_stmt |
| 150 | +// CHECK-NEXT: 0x00000160: 05 DW_LNS_set_column (12) |
| 151 | +// CHECK-NEXT: 0x00000162: 4b address += 4, line += 1, op-index += 0 |
| 152 | +// CHECK-NEXT: 0x000000000000005c 41 12 1 0 0 0 is_stmt |
| 153 | +// CHECK-NEXT: 0x00000163: bb address += 12, line += 1, op-index += 0 |
| 154 | +// CHECK-NEXT: 0x0000000000000068 42 12 1 0 0 0 is_stmt |
| 155 | +// CHECK-NEXT: 0x00000164: 05 DW_LNS_set_column (9) |
| 156 | +// CHECK-NEXT: 0x00000166: 81 address += 8, line += -1, op-index += 0 |
| 157 | +// CHECK-NEXT: 0x0000000000000070 41 9 1 0 0 0 is_stmt |
| 158 | +// CHECK-NEXT: 0x00000167: 05 DW_LNS_set_column (18) |
| 159 | +// CHECK-NEXT: 0x00000169: 4f address += 4, line += 5, op-index += 0 |
| 160 | +// CHECK-NEXT: 0x0000000000000074 46 18 1 0 0 0 is_stmt |
| 161 | +// CHECK-NEXT: 0x0000016a: 05 DW_LNS_set_column (9) |
| 162 | +// CHECK-NEXT: 0x0000016c: ee address += 16, line += -4, op-index += 0 |
| 163 | +// CHECK-NEXT: 0x0000000000000084 42 9 1 0 0 0 is_stmt |
| 164 | +// CHECK-NEXT: 0x0000016d: 05 DW_LNS_set_column (5) |
| 165 | +// CHECK-NEXT: 0x0000016f: 0b DW_LNS_set_epilogue_begin |
| 166 | +// CHECK-NEXT: 0x00000170: 4f address += 4, line += 5, op-index += 0 |
| 167 | +// CHECK-NEXT: 0x0000000000000088 47 5 1 0 0 0 is_stmt epilogue_begin |
| 168 | +// CHECK-NEXT: 0x00000171: 02 DW_LNS_advance_pc (addr += 16, op-index += 0) |
| 169 | +// CHECK-NEXT: 0x00000173: 00 DW_LNE_end_sequence |
| 170 | +// CHECK-NEXT: 0x0000000000000098 47 5 1 0 0 0 is_stmt end_sequence |
| 171 | +// CHECK-NEXT: [[ERRLOG]]: 05 DW_LNS_set_column (85) |
| 172 | +// CHECK-NEXT: 0x00000178: 0a DW_LNS_set_prologue_end |
| 173 | +// CHECK-NEXT: 0x00000179: 00 DW_LNE_set_address (0x0000000000000098) |
| 174 | +// CHECK-NEXT: 0x00000184: 03 DW_LNS_advance_line (34) |
| 175 | +// CHECK-NEXT: 0x00000186: 01 DW_LNS_copy |
| 176 | +// CHECK-NEXT: 0x0000000000000098 34 85 1 0 0 0 is_stmt prologue_end |
| 177 | +// CHECK-NEXT: 0x00000187: 02 DW_LNS_advance_pc (addr += 4, op-index += 0) |
| 178 | +// CHECK-NEXT: 0x00000189: 00 DW_LNE_end_sequence |
| 179 | +// CHECK-NEXT: 0x000000000000009c 34 85 1 0 0 0 is_stmt end_sequence |
| 180 | +// CHECK-NEXT: [[ERRLEN]]: 05 DW_LNS_set_column (86) |
| 181 | +// CHECK-NEXT: 0x0000018e: 0a DW_LNS_set_prologue_end |
| 182 | +// CHECK-NEXT: 0x0000018f: 00 DW_LNE_set_address (0x000000000000009c) |
| 183 | +// CHECK-NEXT: 0x0000019a: 03 DW_LNS_advance_line (34) |
| 184 | +// CHECK-NEXT: 0x0000019c: 01 DW_LNS_copy |
| 185 | +// CHECK-NEXT: 0x000000000000009c 34 86 1 0 0 0 is_stmt prologue_end |
| 186 | +// CHECK-NEXT: 0x0000019d: 02 DW_LNS_advance_pc (addr += 4, op-index += 0) |
| 187 | +// CHECK-NEXT: 0x0000019f: 00 DW_LNE_end_sequence |
| 188 | +// CHECK-NEXT: 0x00000000000000a0 34 86 1 0 0 0 is_stmt end_sequence |
| 189 | + |
| 190 | +#--- stmt_seq_macho.cpp |
| 191 | +#define ATTRIB extern "C" __attribute__((noinline)) |
| 192 | +ATTRIB void function_empty_1() {} |
| 193 | +ATTRIB void function_empty_2() {} |
| 194 | +ATTRIB void function_empty_3() {} |
| 195 | + |
| 196 | +ATTRIB int function1_copy1(int a) { |
| 197 | + return ++a; |
| 198 | +} |
| 199 | + |
| 200 | +ATTRIB int function3_copy1(int a) { |
| 201 | + int b = a + 3; |
| 202 | + return b + 1; |
| 203 | +} |
| 204 | + |
| 205 | +ATTRIB int function2_copy1(int a) { |
| 206 | + return a - 22; |
| 207 | +} |
| 208 | + |
| 209 | +ATTRIB int function3_copy2(int a) { |
| 210 | + int b = a + 3; |
| 211 | + return b + 1; |
| 212 | +} |
| 213 | + |
| 214 | +ATTRIB int function2_copy2(int a) { |
| 215 | + int result = a - 22; |
| 216 | + return result; |
| 217 | +} |
| 218 | + |
| 219 | +struct logic_error { |
| 220 | + logic_error(const char* s) {} |
| 221 | +}; |
| 222 | + |
| 223 | +struct length_error : public logic_error { |
| 224 | + __attribute__((noinline)) explicit length_error(const char* s) : logic_error(s) {} |
| 225 | +}; |
| 226 | + |
| 227 | +int main() { |
| 228 | + int sum = 0; |
| 229 | + sum += function2_copy2(3); |
| 230 | + sum += function3_copy2(41); |
| 231 | + sum += function2_copy1(11); |
| 232 | + sum += function1_copy1(42); |
| 233 | + function_empty_1(); |
| 234 | + function_empty_2(); |
| 235 | + function_empty_3(); |
| 236 | + length_error e("test"); |
| 237 | + return sum; |
| 238 | +} |
0 commit comments