mxms0 wrote:

Sorry for the delay. For this sample program:

```c
void use(void *);

void test_memset(void) {
  char array[24] = { 0 };
  use(array);
}

void test_memcpy(void) {
  char array[24] = { 1, 2, 3 };
  use(array);
}
```

`clang -O2 -g -c sample.c -o sample.o` then `llvm-dwarfdump --debug-info 
--debug-line`

Here's the diff in the dwarf:

```diff
--- before.dwarfdump
+++ after.dwarfdump
@@ -1,7 +1,7 @@
 sample.o:    file format Mach-O arm64

 .debug_info contents:
-0x00000000: Compile Unit: length = 0x00000088, format = DWARF32, version = 
0x0005, unit_type = DW_UT_compile, abbr_offset = 0x0000, addr_size = 0x08 (next 
unit at 0x0000008c)
+0x00000000: Compile Unit: length = 0x000000a6, format = DWARF32, version = 
0x0005, unit_type = DW_UT_compile, abbr_offset = 0x0000, addr_size = 0x08 (next 
unit at 0x000000aa)

 0x0000000c: DW_TAG_compile_unit
               DW_AT_producer    ("clang version 24.0.0git")
@@ -17,6 +17,12 @@
               DW_AT_addr_base    (0x00000008)

 0x00000024:   DW_TAG_subprogram
+                DW_AT_name    ("memset")
+                DW_AT_artificial    (true)
+                DW_AT_external    (true)
+                DW_AT_inline    (DW_INL_inlined)
+
+0x00000026:   DW_TAG_subprogram
                 DW_AT_low_pc    (0x0000000000000000)
                 DW_AT_high_pc    (0x0000000000000054)
                 DW_AT_frame_base    (DW_OP_reg29 W29)
@@ -28,26 +34,34 @@
                 DW_AT_external    (true)
                 DW_AT_APPLE_optimized    (true)

-0x0000002f:     DW_TAG_variable
+0x00000031:     DW_TAG_variable
                   DW_AT_location    (DW_OP_breg31 WSP+0)
                   DW_AT_name    ("array")
                   DW_AT_decl_file    ("./sample.c")
                   DW_AT_decl_line    (4)
-                  DW_AT_type    (0x00000077 "char[24]")
+                  DW_AT_type    (0x00000095 "char[24]")

-0x0000003a:     DW_TAG_call_site
-                  DW_AT_call_origin    (0x00000048 "use")
+0x0000003c:     DW_TAG_inlined_subroutine
+                  DW_AT_abstract_origin    (0x00000024 "memset")
+                  DW_AT_low_pc    (0x000000000000001c)
+                  DW_AT_high_pc    (0x0000000000000024)
+                  DW_AT_call_file    ("./sample.c")
+                  DW_AT_call_line    (4)
+                  DW_AT_call_column    (8)
+
+0x00000049:     DW_TAG_call_site
+                  DW_AT_call_origin    (0x00000057 "use")
                   DW_AT_call_return_pc    (0x000000000000002c)

-0x00000040:       DW_TAG_call_site_parameter
+0x0000004f:       DW_TAG_call_site_parameter
                     DW_AT_location    (DW_OP_reg0 W0)
                     DW_AT_call_value    (DW_OP_breg31 WSP+0)

-0x00000046:       NULL
+0x00000055:       NULL

-0x00000047:     NULL
+0x00000056:     NULL

-0x00000048:   DW_TAG_subprogram
+0x00000057:   DW_TAG_subprogram
                 DW_AT_name    ("use")
                 DW_AT_decl_file    ("./sample.c")
                 DW_AT_decl_line    (1)
@@ -56,14 +70,20 @@
                 DW_AT_external    (true)
                 DW_AT_APPLE_optimized    (true)

-0x0000004c:     DW_TAG_formal_parameter
-                  DW_AT_type    (0x00000052 "void *")
+0x0000005b:     DW_TAG_formal_parameter
+                  DW_AT_type    (0x00000061 "void *")

-0x00000051:     NULL
+0x00000060:     NULL

-0x00000052:   DW_TAG_pointer_type
+0x00000061:   DW_TAG_pointer_type

-0x00000053:   DW_TAG_subprogram
+0x00000062:   DW_TAG_subprogram
+                DW_AT_name    ("memcpy")
+                DW_AT_artificial    (true)
+                DW_AT_external    (true)
+                DW_AT_inline    (DW_INL_inlined)
+
+0x00000064:   DW_TAG_subprogram
                 DW_AT_low_pc    (0x0000000000000054)
                 DW_AT_high_pc    (0x00000000000000b4)
                 DW_AT_frame_base    (DW_OP_reg29 W29)
@@ -75,50 +95,58 @@
                 DW_AT_external    (true)
                 DW_AT_APPLE_optimized    (true)

-0x0000005e:     DW_TAG_variable
+0x0000006f:     DW_TAG_variable
                   DW_AT_location    (DW_OP_breg31 WSP+0)
                   DW_AT_name    ("array")
                   DW_AT_decl_file    ("./sample.c")
                   DW_AT_decl_line    (9)
-                  DW_AT_type    (0x00000077 "char[24]")
+                  DW_AT_type    (0x00000095 "char[24]")

-0x00000069:     DW_TAG_call_site
-                  DW_AT_call_origin    (0x00000048 "use")
+0x0000007a:     DW_TAG_inlined_subroutine
+                  DW_AT_abstract_origin    (0x00000062 "memcpy")
+                  DW_AT_low_pc    (0x0000000000000070)
+                  DW_AT_high_pc    (0x0000000000000084)
+                  DW_AT_call_file    ("./sample.c")
+                  DW_AT_call_line    (9)
+                  DW_AT_call_column    (8)
+
+0x00000087:     DW_TAG_call_site
+                  DW_AT_call_origin    (0x00000057 "use")
                   DW_AT_call_return_pc    (0x000000000000008c)

-0x0000006f:       DW_TAG_call_site_parameter
+0x0000008d:       DW_TAG_call_site_parameter
                     DW_AT_location    (DW_OP_reg0 W0)
                     DW_AT_call_value    (DW_OP_breg31 WSP+0)

-0x00000075:       NULL
+0x00000093:       NULL

-0x00000076:     NULL
+0x00000094:     NULL

-0x00000077:   DW_TAG_array_type
-                DW_AT_type    (0x00000083 "char")
+0x00000095:   DW_TAG_array_type
+                DW_AT_type    (0x000000a1 "char")

-0x0000007c:     DW_TAG_subrange_type
-                  DW_AT_type    (0x00000087 "__ARRAY_SIZE_TYPE__")
+0x0000009a:     DW_TAG_subrange_type
+                  DW_AT_type    (0x000000a5 "__ARRAY_SIZE_TYPE__")
                   DW_AT_count    (0x18)

-0x00000082:     NULL
+0x000000a0:     NULL

-0x00000083:   DW_TAG_base_type
+0x000000a1:   DW_TAG_base_type
                 DW_AT_name    ("char")
                 DW_AT_encoding    (DW_ATE_signed_char)
                 DW_AT_byte_size    (0x01)

-0x00000087:   DW_TAG_base_type
+0x000000a5:   DW_TAG_base_type
                 DW_AT_name    ("__ARRAY_SIZE_TYPE__")
                 DW_AT_byte_size    (0x08)
                 DW_AT_encoding    (DW_ATE_unsigned)

-0x0000008b:   NULL
+0x000000a9:   NULL

 .debug_line contents:
 debug_line[0x00000000]
 Line table prologue:
-    total_length: 0x00000083
+    total_length: 0x00000087
           format: DWARF32
          version: 5
     address_size: 8
```

https://github.com/llvm/llvm-project/pull/229218
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to