Skip to content

Commit 673ba79

Browse files
committed
Merge branch 'fix/116485' of https://github.com/a-tarasyuk/llvm-project into fix/116485
2 parents d97a778 + 67bfd48 commit 673ba79

File tree

1,198 files changed

+32847
-16513
lines changed

Some content is hidden

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

1,198 files changed

+32847
-16513
lines changed

.ci/generate_test_report.py

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -309,10 +309,8 @@ def test_report_size_limit(self):
309309
# If include failures is False, total number of test will be reported but their names
310310
# and output will not be.
311311
def _generate_report(title, junit_objects, size_limit=1024 * 1024, list_failures=True):
312-
style = None
313-
314312
if not junit_objects:
315-
return ("", style)
313+
return ("", "success")
316314

317315
failures = {}
318316
tests_run = 0
@@ -403,22 +401,23 @@ def generate_report(title, junit_files):
403401

404402
report, style = generate_report(args.title, args.junit_files)
405403

406-
p = subprocess.Popen(
407-
[
408-
"buildkite-agent",
409-
"annotate",
410-
"--context",
411-
args.context,
412-
"--style",
413-
style,
414-
],
415-
stdin=subprocess.PIPE,
416-
stderr=subprocess.PIPE,
417-
universal_newlines=True,
418-
)
404+
if report:
405+
p = subprocess.Popen(
406+
[
407+
"buildkite-agent",
408+
"annotate",
409+
"--context",
410+
args.context,
411+
"--style",
412+
style,
413+
],
414+
stdin=subprocess.PIPE,
415+
stderr=subprocess.PIPE,
416+
universal_newlines=True,
417+
)
419418

420-
# The report can be larger than the buffer for command arguments so we send
421-
# it over stdin instead.
422-
_, err = p.communicate(input=report)
423-
if p.returncode:
424-
raise RuntimeError(f"Failed to send report to buildkite-agent:\n{err}")
419+
# The report can be larger than the buffer for command arguments so we send
420+
# it over stdin instead.
421+
_, err = p.communicate(input=report)
422+
if p.returncode:
423+
raise RuntimeError(f"Failed to send report to buildkite-agent:\n{err}")

.github/new-issues-labeler.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,6 @@
2727

2828
'bolt':
2929
- '/\bbolt(?!\-)\b/i'
30+
31+
'infra:commit-access-request':
32+
- '/Request Commit Access/'

.github/workflows/libcxx-build-and-test.yaml

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,11 @@ env:
4545
LLVM_SYMBOLIZER_PATH: "/usr/bin/llvm-symbolizer-19"
4646
CLANG_CRASH_DIAGNOSTICS_DIR: "crash_diagnostics"
4747

48-
4948
jobs:
5049
stage1:
5150
if: github.repository_owner == 'llvm'
52-
runs-on: libcxx-runners-set
53-
container: ghcr.io/libcxx/actions-builder:testing-2024-09-21
51+
runs-on: libcxx-self-hosted-linux
52+
container: ghcr.io/llvm/libcxx-linux-builder:0fd6f684b9c84c32d6cbfd9742402e788b2879f1
5453
continue-on-error: false
5554
strategy:
5655
fail-fast: false
@@ -86,8 +85,8 @@ jobs:
8685
**/crash_diagnostics/*
8786
stage2:
8887
if: github.repository_owner == 'llvm'
89-
runs-on: libcxx-runners-set
90-
container: ghcr.io/libcxx/actions-builder:testing-2024-09-21
88+
runs-on: libcxx-self-hosted-linux
89+
container: ghcr.io/llvm/libcxx-linux-builder:0fd6f684b9c84c32d6cbfd9742402e788b2879f1
9190
needs: [ stage1 ]
9291
continue-on-error: false
9392
strategy:
@@ -161,21 +160,21 @@ jobs:
161160
'generic-static',
162161
'bootstrapping-build'
163162
]
164-
machine: [ 'libcxx-runners-set' ]
163+
machine: [ 'libcxx-self-hosted-linux' ]
165164
include:
166165
- config: 'generic-cxx26'
167-
machine: libcxx-runners-set
166+
machine: libcxx-self-hosted-linux
168167
- config: 'generic-asan'
169-
machine: libcxx-runners-set
168+
machine: libcxx-self-hosted-linux
170169
- config: 'generic-tsan'
171-
machine: libcxx-runners-set
170+
machine: libcxx-self-hosted-linux
172171
- config: 'generic-ubsan'
173-
machine: libcxx-runners-set
172+
machine: libcxx-self-hosted-linux
174173
# Use a larger machine for MSAN to avoid timeout and memory allocation issues.
175174
- config: 'generic-msan'
176-
machine: libcxx-runners-set
175+
machine: libcxx-self-hosted-linux
177176
runs-on: ${{ matrix.machine }}
178-
container: ghcr.io/libcxx/actions-builder:testing-2024-09-21
177+
container: ghcr.io/llvm/libcxx-linux-builder:0fd6f684b9c84c32d6cbfd9742402e788b2879f1
179178
steps:
180179
- uses: actions/checkout@v4
181180
- name: ${{ matrix.config }}

bolt/lib/Core/BinaryEmitter.cpp

Lines changed: 19 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -906,17 +906,6 @@ void BinaryEmitter::emitLSDA(BinaryFunction &BF, const FunctionFragment &FF) {
906906
if (Sites.empty())
907907
return;
908908

909-
// Calculate callsite table size. Size of each callsite entry is:
910-
//
911-
// sizeof(start) + sizeof(length) + sizeof(LP) + sizeof(uleb128(action))
912-
//
913-
// or
914-
//
915-
// sizeof(dwarf::DW_EH_PE_data4) * 3 + sizeof(uleb128(action))
916-
uint64_t CallSiteTableLength = llvm::size(Sites) * 4 * 3;
917-
for (const auto &FragmentCallSite : Sites)
918-
CallSiteTableLength += getULEB128Size(FragmentCallSite.second.Action);
919-
920909
Streamer.switchSection(BC.MOFI->getLSDASection());
921910

922911
const unsigned TTypeEncoding = BF.getLSDATypeEncoding();
@@ -975,36 +964,24 @@ void BinaryEmitter::emitLSDA(BinaryFunction &BF, const FunctionFragment &FF) {
975964

976965
Streamer.emitIntValue(TTypeEncoding, 1); // TType format
977966

978-
// See the comment in EHStreamer::emitExceptionTable() on to use
979-
// uleb128 encoding (which can use variable number of bytes to encode the same
980-
// value) to ensure type info table is properly aligned at 4 bytes without
981-
// iteratively fixing sizes of the tables.
982-
unsigned CallSiteTableLengthSize = getULEB128Size(CallSiteTableLength);
983-
unsigned TTypeBaseOffset =
984-
sizeof(int8_t) + // Call site format
985-
CallSiteTableLengthSize + // Call site table length size
986-
CallSiteTableLength + // Call site table length
987-
BF.getLSDAActionTable().size() + // Actions table size
988-
BF.getLSDATypeTable().size() * TTypeEncodingSize; // Types table size
989-
unsigned TTypeBaseOffsetSize = getULEB128Size(TTypeBaseOffset);
990-
unsigned TotalSize = sizeof(int8_t) + // LPStart format
991-
sizeof(int8_t) + // TType format
992-
TTypeBaseOffsetSize + // TType base offset size
993-
TTypeBaseOffset; // TType base offset
994-
unsigned SizeAlign = (4 - TotalSize) & 3;
995-
996-
if (TTypeEncoding != dwarf::DW_EH_PE_omit)
997-
// Account for any extra padding that will be added to the call site table
998-
// length.
999-
Streamer.emitULEB128IntValue(TTypeBaseOffset,
1000-
/*PadTo=*/TTypeBaseOffsetSize + SizeAlign);
967+
MCSymbol *TTBaseLabel = nullptr;
968+
if (TTypeEncoding != dwarf::DW_EH_PE_omit) {
969+
TTBaseLabel = BC.Ctx->createTempSymbol("TTBase");
970+
MCSymbol *TTBaseRefLabel = BC.Ctx->createTempSymbol("TTBaseRef");
971+
Streamer.emitAbsoluteSymbolDiffAsULEB128(TTBaseLabel, TTBaseRefLabel);
972+
Streamer.emitLabel(TTBaseRefLabel);
973+
}
1001974

1002975
// Emit the landing pad call site table. We use signed data4 since we can emit
1003976
// a landing pad in a different part of the split function that could appear
1004977
// earlier in the address space than LPStart.
1005978
Streamer.emitIntValue(dwarf::DW_EH_PE_sdata4, 1);
1006-
Streamer.emitULEB128IntValue(CallSiteTableLength);
1007979

980+
MCSymbol *CSTStartLabel = BC.Ctx->createTempSymbol("CSTStart");
981+
MCSymbol *CSTEndLabel = BC.Ctx->createTempSymbol("CSTEnd");
982+
Streamer.emitAbsoluteSymbolDiffAsULEB128(CSTEndLabel, CSTStartLabel);
983+
984+
Streamer.emitLabel(CSTStartLabel);
1008985
for (const auto &FragmentCallSite : Sites) {
1009986
const BinaryFunction::CallSite &CallSite = FragmentCallSite.second;
1010987
const MCSymbol *BeginLabel = CallSite.Start;
@@ -1020,6 +997,7 @@ void BinaryEmitter::emitLSDA(BinaryFunction &BF, const FunctionFragment &FF) {
1020997
emitLandingPad(CallSite.LP);
1021998
Streamer.emitULEB128IntValue(CallSite.Action);
1022999
}
1000+
Streamer.emitLabel(CSTEndLabel);
10231001

10241002
// Write out action, type, and type index tables at the end.
10251003
//
@@ -1038,6 +1016,8 @@ void BinaryEmitter::emitLSDA(BinaryFunction &BF, const FunctionFragment &FF) {
10381016
assert(TypeTable.size() == BF.getLSDATypeTable().size() &&
10391017
"indirect type table size mismatch");
10401018

1019+
Streamer.emitValueToAlignment(Align(TTypeAlignment));
1020+
10411021
for (int Index = TypeTable.size() - 1; Index >= 0; --Index) {
10421022
const uint64_t TypeAddress = TypeTable[Index];
10431023
switch (TTypeEncoding & 0x70) {
@@ -1063,6 +1043,10 @@ void BinaryEmitter::emitLSDA(BinaryFunction &BF, const FunctionFragment &FF) {
10631043
}
10641044
}
10651045
}
1046+
1047+
if (TTypeEncoding != dwarf::DW_EH_PE_omit)
1048+
Streamer.emitLabel(TTBaseLabel);
1049+
10661050
for (uint8_t const &Byte : BF.getLSDATypeIndexTable())
10671051
Streamer.emitIntValue(Byte, 1);
10681052
}

bolt/lib/Rewrite/RewriteInstance.cpp

Lines changed: 51 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5791,42 +5791,64 @@ void RewriteInstance::writeEHFrameHeader() {
57915791
LLVM_DEBUG(dbgs() << "BOLT: writing a new " << getEHFrameHdrSectionName()
57925792
<< '\n');
57935793

5794-
NextAvailableAddress =
5795-
appendPadding(Out->os(), NextAvailableAddress, EHFrameHdrAlign);
5794+
// Try to overwrite the original .eh_frame_hdr if the size permits.
5795+
uint64_t EHFrameHdrOutputAddress = 0;
5796+
uint64_t EHFrameHdrFileOffset = 0;
5797+
std::vector<char> NewEHFrameHdr;
5798+
BinarySection *OldEHFrameHdrSection = getSection(getEHFrameHdrSectionName());
5799+
if (OldEHFrameHdrSection) {
5800+
NewEHFrameHdr = CFIRdWrt->generateEHFrameHeader(
5801+
RelocatedEHFrame, NewEHFrame, OldEHFrameHdrSection->getAddress());
5802+
if (NewEHFrameHdr.size() <= OldEHFrameHdrSection->getSize()) {
5803+
BC->outs() << "BOLT-INFO: rewriting " << getEHFrameHdrSectionName()
5804+
<< " in-place\n";
5805+
EHFrameHdrOutputAddress = OldEHFrameHdrSection->getAddress();
5806+
EHFrameHdrFileOffset = OldEHFrameHdrSection->getInputFileOffset();
5807+
} else {
5808+
OldEHFrameHdrSection->setOutputName(getOrgSecPrefix() +
5809+
getEHFrameHdrSectionName());
5810+
OldEHFrameHdrSection = nullptr;
5811+
}
5812+
}
57965813

5797-
const uint64_t EHFrameHdrOutputAddress = NextAvailableAddress;
5798-
const uint64_t EHFrameHdrFileOffset =
5799-
getFileOffsetForAddress(NextAvailableAddress);
5814+
// If there was not enough space, allocate more memory for .eh_frame_hdr.
5815+
if (!OldEHFrameHdrSection) {
5816+
NextAvailableAddress =
5817+
appendPadding(Out->os(), NextAvailableAddress, EHFrameHdrAlign);
58005818

5801-
std::vector<char> NewEHFrameHdr = CFIRdWrt->generateEHFrameHeader(
5802-
RelocatedEHFrame, NewEHFrame, EHFrameHdrOutputAddress);
5819+
EHFrameHdrOutputAddress = NextAvailableAddress;
5820+
EHFrameHdrFileOffset = getFileOffsetForAddress(NextAvailableAddress);
5821+
5822+
NewEHFrameHdr = CFIRdWrt->generateEHFrameHeader(
5823+
RelocatedEHFrame, NewEHFrame, EHFrameHdrOutputAddress);
5824+
5825+
NextAvailableAddress += NewEHFrameHdr.size();
5826+
if (!BC->BOLTReserved.empty() &&
5827+
(NextAvailableAddress > BC->BOLTReserved.end())) {
5828+
BC->errs() << "BOLT-ERROR: unable to fit " << getEHFrameHdrSectionName()
5829+
<< " into reserved space\n";
5830+
exit(1);
5831+
}
5832+
5833+
// Create a new entry in the section header table.
5834+
const unsigned Flags = BinarySection::getFlags(/*IsReadOnly=*/true,
5835+
/*IsText=*/false,
5836+
/*IsAllocatable=*/true);
5837+
BinarySection &EHFrameHdrSec = BC->registerOrUpdateSection(
5838+
getNewSecPrefix() + getEHFrameHdrSectionName(), ELF::SHT_PROGBITS,
5839+
Flags, nullptr, NewEHFrameHdr.size(), /*Alignment=*/1);
5840+
EHFrameHdrSec.setOutputFileOffset(EHFrameHdrFileOffset);
5841+
EHFrameHdrSec.setOutputAddress(EHFrameHdrOutputAddress);
5842+
EHFrameHdrSec.setOutputName(getEHFrameHdrSectionName());
5843+
}
58035844

58045845
Out->os().seek(EHFrameHdrFileOffset);
58055846
Out->os().write(NewEHFrameHdr.data(), NewEHFrameHdr.size());
58065847

5807-
const unsigned Flags = BinarySection::getFlags(/*IsReadOnly=*/true,
5808-
/*IsText=*/false,
5809-
/*IsAllocatable=*/true);
5810-
BinarySection *OldEHFrameHdrSection = getSection(getEHFrameHdrSectionName());
5848+
// Pad the contents if overwriting in-place.
58115849
if (OldEHFrameHdrSection)
5812-
OldEHFrameHdrSection->setOutputName(getOrgSecPrefix() +
5813-
getEHFrameHdrSectionName());
5814-
5815-
BinarySection &EHFrameHdrSec = BC->registerOrUpdateSection(
5816-
getNewSecPrefix() + getEHFrameHdrSectionName(), ELF::SHT_PROGBITS, Flags,
5817-
nullptr, NewEHFrameHdr.size(), /*Alignment=*/1);
5818-
EHFrameHdrSec.setOutputFileOffset(EHFrameHdrFileOffset);
5819-
EHFrameHdrSec.setOutputAddress(EHFrameHdrOutputAddress);
5820-
EHFrameHdrSec.setOutputName(getEHFrameHdrSectionName());
5821-
5822-
NextAvailableAddress += EHFrameHdrSec.getOutputSize();
5823-
5824-
if (!BC->BOLTReserved.empty() &&
5825-
(NextAvailableAddress > BC->BOLTReserved.end())) {
5826-
BC->errs() << "BOLT-ERROR: unable to fit " << getEHFrameHdrSectionName()
5827-
<< " into reserved space\n";
5828-
exit(1);
5829-
}
5850+
Out->os().write_zeros(OldEHFrameHdrSection->getSize() -
5851+
NewEHFrameHdr.size());
58305852

58315853
// Merge new .eh_frame with the relocated original so that gdb can locate all
58325854
// FDEs.

bolt/test/eh-frame-hdr.test

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Check that llvm-bolt overwrites .eh_frame_hdr in-place.
2+
3+
REQUIRES: system-linux
4+
5+
RUN: %clang %cflags %p/Inputs/hello.c -o %t -Wl,-q
6+
RUN: llvm-bolt %t -o %t.bolt --use-old-text \
7+
RUN: | FileCheck %s --check-prefix=CHECK-BOLT
8+
RUN: llvm-readelf -WS %t.bolt | FileCheck %s
9+
10+
CHECK-BOLT: rewriting .eh_frame_hdr in-place
11+
12+
CHECK-NOT: .bolt.org.eh_frame_hdr

clang-tools-extra/clang-tidy/bugprone/ExceptionEscapeCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ namespace {
2020

2121
AST_MATCHER_P(FunctionDecl, isEnabled, llvm::StringSet<>,
2222
FunctionsThatShouldNotThrow) {
23-
return FunctionsThatShouldNotThrow.count(Node.getNameAsString()) > 0;
23+
return FunctionsThatShouldNotThrow.contains(Node.getNameAsString());
2424
}
2525

2626
AST_MATCHER(FunctionDecl, isExplicitThrow) {

clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ ExceptionAnalyzer::ExceptionInfo::filterIgnoredExceptions(
418418
if (TD->getDeclName().isIdentifier()) {
419419
if ((IgnoreBadAlloc &&
420420
(TD->getName() == "bad_alloc" && TD->isInStdNamespace())) ||
421-
(IgnoredTypes.count(TD->getName()) > 0))
421+
(IgnoredTypes.contains(TD->getName())))
422422
TypesToDelete.push_back(T);
423423
}
424424
}
@@ -449,7 +449,8 @@ void ExceptionAnalyzer::ExceptionInfo::reevaluateBehaviour() {
449449
ExceptionAnalyzer::ExceptionInfo ExceptionAnalyzer::throwsException(
450450
const FunctionDecl *Func, const ExceptionInfo::Throwables &Caught,
451451
llvm::SmallSet<const FunctionDecl *, 32> &CallStack) {
452-
if (!Func || CallStack.count(Func) || (!CallStack.empty() && !canThrow(Func)))
452+
if (!Func || CallStack.contains(Func) ||
453+
(!CallStack.empty() && !canThrow(Func)))
453454
return ExceptionInfo::createNonThrowing();
454455

455456
if (const Stmt *Body = Func->getBody()) {
@@ -507,7 +508,7 @@ ExceptionAnalyzer::ExceptionInfo ExceptionAnalyzer::throwsException(
507508
for (unsigned I = 0; I < Try->getNumHandlers(); ++I) {
508509
const CXXCatchStmt *Catch = Try->getHandler(I);
509510

510-
// Everything is catched through 'catch(...)'.
511+
// Everything is caught through 'catch(...)'.
511512
if (!Catch->getExceptionDecl()) {
512513
ExceptionInfo Rethrown = throwsException(
513514
Catch->getHandlerBlock(), Uncaught.getExceptionTypes(), CallStack);

clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ class ExceptionAnalyzer {
101101
/// Recalculate the 'Behaviour' for example after filtering.
102102
void reevaluateBehaviour();
103103

104-
/// Keep track if the entity related to this 'ExceptionInfo' can in princple
105-
/// throw, if it's unknown or if it won't throw.
104+
/// Keep track if the entity related to this 'ExceptionInfo' can in
105+
/// principle throw, if it's unknown or if it won't throw.
106106
State Behaviour;
107107

108108
/// Keep track if the entity contains any unknown elements to keep track

0 commit comments

Comments
 (0)