Skip to content

Commit b16d2b4

Browse files
committed
Merge from 'main' to 'sycl-web' (100 commits)
Temporarily revert 4716696 [OpenMP] Deprecate the old driver for OpenMP offloading, since the patch from llvm.org influences construct offload-wrapper command for sycl. CONFLICT (modify/delete): clang/tools/clang-offload-wrapper/ClangOffloadWrapper.cpp deleted in 4716696 and modified in HEAD. Version HEAD of clang/tools/clang-offload-wrapper/ClangOffloadWrapper.cpp left in tree. CONFLICT (content): Merge conflict in clang/tools/CMakeLists.txt CONFLICT (content): Merge conflict in clang/test/Driver/openmp-offload.c CONFLICT (modify/delete): clang/test/Driver/clang-offload-wrapper.c deleted in 4716696 and modified in HEAD. Version HEAD of clang/test/Driver/clang-offload-wrapper.c left in tree. CONFLICT (content): Merge conflict in clang/test/Driver/amdgpu-openmp-toolchain.c CONFLICT (modify/delete): clang/test/Driver/amdgpu-openmp-toolchain-new.c deleted in 4716696 and modified in HEAD. Version HEAD of clang/test/Driver/amdgpu-openmp-toolchain-new.c left in tree. CONFLICT (content): Merge conflict in clang/lib/Driver/ToolChains/Cuda.h CONFLICT (content): Merge conflict in clang/lib/Driver/ToolChains/Cuda.cpp CONFLICT (content): Merge conflict in clang/lib/Driver/ToolChains/Clang.cpp CONFLICT (content): Merge conflict in clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp CONFLICT (content): Merge conflict in clang/lib/Driver/Driver.cpp CONFLICT (content): Merge conflict in clang/lib/Driver/Action.cpp CONFLICT (content): Merge conflict in clang/include/clang/Driver/Action.h
2 parents f7ab422 + 4716696 commit b16d2b4

File tree

384 files changed

+33733
-19860
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

384 files changed

+33733
-19860
lines changed

bolt/include/bolt/Core/DebugData.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,11 @@ class DebugAddrWriter {
319319
/// section.
320320
virtual uint64_t getOffset(DWARFUnit &Unit);
321321

322+
/// Returns True if CU exists in the DebugAddrWriter.
323+
bool doesCUExist(DWARFUnit &Unit) {
324+
return DWOIdToOffsetMap.count(getCUID(Unit)) > 0;
325+
}
326+
322327
/// Returns False if .debug_addr section was created..
323328
bool isInitialized() const { return !AddressMaps.empty(); }
324329

bolt/lib/Rewrite/DWARFRewriter.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,6 +1047,9 @@ DWARFRewriter::finalizeDebugSections(DebugInfoBinaryPatcher &DebugInfoPatcher) {
10471047
if (!AttrValGnu && CU->getVersion() < 5)
10481048
continue;
10491049

1050+
if (!AttrVal && CU->getVersion() >= 5 && !AddrWriter->doesCUExist(*CU))
1051+
continue;
1052+
10501053
Offset = AddrWriter->getOffset(*CU);
10511054

10521055
if (AttrValGnu) {
Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
# clang++ -g2 -gdwarf-5 helper.cpp -S
2+
# __attribute__ ((used))
3+
# static struct {
4+
# int i;
5+
# } Foo;
6+
7+
# Manually modifed to remove DW_AT_addr_base and DW_AT_location.
8+
9+
.text
10+
.file "helper.cpp"
11+
.file 0 "." "helper.cpp" md5 0x18c63f39ce5af555b264ad09798e35d5
12+
.type _ZL3Foo,@object # @_ZL3Foo
13+
.local _ZL3Foo
14+
.comm _ZL3Foo,4,4
15+
.section .debug_abbrev,"",@progbits
16+
.byte 1 # Abbreviation Code
17+
.byte 17 # DW_TAG_compile_unit
18+
.byte 1 # DW_CHILDREN_yes
19+
.byte 37 # DW_AT_producer
20+
.byte 37 # DW_FORM_strx1
21+
.byte 19 # DW_AT_language
22+
.byte 5 # DW_FORM_data2
23+
.byte 3 # DW_AT_name
24+
.byte 37 # DW_FORM_strx1
25+
.byte 114 # DW_AT_str_offsets_base
26+
.byte 23 # DW_FORM_sec_offset
27+
.byte 16 # DW_AT_stmt_list
28+
.byte 23 # DW_FORM_sec_offset
29+
.byte 27 # DW_AT_comp_dir
30+
.byte 37 # DW_FORM_strx1
31+
#.byte 115 # DW_AT_addr_base manually removed
32+
#.byte 23 # DW_FORM_sec_offset
33+
.byte 0 # EOM(1)
34+
.byte 0 # EOM(2)
35+
.byte 2 # Abbreviation Code
36+
.byte 52 # DW_TAG_variable
37+
.byte 0 # DW_CHILDREN_no
38+
.byte 3 # DW_AT_name
39+
.byte 37 # DW_FORM_strx1
40+
.byte 73 # DW_AT_type
41+
.byte 19 # DW_FORM_ref4
42+
.byte 58 # DW_AT_decl_file
43+
.byte 11 # DW_FORM_data1
44+
.byte 59 # DW_AT_decl_line
45+
.byte 11 # DW_FORM_data1
46+
#.byte 2 # DW_AT_location manually removed
47+
#.byte 24 # DW_FORM_exprloc
48+
.byte 110 # DW_AT_linkage_name
49+
.byte 37 # DW_FORM_strx1
50+
.byte 0 # EOM(1)
51+
.byte 0 # EOM(2)
52+
.byte 3 # Abbreviation Code
53+
.byte 19 # DW_TAG_structure_type
54+
.byte 1 # DW_CHILDREN_yes
55+
.byte 54 # DW_AT_calling_convention
56+
.byte 11 # DW_FORM_data1
57+
.byte 11 # DW_AT_byte_size
58+
.byte 11 # DW_FORM_data1
59+
.byte 58 # DW_AT_decl_file
60+
.byte 11 # DW_FORM_data1
61+
.byte 59 # DW_AT_decl_line
62+
.byte 11 # DW_FORM_data1
63+
.byte 0 # EOM(1)
64+
.byte 0 # EOM(2)
65+
.byte 4 # Abbreviation Code
66+
.byte 13 # DW_TAG_member
67+
.byte 0 # DW_CHILDREN_no
68+
.byte 3 # DW_AT_name
69+
.byte 37 # DW_FORM_strx1
70+
.byte 73 # DW_AT_type
71+
.byte 19 # DW_FORM_ref4
72+
.byte 58 # DW_AT_decl_file
73+
.byte 11 # DW_FORM_data1
74+
.byte 59 # DW_AT_decl_line
75+
.byte 11 # DW_FORM_data1
76+
.byte 56 # DW_AT_data_member_location
77+
.byte 11 # DW_FORM_data1
78+
.byte 0 # EOM(1)
79+
.byte 0 # EOM(2)
80+
.byte 5 # Abbreviation Code
81+
.byte 36 # DW_TAG_base_type
82+
.byte 0 # DW_CHILDREN_no
83+
.byte 3 # DW_AT_name
84+
.byte 37 # DW_FORM_strx1
85+
.byte 62 # DW_AT_encoding
86+
.byte 11 # DW_FORM_data1
87+
.byte 11 # DW_AT_byte_size
88+
.byte 11 # DW_FORM_data1
89+
.byte 0 # EOM(1)
90+
.byte 0 # EOM(2)
91+
.byte 0 # EOM(3)
92+
.section .debug_info,"",@progbits
93+
.Lcu_begin0:
94+
.long .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit
95+
.Ldebug_info_start0:
96+
.short 5 # DWARF version number
97+
.byte 1 # DWARF Unit Type
98+
.byte 8 # Address Size (in bytes)
99+
.long .debug_abbrev # Offset Into Abbrev. Section
100+
.byte 1 # Abbrev [1] 0xc:0x32 DW_TAG_compile_unit
101+
.byte 0 # DW_AT_producer
102+
.short 33 # DW_AT_language
103+
.byte 1 # DW_AT_name
104+
.long .Lstr_offsets_base0 # DW_AT_str_offsets_base
105+
.long .Lline_table_start0 # DW_AT_stmt_list
106+
.byte 2 # DW_AT_comp_dir
107+
#.long .Laddr_table_base0 # DW_AT_addr_base mannually removed
108+
.byte 2 # Abbrev [2] 0x1e:0xc DW_TAG_variable
109+
.byte 3 # DW_AT_name
110+
.long 42 # DW_AT_type
111+
.byte 0 # DW_AT_decl_file
112+
.byte 4 # DW_AT_decl_line
113+
#.byte 2 # DW_AT_location manually removed
114+
#.byte 161
115+
#.byte 0
116+
.byte 6 # DW_AT_linkage_name
117+
.byte 3 # Abbrev [3] 0x2a:0xf DW_TAG_structure_type
118+
.byte 5 # DW_AT_calling_convention
119+
.byte 4 # DW_AT_byte_size
120+
.byte 0 # DW_AT_decl_file
121+
.byte 2 # DW_AT_decl_line
122+
.byte 4 # Abbrev [4] 0x2f:0x9 DW_TAG_member
123+
.byte 4 # DW_AT_name
124+
.long 57 # DW_AT_type
125+
.byte 0 # DW_AT_decl_file
126+
.byte 3 # DW_AT_decl_line
127+
.byte 0 # DW_AT_data_member_location
128+
.byte 0 # End Of Children Mark
129+
.byte 5 # Abbrev [5] 0x39:0x4 DW_TAG_base_type
130+
.byte 5 # DW_AT_name
131+
.byte 5 # DW_AT_encoding
132+
.byte 4 # DW_AT_byte_size
133+
.byte 0 # End Of Children Mark
134+
.Ldebug_info_end0:
135+
.section .debug_str_offsets,"",@progbits
136+
.long 32 # Length of String Offsets Set
137+
.short 5
138+
.short 0
139+
.Lstr_offsets_base0:
140+
.section .debug_str,"MS",@progbits,1
141+
.Linfo_string0:
142+
.asciz "clang version 16.0.0" # string offset=0
143+
.Linfo_string1:
144+
.asciz "helper.cpp" # string offset=134
145+
.Linfo_string2:
146+
.asciz "." # string offset=145
147+
.Linfo_string3:
148+
.asciz "Foo" # string offset=183
149+
.Linfo_string4:
150+
.asciz "i" # string offset=187
151+
.Linfo_string5:
152+
.asciz "int" # string offset=189
153+
.Linfo_string6:
154+
.asciz "_ZL3Foo" # string offset=193
155+
.section .debug_str_offsets,"",@progbits
156+
.long .Linfo_string0
157+
.long .Linfo_string1
158+
.long .Linfo_string2
159+
.long .Linfo_string3
160+
.long .Linfo_string4
161+
.long .Linfo_string5
162+
.long .Linfo_string6
163+
.section .debug_addr,"",@progbits
164+
.long .Ldebug_addr_end0-.Ldebug_addr_start0 # Length of contribution
165+
.Ldebug_addr_start0:
166+
.short 5 # DWARF version number
167+
.byte 8 # Address size
168+
.byte 0 # Segment selector size
169+
.Laddr_table_base0:
170+
.quad _ZL3Foo
171+
.Ldebug_addr_end0:
172+
.ident "clang version 16.0.0"
173+
.section ".note.GNU-stack","",@progbits
174+
.addrsig
175+
.addrsig_sym _ZL3Foo
176+
.section .debug_line,"",@progbits
177+
.Lline_table_start0:
Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
# clang++ -g2 -gdwarf-5 main.cpp -S
2+
# int main(){
3+
# return 0;
4+
# }
5+
6+
7+
.text
8+
.file "main.cpp"
9+
.globl main # -- Begin function main
10+
.p2align 4, 0x90
11+
.type main,@function
12+
main: # @main
13+
.Lfunc_begin0:
14+
.file 0 "." "main.cpp" md5 0x1dc672a3317ca2ae06986e1275dcc6e7
15+
.loc 0 1 0 # main.cpp:1:0
16+
.cfi_startproc
17+
# %bb.0: # %entry
18+
pushq %rbp
19+
.cfi_def_cfa_offset 16
20+
.cfi_offset %rbp, -16
21+
movq %rsp, %rbp
22+
.cfi_def_cfa_register %rbp
23+
movl $0, -4(%rbp)
24+
.Ltmp0:
25+
.loc 0 2 3 prologue_end # main.cpp:2:3
26+
xorl %eax, %eax
27+
popq %rbp
28+
.cfi_def_cfa %rsp, 8
29+
retq
30+
.Ltmp1:
31+
.Lfunc_end0:
32+
.size main, .Lfunc_end0-main
33+
.cfi_endproc
34+
# -- End function
35+
.section .debug_abbrev,"",@progbits
36+
.byte 1 # Abbreviation Code
37+
.byte 17 # DW_TAG_compile_unit
38+
.byte 1 # DW_CHILDREN_yes
39+
.byte 37 # DW_AT_producer
40+
.byte 37 # DW_FORM_strx1
41+
.byte 19 # DW_AT_language
42+
.byte 5 # DW_FORM_data2
43+
.byte 3 # DW_AT_name
44+
.byte 37 # DW_FORM_strx1
45+
.byte 114 # DW_AT_str_offsets_base
46+
.byte 23 # DW_FORM_sec_offset
47+
.byte 16 # DW_AT_stmt_list
48+
.byte 23 # DW_FORM_sec_offset
49+
.byte 27 # DW_AT_comp_dir
50+
.byte 37 # DW_FORM_strx1
51+
.byte 17 # DW_AT_low_pc
52+
.byte 27 # DW_FORM_addrx
53+
.byte 18 # DW_AT_high_pc
54+
.byte 6 # DW_FORM_data4
55+
.byte 115 # DW_AT_addr_base
56+
.byte 23 # DW_FORM_sec_offset
57+
.byte 0 # EOM(1)
58+
.byte 0 # EOM(2)
59+
.byte 2 # Abbreviation Code
60+
.byte 46 # DW_TAG_subprogram
61+
.byte 0 # DW_CHILDREN_no
62+
.byte 17 # DW_AT_low_pc
63+
.byte 27 # DW_FORM_addrx
64+
.byte 18 # DW_AT_high_pc
65+
.byte 6 # DW_FORM_data4
66+
.byte 64 # DW_AT_frame_base
67+
.byte 24 # DW_FORM_exprloc
68+
.byte 3 # DW_AT_name
69+
.byte 37 # DW_FORM_strx1
70+
.byte 58 # DW_AT_decl_file
71+
.byte 11 # DW_FORM_data1
72+
.byte 59 # DW_AT_decl_line
73+
.byte 11 # DW_FORM_data1
74+
.byte 73 # DW_AT_type
75+
.byte 19 # DW_FORM_ref4
76+
.byte 63 # DW_AT_external
77+
.byte 25 # DW_FORM_flag_present
78+
.byte 0 # EOM(1)
79+
.byte 0 # EOM(2)
80+
.byte 3 # Abbreviation Code
81+
.byte 36 # DW_TAG_base_type
82+
.byte 0 # DW_CHILDREN_no
83+
.byte 3 # DW_AT_name
84+
.byte 37 # DW_FORM_strx1
85+
.byte 62 # DW_AT_encoding
86+
.byte 11 # DW_FORM_data1
87+
.byte 11 # DW_AT_byte_size
88+
.byte 11 # DW_FORM_data1
89+
.byte 0 # EOM(1)
90+
.byte 0 # EOM(2)
91+
.byte 0 # EOM(3)
92+
.section .debug_info,"",@progbits
93+
.Lcu_begin0:
94+
.long .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit
95+
.Ldebug_info_start0:
96+
.short 5 # DWARF version number
97+
.byte 1 # DWARF Unit Type
98+
.byte 8 # Address Size (in bytes)
99+
.long .debug_abbrev # Offset Into Abbrev. Section
100+
.byte 1 # Abbrev [1] 0xc:0x2b DW_TAG_compile_unit
101+
.byte 0 # DW_AT_producer
102+
.short 33 # DW_AT_language
103+
.byte 1 # DW_AT_name
104+
.long .Lstr_offsets_base0 # DW_AT_str_offsets_base
105+
.long .Lline_table_start0 # DW_AT_stmt_list
106+
.byte 2 # DW_AT_comp_dir
107+
.byte 0 # DW_AT_low_pc
108+
.long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc
109+
.long .Laddr_table_base0 # DW_AT_addr_base
110+
.byte 2 # Abbrev [2] 0x23:0xf DW_TAG_subprogram
111+
.byte 0 # DW_AT_low_pc
112+
.long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc
113+
.byte 1 # DW_AT_frame_base
114+
.byte 86
115+
.byte 3 # DW_AT_name
116+
.byte 0 # DW_AT_decl_file
117+
.byte 1 # DW_AT_decl_line
118+
.long 50 # DW_AT_type
119+
# DW_AT_external
120+
.byte 3 # Abbrev [3] 0x32:0x4 DW_TAG_base_type
121+
.byte 4 # DW_AT_name
122+
.byte 5 # DW_AT_encoding
123+
.byte 4 # DW_AT_byte_size
124+
.byte 0 # End Of Children Mark
125+
.Ldebug_info_end0:
126+
.section .debug_str_offsets,"",@progbits
127+
.long 24 # Length of String Offsets Set
128+
.short 5
129+
.short 0
130+
.Lstr_offsets_base0:
131+
.section .debug_str,"MS",@progbits,1
132+
.Linfo_string0:
133+
.asciz "clang version 16.0.0" # string offset=0
134+
.Linfo_string1:
135+
.asciz "main.cpp" # string offset=134
136+
.Linfo_string2:
137+
.asciz "." # string offset=143
138+
.Linfo_string3:
139+
.asciz "main" # string offset=181
140+
.Linfo_string4:
141+
.asciz "int" # string offset=186
142+
.section .debug_str_offsets,"",@progbits
143+
.long .Linfo_string0
144+
.long .Linfo_string1
145+
.long .Linfo_string2
146+
.long .Linfo_string3
147+
.long .Linfo_string4
148+
.section .debug_addr,"",@progbits
149+
.long .Ldebug_addr_end0-.Ldebug_addr_start0 # Length of contribution
150+
.Ldebug_addr_start0:
151+
.short 5 # DWARF version number
152+
.byte 8 # Address size
153+
.byte 0 # Segment selector size
154+
.Laddr_table_base0:
155+
.quad .Lfunc_begin0
156+
.Ldebug_addr_end0:
157+
.ident "clang version 16.0.0"
158+
.section ".note.GNU-stack","",@progbits
159+
.addrsig
160+
.section .debug_line,"",@progbits
161+
.Lline_table_start0:
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# REQUIRES: system-linux
2+
3+
# RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-cu-no-debug-addr-main.s -o %t1main.o
4+
# RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-cu-no-debug-addr-helper.s -o %t1helper.o
5+
# RUN: %clang %cflags -dwarf-5 %t1main.o %t1helper.o -o %t.exe -Wl,-q
6+
# RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections
7+
# RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.exe | FileCheck --check-prefix=PRECHECK %s
8+
# RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.bolt | FileCheck --check-prefix=POSTCHECK %s
9+
10+
# This tests checks that we handle correctly, don't crash, DWARF5 CUs that does not access .debug_addr.
11+
12+
# PRECHECK: DW_TAG_compile_unit
13+
# PRECHECK: DW_AT_addr_base
14+
# PRECHECK: DW_TAG_compile_unit
15+
# PRECHECK-NOT: DW_AT_addr_base
16+
17+
# POSTCHECK: DW_TAG_compile_unit
18+
# POSTCHECK: DW_AT_addr_base
19+
# POSTCHECK: DW_TAG_compile_unit
20+
# POSTCHECK-NOT: DW_AT_addr_base

0 commit comments

Comments
 (0)