Skip to content

Commit 1550e57

Browse files
committed
Merge from 'main' to 'sycl-web' (107 commits)
CONFLICT (content): Merge conflict in clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
2 parents c9af821 + 7318fe6 commit 1550e57

File tree

300 files changed

+16935
-2266
lines changed

Some content is hidden

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

300 files changed

+16935
-2266
lines changed

bolt/include/bolt/Rewrite/RewriteInstance.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,7 @@ class RewriteInstance {
430430

431431
/// Common section names.
432432
static StringRef getEHFrameSectionName() { return ".eh_frame"; }
433+
static StringRef getRelaDynSectionName() { return ".rela.dyn"; }
433434

434435
/// An instance of the input binary we are processing, externally owned.
435436
llvm::object::ELFObjectFileBase *InputFile;

bolt/lib/Passes/ADRRelaxationPass.cpp

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,14 @@ void ADRRelaxationPass::runOnFunction(BinaryFunction &BF) {
5656
continue;
5757
}
5858

59-
BinaryFunction *TargetBF = BC.getFunctionForSymbol(Symbol);
60-
if (TargetBF && TargetBF == &BF)
61-
continue;
59+
// Don't relax adr if it points to the same function and it is not split
60+
// and BF initial size is < 1MB.
61+
const unsigned OneMB = 0x100000;
62+
if (!BF.isSplit() && BF.getSize() < OneMB) {
63+
BinaryFunction *TargetBF = BC.getFunctionForSymbol(Symbol);
64+
if (TargetBF && TargetBF == &BF)
65+
continue;
66+
}
6267

6368
MCPhysReg Reg;
6469
BC.MIB->getADRReg(Inst, Reg);
@@ -72,14 +77,17 @@ void ADRRelaxationPass::runOnFunction(BinaryFunction &BF) {
7277

7378
if (It != BB.begin() && BC.MIB->isNoop(*std::prev(It))) {
7479
It = BB.eraseInstruction(std::prev(It));
75-
} else if (opts::StrictMode && !BF.isSimple()) {
80+
} else if (std::next(It) != BB.end() && BC.MIB->isNoop(*std::next(It))) {
81+
BB.eraseInstruction(std::next(It));
82+
} else if (!opts::StrictMode && !BF.isSimple()) {
7683
// If the function is not simple, it may contain a jump table undetected
7784
// by us. This jump table may use an offset from the branch instruction
7885
// to land in the desired place. If we add new instructions, we
7986
// invalidate this offset, so we have to rely on linker-inserted NOP to
8087
// replace it with ADRP, and abort if it is not present.
88+
auto L = BC.scopeLock();
8189
errs() << formatv("BOLT-ERROR: Cannot relax adr in non-simple function "
82-
"{0}. Can't proceed in current mode.\n",
90+
"{0}. Use --strict option to override\n",
8391
BF.getOneName());
8492
PassFailed = true;
8593
return;

bolt/lib/Rewrite/DWARFRewriter.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,7 @@ getDWOName(llvm::DWARFUnit &CU,
440440
assert(!DWOName.empty() &&
441441
"DW_AT_dwo_name/DW_AT_GNU_dwo_name does not exists.");
442442
if (!opts::DwarfOutputPath.empty()) {
443+
DWOName = std::string(sys::path::filename(DWOName));
443444
auto Iter = NameToIndexMap.find(DWOName);
444445
if (Iter == NameToIndexMap.end())
445446
Iter = NameToIndexMap.insert({DWOName, 0}).first;

bolt/lib/Rewrite/RewriteInstance.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2217,6 +2217,19 @@ void RewriteInstance::processDynamicRelocations() {
22172217
}
22182218

22192219
// The rest of dynamic relocations - DT_RELA.
2220+
// The static executable might have .rela.dyn secion and not have PT_DYNAMIC
2221+
if (!DynamicRelocationsSize && BC->IsStaticExecutable) {
2222+
ErrorOr<BinarySection &> DynamicRelSectionOrErr =
2223+
BC->getUniqueSectionByName(getRelaDynSectionName());
2224+
if (DynamicRelSectionOrErr) {
2225+
DynamicRelocationsAddress = DynamicRelSectionOrErr->getAddress();
2226+
DynamicRelocationsSize = DynamicRelSectionOrErr->getSize();
2227+
const SectionRef &SectionRef = DynamicRelSectionOrErr->getSectionRef();
2228+
DynamicRelativeRelocationsCount = std::distance(
2229+
SectionRef.relocation_begin(), SectionRef.relocation_end());
2230+
}
2231+
}
2232+
22202233
if (DynamicRelocationsSize > 0) {
22212234
ErrorOr<BinarySection &> DynamicRelSectionOrErr =
22222235
BC->getSectionForAddress(*DynamicRelocationsAddress);

bolt/test/AArch64/ifunc.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,20 @@
77
// RUN: llvm-bolt %t.O0.exe -o %t.O0.bolt.exe \
88
// RUN: --print-disasm --print-only=_start | \
99
// RUN: FileCheck --check-prefix=O0_CHECK %s
10+
// RUN: llvm-readelf -aW %t.O0.bolt.exe | \
11+
// RUN: FileCheck --check-prefix=REL_CHECK %s
12+
13+
// Non-pie static executable doesn't generate PT_DYNAMIC, check relocation
14+
// is readed successfully and IPLT trampoline has been identified by bolt.
15+
// RUN: %clang %cflags -nostdlib -O3 %s -fuse-ld=lld -no-pie \
16+
// RUN: -o %t.O3_nopie.exe -Wl,-q
17+
// RUN: llvm-readelf -l %t.O3_nopie.exe | \
18+
// RUN: FileCheck --check-prefix=NON_DYN_CHECK %s
19+
// RUN: llvm-bolt %t.O3_nopie.exe -o %t.O3_nopie.bolt.exe \
20+
// RUN: --print-disasm --print-only=_start | \
21+
// RUN: FileCheck --check-prefix=O3_CHECK %s
22+
// RUN: llvm-readelf -aW %t.O3_nopie.bolt.exe | \
23+
// RUN: FileCheck --check-prefix=REL_CHECK %s
1024

1125
// With -O3 direct call is performed on IPLT trampoline. IPLT trampoline
1226
// doesn't have associated symbol. The ifunc symbol has the same address as
@@ -16,6 +30,8 @@
1630
// RUN: llvm-bolt %t.O3_pie.exe -o %t.O3_pie.bolt.exe \
1731
// RUN: --print-disasm --print-only=_start | \
1832
// RUN: FileCheck --check-prefix=O3_CHECK %s
33+
// RUN: llvm-readelf -aW %t.O3_pie.bolt.exe | \
34+
// RUN: FileCheck --check-prefix=REL_CHECK %s
1935

2036
// Check that IPLT trampoline located in .plt section are normally handled by
2137
// BOLT. The gnu-ld linker doesn't use separate .iplt section.
@@ -24,10 +40,17 @@
2440
// RUN: llvm-bolt %t.iplt_O3_pie.exe -o %t.iplt_O3_pie.bolt.exe \
2541
// RUN: --print-disasm --print-only=_start | \
2642
// RUN: FileCheck --check-prefix=O3_CHECK %s
43+
// RUN: llvm-readelf -aW %t.iplt_O3_pie.bolt.exe | \
44+
// RUN: FileCheck --check-prefix=REL_CHECK %s
45+
46+
// NON_DYN_CHECK-NOT: DYNAMIC
2747

2848
// O0_CHECK: adr x{{[0-9]+}}, ifoo
2949
// O3_CHECK: b "{{resolver_foo|ifoo}}{{.*}}@PLT"
3050

51+
// REL_CHECK: R_AARCH64_IRELATIVE [[#%x,REL_SYMB_ADDR:]]
52+
// REL_CHECK: [[#REL_SYMB_ADDR]] {{.*}} FUNC {{.*}} resolver_foo
53+
3154
static void foo() {}
3255

3356
static void *resolver_foo(void) { return foo; }

bolt/test/AArch64/r_aarch64_prelxx.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// CHECKPREL-NEXT: R_AARCH64_PREL32 {{.*}} _start + 4
1313
// CHECKPREL-NEXT: R_AARCH64_PREL64 {{.*}} _start + 8
1414

15-
// RUN: llvm-bolt %t.exe -o %t.bolt
15+
// RUN: llvm-bolt %t.exe -o %t.bolt --strict
1616
// RUN: llvm-objdump -D %t.bolt | FileCheck %s --check-prefix=CHECKPREL32
1717

1818
// CHECKPREL32: [[#%x,DATATABLEADDR:]] <datatable>:
Lines changed: 225 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,225 @@
1+
# clang++ helper.cpp -g2 -gsplit-dwarf -S -fdebug-compilation-dir=.
2+
# Modified assembly so that DW_AT_dwo_name has a partial path.
3+
# int foo() { return 0; }
4+
.text
5+
.file "helper.cpp"
6+
.globl _Z3foov # -- Begin function _Z3foov
7+
.p2align 4, 0x90
8+
.type _Z3foov,@function
9+
_Z3foov: # @_Z3foov
10+
.Lfunc_begin0:
11+
.file 0 "." "helper.cpp" md5 0xde8d315e6d1f74ad53575cef6507e770
12+
.loc 0 1 0 # helper.cpp:1:0
13+
.cfi_startproc
14+
# %bb.0: # %entry
15+
pushq %rbp
16+
.cfi_def_cfa_offset 16
17+
.cfi_offset %rbp, -16
18+
movq %rsp, %rbp
19+
.cfi_def_cfa_register %rbp
20+
.Ltmp0:
21+
.loc 0 1 13 prologue_end # helper.cpp:1:13
22+
xorl %eax, %eax
23+
.loc 0 1 13 epilogue_begin is_stmt 0 # helper.cpp:1:13
24+
popq %rbp
25+
.cfi_def_cfa %rsp, 8
26+
retq
27+
.Ltmp1:
28+
.Lfunc_end0:
29+
.size _Z3foov, .Lfunc_end0-_Z3foov
30+
.cfi_endproc
31+
# -- End function
32+
.section .debug_abbrev,"",@progbits
33+
.byte 1 # Abbreviation Code
34+
.byte 74 # DW_TAG_skeleton_unit
35+
.byte 0 # DW_CHILDREN_no
36+
.byte 16 # DW_AT_stmt_list
37+
.byte 23 # DW_FORM_sec_offset
38+
.byte 114 # DW_AT_str_offsets_base
39+
.byte 23 # DW_FORM_sec_offset
40+
.byte 27 # DW_AT_comp_dir
41+
.byte 37 # DW_FORM_strx1
42+
.ascii "\264B" # DW_AT_GNU_pubnames
43+
.byte 25 # DW_FORM_flag_present
44+
.byte 118 # DW_AT_dwo_name
45+
.byte 37 # DW_FORM_strx1
46+
.byte 17 # DW_AT_low_pc
47+
.byte 27 # DW_FORM_addrx
48+
.byte 18 # DW_AT_high_pc
49+
.byte 6 # DW_FORM_data4
50+
.byte 115 # DW_AT_addr_base
51+
.byte 23 # DW_FORM_sec_offset
52+
.byte 0 # EOM(1)
53+
.byte 0 # EOM(2)
54+
.byte 0 # EOM(3)
55+
.section .debug_info,"",@progbits
56+
.Lcu_begin0:
57+
.long .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit
58+
.Ldebug_info_start0:
59+
.short 5 # DWARF version number
60+
.byte 4 # DWARF Unit Type
61+
.byte 8 # Address Size (in bytes)
62+
.long .debug_abbrev # Offset Into Abbrev. Section
63+
.quad -1360665163647638292
64+
.byte 1 # Abbrev [1] 0x14:0x14 DW_TAG_skeleton_unit
65+
.long .Lline_table_start0 # DW_AT_stmt_list
66+
.long .Lstr_offsets_base0 # DW_AT_str_offsets_base
67+
.byte 0 # DW_AT_comp_dir
68+
# DW_AT_GNU_pubnames
69+
.byte 1 # DW_AT_dwo_name
70+
.byte 0 # DW_AT_low_pc
71+
.long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc
72+
.long .Laddr_table_base0 # DW_AT_addr_base
73+
.Ldebug_info_end0:
74+
.section .debug_str_offsets,"",@progbits
75+
.long 12 # Length of String Offsets Set
76+
.short 5
77+
.short 0
78+
.Lstr_offsets_base0:
79+
.section .debug_str,"MS",@progbits,1
80+
.Lskel_string0:
81+
.asciz "." # string offset=0
82+
.Lskel_string1:
83+
.asciz "objects/o2/split.dwo" # string offset=2 <-- Manually modified.
84+
.section .debug_str_offsets,"",@progbits
85+
.long .Lskel_string0
86+
.long .Lskel_string1
87+
.section .debug_str_offsets.dwo,"e",@progbits
88+
.long 28 # Length of String Offsets Set
89+
.short 5
90+
.short 0
91+
.section .debug_str.dwo,"eMS",@progbits,1
92+
.Linfo_string0:
93+
.asciz "_Z3foov" # string offset=0
94+
.Linfo_string1:
95+
.asciz "foo" # string offset=8
96+
.Linfo_string2:
97+
.asciz "int" # string offset=12
98+
.Linfo_string3:
99+
.asciz "clang version 18.0.0" # string offset=16
100+
.Linfo_string4:
101+
.asciz "helper.cpp" # string offset=37
102+
.Linfo_string5:
103+
.asciz "objects/o2/split.dwo" # string offset=48 <-- Manually modified.
104+
.section .debug_str_offsets.dwo,"e",@progbits
105+
.long 0
106+
.long 8
107+
.long 12
108+
.long 16
109+
.long 37
110+
.long 48
111+
.section .debug_info.dwo,"e",@progbits
112+
.long .Ldebug_info_dwo_end0-.Ldebug_info_dwo_start0 # Length of Unit
113+
.Ldebug_info_dwo_start0:
114+
.short 5 # DWARF version number
115+
.byte 5 # DWARF Unit Type
116+
.byte 8 # Address Size (in bytes)
117+
.long 0 # Offset Into Abbrev. Section
118+
.quad -1360665163647638292
119+
.byte 1 # Abbrev [1] 0x14:0x1b DW_TAG_compile_unit
120+
.byte 3 # DW_AT_producer
121+
.short 33 # DW_AT_language
122+
.byte 4 # DW_AT_name
123+
.byte 5 # DW_AT_dwo_name
124+
.byte 2 # Abbrev [2] 0x1a:0x10 DW_TAG_subprogram
125+
.byte 0 # DW_AT_low_pc
126+
.long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc
127+
.byte 1 # DW_AT_frame_base
128+
.byte 86
129+
.byte 0 # DW_AT_linkage_name
130+
.byte 1 # DW_AT_name
131+
.byte 0 # DW_AT_decl_file
132+
.byte 1 # DW_AT_decl_line
133+
.long 42 # DW_AT_type
134+
# DW_AT_external
135+
.byte 3 # Abbrev [3] 0x2a:0x4 DW_TAG_base_type
136+
.byte 2 # DW_AT_name
137+
.byte 5 # DW_AT_encoding
138+
.byte 4 # DW_AT_byte_size
139+
.byte 0 # End Of Children Mark
140+
.Ldebug_info_dwo_end0:
141+
.section .debug_abbrev.dwo,"e",@progbits
142+
.byte 1 # Abbreviation Code
143+
.byte 17 # DW_TAG_compile_unit
144+
.byte 1 # DW_CHILDREN_yes
145+
.byte 37 # DW_AT_producer
146+
.byte 37 # DW_FORM_strx1
147+
.byte 19 # DW_AT_language
148+
.byte 5 # DW_FORM_data2
149+
.byte 3 # DW_AT_name
150+
.byte 37 # DW_FORM_strx1
151+
.byte 118 # DW_AT_dwo_name
152+
.byte 37 # DW_FORM_strx1
153+
.byte 0 # EOM(1)
154+
.byte 0 # EOM(2)
155+
.byte 2 # Abbreviation Code
156+
.byte 46 # DW_TAG_subprogram
157+
.byte 0 # DW_CHILDREN_no
158+
.byte 17 # DW_AT_low_pc
159+
.byte 27 # DW_FORM_addrx
160+
.byte 18 # DW_AT_high_pc
161+
.byte 6 # DW_FORM_data4
162+
.byte 64 # DW_AT_frame_base
163+
.byte 24 # DW_FORM_exprloc
164+
.byte 110 # DW_AT_linkage_name
165+
.byte 37 # DW_FORM_strx1
166+
.byte 3 # DW_AT_name
167+
.byte 37 # DW_FORM_strx1
168+
.byte 58 # DW_AT_decl_file
169+
.byte 11 # DW_FORM_data1
170+
.byte 59 # DW_AT_decl_line
171+
.byte 11 # DW_FORM_data1
172+
.byte 73 # DW_AT_type
173+
.byte 19 # DW_FORM_ref4
174+
.byte 63 # DW_AT_external
175+
.byte 25 # DW_FORM_flag_present
176+
.byte 0 # EOM(1)
177+
.byte 0 # EOM(2)
178+
.byte 3 # Abbreviation Code
179+
.byte 36 # DW_TAG_base_type
180+
.byte 0 # DW_CHILDREN_no
181+
.byte 3 # DW_AT_name
182+
.byte 37 # DW_FORM_strx1
183+
.byte 62 # DW_AT_encoding
184+
.byte 11 # DW_FORM_data1
185+
.byte 11 # DW_AT_byte_size
186+
.byte 11 # DW_FORM_data1
187+
.byte 0 # EOM(1)
188+
.byte 0 # EOM(2)
189+
.byte 0 # EOM(3)
190+
.section .debug_addr,"",@progbits
191+
.long .Ldebug_addr_end0-.Ldebug_addr_start0 # Length of contribution
192+
.Ldebug_addr_start0:
193+
.short 5 # DWARF version number
194+
.byte 8 # Address size
195+
.byte 0 # Segment selector size
196+
.Laddr_table_base0:
197+
.quad .Lfunc_begin0
198+
.Ldebug_addr_end0:
199+
.section .debug_gnu_pubnames,"",@progbits
200+
.long .LpubNames_end0-.LpubNames_start0 # Length of Public Names Info
201+
.LpubNames_start0:
202+
.short 2 # DWARF Version
203+
.long .Lcu_begin0 # Offset of Compilation Unit Info
204+
.long 40 # Compilation Unit Length
205+
.long 26 # DIE offset
206+
.byte 48 # Attributes: FUNCTION, EXTERNAL
207+
.asciz "foo" # External Name
208+
.long 0 # End Mark
209+
.LpubNames_end0:
210+
.section .debug_gnu_pubtypes,"",@progbits
211+
.long .LpubTypes_end0-.LpubTypes_start0 # Length of Public Types Info
212+
.LpubTypes_start0:
213+
.short 2 # DWARF Version
214+
.long .Lcu_begin0 # Offset of Compilation Unit Info
215+
.long 40 # Compilation Unit Length
216+
.long 42 # DIE offset
217+
.byte 144 # Attributes: TYPE, STATIC
218+
.asciz "int" # External Name
219+
.long 0 # End Mark
220+
.LpubTypes_end0:
221+
.ident "clang version 18.0.0"
222+
.section ".note.GNU-stack","",@progbits
223+
.addrsig
224+
.section .debug_line,"",@progbits
225+
.Lline_table_start0:

0 commit comments

Comments
 (0)