File: verify_no_overlap_error_icf.yaml

package info (click to toggle)
llvm-toolchain-20 1%3A20.1.8-1~exp1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 2,111,388 kB
  • sloc: cpp: 7,438,767; ansic: 1,393,871; asm: 1,012,926; python: 241,728; f90: 86,635; objc: 75,411; lisp: 42,144; pascal: 17,286; sh: 10,027; ml: 5,082; perl: 4,730; awk: 3,523; makefile: 3,349; javascript: 2,251; xml: 892; fortran: 672
file content (153 lines) | stat: -rw-r--r-- 5,664 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#--- comments.txt

# This test verifies several scenarios with DW_TAG_subprogram address ranges:
# 1. Two subprograms can have identical ranges (shown with foo2 and foo3 having same low_pc/high_pc)
#    This is valid and can happen when ICF (Identical Code Folding) merges functions.
# 2. Two subprograms can have overlapping ranges when using DW_AT_ranges
#    (shown with func1_with_ranges and func2_with_ranges sharing range 0x5000-0x6000)
#    This is also valid and can occur with -fbasic-block-sections=all
# 3. The test also verifies that non-identical overlapping ranges are correctly flagged as errors:
#    - When modifying just the first range's high offset from 0x6000 to 0x5999, it creates an invalid subrange overlap
#    - When modifying just the first instance of DW_AT_high_pc 0x77 to 0x66, it creates an invalid function overlap
# The test ensures llvm-dwarfdump --verify correctly validates these cases by:
#  a) Accepting valid identical overlapping ranges
#  b) Rejecting invalid non-identical overlapping ranges

# Need to use split-file in order for `sed` calls below to work correctly
# RUN: split-file %s %t
# RUN: yaml2obj %t/test.yaml | llvm-dwarfdump --error-display=details --verify - | FileCheck %s
# CHECK: No errors.

# RUN: sed -e '1,/HighOffset: 0x6000/s/HighOffset: 0x6000/HighOffset: 0x5999/' %t/test.yaml | yaml2obj | not llvm-dwarfdump --error-display=details --verify - | FileCheck %s --check-prefix=CHECK-RANGES
# CHECK-RANGES: error: DIEs have overlapping address ranges

# RUN: sed -e '1,/Value:  0x77/s/Value:  0x77/Value:  0x66/' %t/test.yaml | yaml2obj | not llvm-dwarfdump --error-display=details --verify - | FileCheck %s --check-prefix=CHECK-HIGH-PC
# CHECK-HIGH-PC: error: DIEs have overlapping address ranges

# RUN: sed -e '1,/LowOffset:  0x880111/s/LowOffset:  0x880111/LowOffset:  0x880112/' %t/test.yaml | yaml2obj | not llvm-dwarfdump --error-display=details --verify - | FileCheck %s --check-prefix=CHECK-LEX-BLOCK
# CHECK-LEX-BLOCK: DIE has overlapping ranges in DW_AT_ranges attribute

#--- test.yaml
--- !ELF
FileHeader:
  Class:    ELFCLASS64
  Data:     ELFDATA2LSB
  Type:     ET_REL
  Machine:  EM_X86_64
DWARF:
  debug_abbrev:
    - Table:
      - Tag:      DW_TAG_compile_unit
        Children: DW_CHILDREN_yes
        Attributes:
          - Attribute: DW_AT_producer
            Form:      DW_FORM_string
          - Attribute: DW_AT_language
            Form:      DW_FORM_data2
          - Attribute: DW_AT_name
            Form:      DW_FORM_string
          - Attribute: DW_AT_low_pc
            Form:      DW_FORM_addr
          - Attribute: DW_AT_high_pc
            Form:      DW_FORM_data8
      - Tag:      DW_TAG_subprogram
        Children: DW_CHILDREN_no
        Attributes:
          - Attribute: DW_AT_name
            Form:      DW_FORM_string
          - Attribute: DW_AT_low_pc
            Form:      DW_FORM_addr
          - Attribute: DW_AT_high_pc
            Form:      DW_FORM_data8
      - Tag:      DW_TAG_subprogram
        Children: DW_CHILDREN_no
        Attributes:
          - Attribute: DW_AT_name
            Form:      DW_FORM_string
          - Attribute: DW_AT_ranges
            Form:      DW_FORM_sec_offset
      - Tag:      DW_TAG_base_type
        Children: DW_CHILDREN_no
        Attributes:
          - Attribute: DW_AT_name
            Form:      DW_FORM_string
      - Tag:      DW_TAG_lexical_block
        Children: DW_CHILDREN_no
        Attributes:
          - Attribute: DW_AT_ranges
            Form:      DW_FORM_sec_offset
  debug_ranges:
    - Offset:    0x0
      AddrSize:  0x8
      Entries:
        - LowOffset:  0x1000
          HighOffset: 0x2000
        - LowOffset:  0x3000
          HighOffset: 0x4000
        - LowOffset:  0x5000  # Overlaps with 2nd range below
          HighOffset: 0x6000
        - LowOffset:  0x0
          HighOffset: 0x0
    - Offset:    0x50
      AddrSize:  0x8
      Entries:
        - LowOffset:  0x2500
          HighOffset: 0x2800
        - LowOffset:  0x5000  # Overlaps with 3rd range above
          HighOffset: 0x6000
        - LowOffset:  0x7000
          HighOffset: 0x8000
        - LowOffset:  0x0
          HighOffset: 0x0
    - Offset: 0xA0   # Added Range List #3 for lexical block
      AddrSize: 0x8
      Entries:
        - LowOffset:  0x880111
          HighOffset: 0x881222
        - LowOffset:  0x882333
          HighOffset: 0x883444
        - LowOffset:  0x880111  # Overlaps with 1st range in the same list
          HighOffset: 0x881222
        - LowOffset:  0x0   # End of list
          HighOffset: 0x0
  debug_info:
    - Version: 4
      Entries:
        - AbbrCode: 1
          Values:
            - CStr: by_hand
            - Value:  0x04
            - CStr: CU1
            - Value:  0x1000
            - Value:  0x100
        - AbbrCode: 4
          Values:
            - CStr: int
        - AbbrCode: 2
          Values:
            - CStr: foo1
            - Value:  0x1000
            - Value:  0x10
        - AbbrCode: 2
          Values:
            - CStr: foo2
            - Value:  0x0    # Overlaps with 'foo3' below
            - Value:  0x77
        - AbbrCode: 2
          Values:
            - CStr: foo3
            - Value:  0x0    # Overlaps with 'foo2' above
            - Value:  0x77
        - AbbrCode: 3
          Values:
            - CStr: func1_with_ranges
            - Value:  0x0
        - AbbrCode: 3
          Values:
            - CStr: func2_with_ranges
            - Value:  0x50
        - AbbrCode: 5   # Added lexical block using ranges
          Values:
            - Value: 0xA0 # Range list index in debug_ranges
        - AbbrCode: 0
...