Skip to content

Commit 44eef3d

Browse files
committed
Merge from 'main' to 'sycl-web' (94 commits)
CONFLICT (content): Merge conflict in clang/lib/CodeGen/CGBuiltin.cpp
2 parents ea9d379 + f335883 commit 44eef3d

File tree

360 files changed

+26302
-9943
lines changed

Some content is hidden

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

360 files changed

+26302
-9943
lines changed

bolt/include/bolt/Core/BinaryContext.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,6 +1290,9 @@ class BinaryContext {
12901290
/// Return true if the function should be emitted to the output file.
12911291
bool shouldEmit(const BinaryFunction &Function) const;
12921292

1293+
/// Dump the assembly representation of MCInst to debug output.
1294+
void dump(const MCInst &Inst) const;
1295+
12931296
/// Print the string name for a CFI operation.
12941297
static void printCFI(raw_ostream &OS, const MCCFIInstruction &Inst);
12951298

bolt/lib/Core/BinaryContext.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1738,6 +1738,15 @@ bool BinaryContext::shouldEmit(const BinaryFunction &Function) const {
17381738
return HasRelocations || Function.isSimple();
17391739
}
17401740

1741+
void BinaryContext::dump(const MCInst &Inst) const {
1742+
if (LLVM_UNLIKELY(!InstPrinter)) {
1743+
dbgs() << "Cannot dump for InstPrinter is not initialized.\n";
1744+
return;
1745+
}
1746+
InstPrinter->printInst(&Inst, 0, "", *STI, dbgs());
1747+
dbgs() << "\n";
1748+
}
1749+
17411750
void BinaryContext::printCFI(raw_ostream &OS, const MCCFIInstruction &Inst) {
17421751
uint32_t Operation = Inst.getOperation();
17431752
switch (Operation) {

bolt/lib/Core/Exceptions.cpp

Lines changed: 33 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,18 @@ void BinaryFunction::parseLSDA(ArrayRef<uint8_t> LSDASectionData,
112112
uint64_t Offset = getLSDAAddress() - LSDASectionAddress;
113113
assert(Data.isValidOffset(Offset) && "wrong LSDA address");
114114

115-
uint8_t LPStartEncoding = Data.getU8(&Offset);
116-
uint64_t LPStart = 0;
117-
// Convert to offset if LPStartEncoding is typed absptr DW_EH_PE_absptr
118-
if (std::optional<uint64_t> MaybeLPStart = Data.getEncodedPointer(
119-
&Offset, LPStartEncoding, Offset + LSDASectionAddress))
120-
LPStart = (LPStartEncoding && 0xFF == 0) ? *MaybeLPStart
121-
: *MaybeLPStart - Address;
115+
const uint8_t LPStartEncoding = Data.getU8(&Offset);
116+
uint64_t LPStart = Address;
117+
if (LPStartEncoding != dwarf::DW_EH_PE_omit) {
118+
std::optional<uint64_t> MaybeLPStart = Data.getEncodedPointer(
119+
&Offset, LPStartEncoding, Offset + LSDASectionAddress);
120+
if (!MaybeLPStart) {
121+
errs() << "BOLT-ERROR: unsupported LPStartEncoding: "
122+
<< (unsigned)LPStartEncoding << '\n';
123+
exit(1);
124+
}
125+
LPStart = *MaybeLPStart;
126+
}
122127

123128
const uint8_t TTypeEncoding = Data.getU8(&Offset);
124129
LSDATypeEncoding = TTypeEncoding;
@@ -175,38 +180,38 @@ void BinaryFunction::parseLSDA(ArrayRef<uint8_t> LSDASectionData,
175180
uint64_t LandingPad = *Data.getEncodedPointer(
176181
&CallSitePtr, CallSiteEncoding, CallSitePtr + LSDASectionAddress);
177182
uint64_t ActionEntry = Data.getULEB128(&CallSitePtr);
178-
179-
uint64_t LPOffset = LPStart + LandingPad;
180-
uint64_t LPAddress = Address + LPOffset;
181-
182-
// Verify if landing pad code is located outside current function
183-
// Support landing pad to builtin_unreachable
184-
if (LPAddress < Address || LPAddress > Address + getSize()) {
185-
BinaryFunction *Fragment =
186-
BC.getBinaryFunctionContainingAddress(LPAddress);
187-
assert(Fragment != nullptr &&
188-
"BOLT-ERROR: cannot find landing pad fragment");
189-
BC.addInterproceduralReference(this, Fragment->getAddress());
190-
BC.processInterproceduralReferences();
191-
assert(isParentOrChildOf(*Fragment) &&
192-
"BOLT-ERROR: cannot have landing pads in different functions");
193-
setHasIndirectTargetToSplitFragment(true);
194-
BC.addFragmentsToSkip(this);
195-
return;
196-
}
183+
if (LandingPad)
184+
LandingPad += LPStart;
197185

198186
if (opts::PrintExceptions) {
199187
outs() << "Call Site: [0x" << Twine::utohexstr(RangeBase + Start)
200188
<< ", 0x" << Twine::utohexstr(RangeBase + Start + Length)
201-
<< "); landing pad: 0x" << Twine::utohexstr(LPOffset)
189+
<< "); landing pad: 0x" << Twine::utohexstr(LandingPad)
202190
<< "; action entry: 0x" << Twine::utohexstr(ActionEntry) << "\n";
203191
outs() << " current offset is " << (CallSitePtr - CallSiteTableStart)
204192
<< '\n';
205193
}
206194

207195
// Create a handler entry if necessary.
208196
MCSymbol *LPSymbol = nullptr;
209-
if (LPOffset) {
197+
if (LandingPad) {
198+
// Verify if landing pad code is located outside current function
199+
// Support landing pad to builtin_unreachable
200+
if (LandingPad < Address || LandingPad > Address + getSize()) {
201+
BinaryFunction *Fragment =
202+
BC.getBinaryFunctionContainingAddress(LandingPad);
203+
assert(Fragment != nullptr &&
204+
"BOLT-ERROR: cannot find landing pad fragment");
205+
BC.addInterproceduralReference(this, Fragment->getAddress());
206+
BC.processInterproceduralReferences();
207+
assert(isParentOrChildOf(*Fragment) &&
208+
"BOLT-ERROR: cannot have landing pads in different functions");
209+
setHasIndirectTargetToSplitFragment(true);
210+
BC.addFragmentsToSkip(this);
211+
return;
212+
}
213+
214+
const uint64_t LPOffset = LandingPad - getAddress();
210215
if (!getInstructionAtOffset(LPOffset)) {
211216
if (opts::Verbosity >= 1)
212217
errs() << "BOLT-WARNING: landing pad " << Twine::utohexstr(LPOffset)

bolt/lib/Passes/ValidateInternalCalls.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -281,18 +281,16 @@ bool ValidateInternalCalls::analyzeFunction(BinaryFunction &Function) const {
281281
LLVM_DEBUG({
282282
dbgs() << "Detected out-of-range PIC reference in " << Function
283283
<< "\nReturn address load: ";
284-
BC.InstPrinter->printInst(TargetInst, 0, "", *BC.STI, dbgs());
285-
dbgs() << "\nUse: ";
286-
BC.InstPrinter->printInst(&Use, 0, "", *BC.STI, dbgs());
287-
dbgs() << "\n";
284+
BC.dump(*TargetInst);
285+
dbgs() << "Use: ";
286+
BC.dump(Use);
288287
Function.dump();
289288
});
290289
return false;
291290
}
292291
LLVM_DEBUG({
293292
dbgs() << "Validated access: ";
294-
BC.InstPrinter->printInst(&Use, 0, "", *BC.STI, dbgs());
295-
dbgs() << "\n";
293+
BC.dump(Use);
296294
});
297295
}
298296
if (!UseDetected) {
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# RUN: %clangxx %cflags -no-pie %s -o %t.exe -Wl,-q
2+
# RUN: llvm-bolt %t.exe -o %t.exe.bolt
3+
# RUN: %t.exe.bolt
4+
5+
# REQUIRES: system-linux
6+
7+
## Test that BOLT properly handles LPStart when LPStartEncoding is different
8+
## from DW_EH_PE_omit.
9+
10+
# The test case compiled with -O1 from:
11+
#
12+
# int main() {
13+
# try {
14+
# throw 42;
15+
# } catch (...) {
16+
# return 0;
17+
# }
18+
# return 1;
19+
# }
20+
#
21+
# The exception table was modified with udata4 LPStartEncoding and sdata4
22+
# CallSiteEncoding.
23+
24+
.text
25+
.globl main # -- Begin function main
26+
.p2align 4, 0x90
27+
.type main,@function
28+
main: # @main
29+
.Lfunc_begin0:
30+
.cfi_startproc
31+
.cfi_personality 3, __gxx_personality_v0
32+
.cfi_lsda 3, .Lexception0
33+
# %bb.0:
34+
pushq %rax
35+
.cfi_def_cfa_offset 16
36+
movl $4, %edi
37+
callq __cxa_allocate_exception
38+
movl $42, (%rax)
39+
.Ltmp0:
40+
movl $_ZTIi, %esi
41+
movq %rax, %rdi
42+
xorl %edx, %edx
43+
callq __cxa_throw
44+
.Ltmp1:
45+
# %bb.1:
46+
.LBB0_2:
47+
.Ltmp2:
48+
movq %rax, %rdi
49+
callq __cxa_begin_catch
50+
callq __cxa_end_catch
51+
xorl %eax, %eax
52+
popq %rcx
53+
.cfi_def_cfa_offset 8
54+
retq
55+
.Lfunc_end0:
56+
.size main, .Lfunc_end0-main
57+
.cfi_endproc
58+
.section .gcc_except_table,"a",@progbits
59+
.p2align 2
60+
GCC_except_table0:
61+
.Lexception0:
62+
.byte 3 # @LPStart Encoding = udata4
63+
.long 0
64+
.byte 3 # @TType Encoding = udata4
65+
.uleb128 .Lttbase0-.Lttbaseref0
66+
.Lttbaseref0:
67+
.byte 11 # Call site Encoding = sdata4
68+
.uleb128 .Lcst_end0-.Lcst_begin0
69+
.Lcst_begin0:
70+
.long .Lfunc_begin0-.Lfunc_begin0 # >> Call Site 1 <<
71+
.long .Ltmp0-.Lfunc_begin0 # Call between .Lfunc_begin0 and .Ltmp0
72+
.long 0 # has no landing pad
73+
.byte 0 # On action: cleanup
74+
.long .Ltmp0-.Lfunc_begin0 # >> Call Site 2 <<
75+
.long .Ltmp1-.Ltmp0 # Call between .Ltmp0 and .Ltmp1
76+
.long .Ltmp2 # jumps to .Ltmp2
77+
.byte 1 # On action: 1
78+
.long .Ltmp1-.Lfunc_begin0 # >> Call Site 3 <<
79+
.long .Lfunc_end0-.Ltmp1 # Call between .Ltmp1 and .Lfunc_end0
80+
.long 0 # has no landing pad
81+
.byte 0 # On action: cleanup
82+
.Lcst_end0:
83+
.byte 1 # >> Action Record 1 <<
84+
# Catch TypeInfo 1
85+
.byte 0 # No further actions
86+
.p2align 2
87+
# >> Catch TypeInfos <<
88+
.long 0 # TypeInfo 1
89+
.Lttbase0:
90+
.p2align 2
91+
# -- End function

clang/docs/ReleaseNotes.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,8 @@ Bug Fixes in This Version
608608

609609
- Fixed an issue that a benign assertion might hit when instantiating a pack expansion
610610
inside a lambda. (`#61460 <https://github.com/llvm/llvm-project/issues/61460>`_)
611+
- Fix crash during instantiation of some class template specializations within class
612+
templates. Fixes (`#70375 <https://github.com/llvm/llvm-project/issues/70375>`_)
611613

612614
Bug Fixes to Compiler Builtins
613615
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -936,6 +938,10 @@ Static Analyzer
936938
- Added a new checker ``core.BitwiseShift`` which reports situations where
937939
bitwise shift operators produce undefined behavior (because some operand is
938940
negative or too large).
941+
942+
- Move checker ``alpha.unix.Errno`` out of the ``alpha`` package
943+
to ``unix.Errno``.
944+
939945
- Move checker ``alpha.unix.StdCLibraryFunctions`` out of the ``alpha`` package
940946
to ``unix.StdCLibraryFunctions``.
941947

0 commit comments

Comments
 (0)