Skip to content

Commit c7a5b03

Browse files
committed
Merge remote-tracking branch 'origin/main' into vplan-induction-resume-values
2 parents e8d78a9 + d5032b9 commit c7a5b03

File tree

1,806 files changed

+48087
-26802
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,806 files changed

+48087
-26802
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/include/bolt/Core/BinarySection.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ class BinarySection {
8787
// been renamed)
8888
uint64_t OutputAddress{0}; // Section address for the rewritten binary.
8989
uint64_t OutputSize{0}; // Section size in the rewritten binary.
90+
// Can exceed OutputContents with padding.
9091
uint64_t OutputFileOffset{0}; // File offset in the rewritten binary file.
9192
StringRef OutputContents; // Rewritten section contents.
9293
const uint64_t SectionNumber; // Order in which the section was created.
@@ -474,6 +475,11 @@ class BinarySection {
474475
/// Use name \p SectionName for the section during the emission.
475476
void emitAsData(MCStreamer &Streamer, const Twine &SectionName) const;
476477

478+
/// Write finalized contents of the section. If OutputSize exceeds the size of
479+
/// the OutputContents, append zero padding to the stream and return the
480+
/// number of byte written which should match the OutputSize.
481+
uint64_t write(raw_ostream &OS) const;
482+
477483
using SymbolResolverFuncTy = llvm::function_ref<uint64_t(const MCSymbol *)>;
478484

479485
/// Flush all pending relocations to patch original contents of sections
@@ -497,6 +503,9 @@ class BinarySection {
497503
IsFinalized = true;
498504
}
499505

506+
/// When writing section contents, add \p PaddingSize zero bytes at the end.
507+
void addPadding(uint64_t PaddingSize) { OutputSize += PaddingSize; }
508+
500509
/// Reorder the contents of this section according to /p Order. If
501510
/// /p Inplace is true, the entire contents of the section is reordered,
502511
/// otherwise the new contents contain only the reordered data.

bolt/lib/Core/BinaryEmitter.cpp

Lines changed: 56 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -416,17 +416,6 @@ void BinaryEmitter::emitFunctionBody(BinaryFunction &BF, FunctionFragment &FF,
416416
BF.duplicateConstantIslands();
417417
}
418418

419-
if (!FF.empty() && FF.front()->isLandingPad()) {
420-
assert(!FF.front()->isEntryPoint() &&
421-
"Landing pad cannot be entry point of function");
422-
// If the first block of the fragment is a landing pad, it's offset from the
423-
// start of the area that the corresponding LSDA describes is zero. In this
424-
// case, the call site entries in that LSDA have 0 as offset to the landing
425-
// pad, which the runtime interprets as "no handler". To prevent this,
426-
// insert some padding.
427-
Streamer.emitBytes(BC.MIB->getTrapFillValue());
428-
}
429-
430419
// Track the first emitted instruction with debug info.
431420
bool FirstInstr = true;
432421
for (BinaryBasicBlock *const BB : FF) {
@@ -906,17 +895,6 @@ void BinaryEmitter::emitLSDA(BinaryFunction &BF, const FunctionFragment &FF) {
906895
if (Sites.empty())
907896
return;
908897

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-
920898
Streamer.switchSection(BC.MOFI->getLSDASection());
921899

922900
const unsigned TTypeEncoding = BF.getLSDATypeEncoding();
@@ -937,74 +915,77 @@ void BinaryEmitter::emitLSDA(BinaryFunction &BF, const FunctionFragment &FF) {
937915
// Emit the LSDA header.
938916

939917
// If LPStart is omitted, then the start of the FDE is used as a base for
940-
// landing pad displacements. Then if a cold fragment starts with
941-
// a landing pad, this means that the first landing pad offset will be 0.
942-
// As a result, the exception handling runtime will ignore this landing pad
943-
// because zero offset denotes the absence of a landing pad.
944-
// For this reason, when the binary has fixed starting address we emit LPStart
945-
// as 0 and output the absolute value of the landing pad in the table.
918+
// landing pad displacements. Then, if a cold fragment starts with a landing
919+
// pad, this means that the first landing pad offset will be 0. However, C++
920+
// runtime treats 0 as if there is no landing pad present, thus we *must* emit
921+
// non-zero offsets for all valid LPs.
946922
//
947-
// If the base address can change, we cannot use absolute addresses for
948-
// landing pads (at least not without runtime relocations). Hence, we fall
949-
// back to emitting landing pads relative to the FDE start.
950-
// As we are emitting label differences, we have to guarantee both labels are
951-
// defined in the same section and hence cannot place the landing pad into a
952-
// cold fragment when the corresponding call site is in the hot fragment.
953-
// Because of this issue and the previously described issue of possible
954-
// zero-offset landing pad we have to place landing pads in the same section
955-
// as the corresponding invokes for shared objects.
923+
// As a solution, for fixed-address binaries we set LPStart to 0, and for
924+
// position-independent binaries we set LP start to FDE start minus one byte
925+
// for FDEs that start with a landing pad.
926+
const bool NeedsLPAdjustment = !FF.empty() && FF.front()->isLandingPad();
956927
std::function<void(const MCSymbol *)> emitLandingPad;
957928
if (BC.HasFixedLoadAddress) {
958929
Streamer.emitIntValue(dwarf::DW_EH_PE_udata4, 1); // LPStart format
959930
Streamer.emitIntValue(0, 4); // LPStart
960931
emitLandingPad = [&](const MCSymbol *LPSymbol) {
961-
if (!LPSymbol)
962-
Streamer.emitIntValue(0, 4);
963-
else
932+
if (LPSymbol)
964933
Streamer.emitSymbolValue(LPSymbol, 4);
934+
else
935+
Streamer.emitIntValue(0, 4);
965936
};
966937
} else {
967-
Streamer.emitIntValue(dwarf::DW_EH_PE_omit, 1); // LPStart format
938+
if (NeedsLPAdjustment) {
939+
// Use relative LPStart format and emit LPStart as [SymbolStart - 1].
940+
Streamer.emitIntValue(dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4, 1);
941+
MCSymbol *DotSymbol = BC.Ctx->createTempSymbol("LPBase");
942+
Streamer.emitLabel(DotSymbol);
943+
944+
const MCExpr *LPStartExpr = MCBinaryExpr::createSub(
945+
MCSymbolRefExpr::create(StartSymbol, *BC.Ctx),
946+
MCSymbolRefExpr::create(DotSymbol, *BC.Ctx), *BC.Ctx);
947+
LPStartExpr = MCBinaryExpr::createSub(
948+
LPStartExpr, MCConstantExpr::create(1, *BC.Ctx), *BC.Ctx);
949+
Streamer.emitValue(LPStartExpr, 4);
950+
} else {
951+
// DW_EH_PE_omit means FDE start (StartSymbol) will be used as LPStart.
952+
Streamer.emitIntValue(dwarf::DW_EH_PE_omit, 1);
953+
}
968954
emitLandingPad = [&](const MCSymbol *LPSymbol) {
969-
if (!LPSymbol)
955+
if (LPSymbol) {
956+
const MCExpr *LPOffsetExpr = MCBinaryExpr::createSub(
957+
MCSymbolRefExpr::create(LPSymbol, *BC.Ctx),
958+
MCSymbolRefExpr::create(StartSymbol, *BC.Ctx), *BC.Ctx);
959+
if (NeedsLPAdjustment)
960+
LPOffsetExpr = MCBinaryExpr::createAdd(
961+
LPOffsetExpr, MCConstantExpr::create(1, *BC.Ctx), *BC.Ctx);
962+
Streamer.emitValue(LPOffsetExpr, 4);
963+
} else {
970964
Streamer.emitIntValue(0, 4);
971-
else
972-
Streamer.emitAbsoluteSymbolDiff(LPSymbol, StartSymbol, 4);
965+
}
973966
};
974967
}
975968

976969
Streamer.emitIntValue(TTypeEncoding, 1); // TType format
977970

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);
971+
MCSymbol *TTBaseLabel = nullptr;
972+
if (TTypeEncoding != dwarf::DW_EH_PE_omit) {
973+
TTBaseLabel = BC.Ctx->createTempSymbol("TTBase");
974+
MCSymbol *TTBaseRefLabel = BC.Ctx->createTempSymbol("TTBaseRef");
975+
Streamer.emitAbsoluteSymbolDiffAsULEB128(TTBaseLabel, TTBaseRefLabel);
976+
Streamer.emitLabel(TTBaseRefLabel);
977+
}
1001978

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

984+
MCSymbol *CSTStartLabel = BC.Ctx->createTempSymbol("CSTStart");
985+
MCSymbol *CSTEndLabel = BC.Ctx->createTempSymbol("CSTEnd");
986+
Streamer.emitAbsoluteSymbolDiffAsULEB128(CSTEndLabel, CSTStartLabel);
987+
988+
Streamer.emitLabel(CSTStartLabel);
1008989
for (const auto &FragmentCallSite : Sites) {
1009990
const BinaryFunction::CallSite &CallSite = FragmentCallSite.second;
1010991
const MCSymbol *BeginLabel = CallSite.Start;
@@ -1020,6 +1001,7 @@ void BinaryEmitter::emitLSDA(BinaryFunction &BF, const FunctionFragment &FF) {
10201001
emitLandingPad(CallSite.LP);
10211002
Streamer.emitULEB128IntValue(CallSite.Action);
10221003
}
1004+
Streamer.emitLabel(CSTEndLabel);
10231005

10241006
// Write out action, type, and type index tables at the end.
10251007
//
@@ -1038,6 +1020,8 @@ void BinaryEmitter::emitLSDA(BinaryFunction &BF, const FunctionFragment &FF) {
10381020
assert(TypeTable.size() == BF.getLSDATypeTable().size() &&
10391021
"indirect type table size mismatch");
10401022

1023+
Streamer.emitValueToAlignment(Align(TTypeAlignment));
1024+
10411025
for (int Index = TypeTable.size() - 1; Index >= 0; --Index) {
10421026
const uint64_t TypeAddress = TypeTable[Index];
10431027
switch (TTypeEncoding & 0x70) {
@@ -1063,6 +1047,10 @@ void BinaryEmitter::emitLSDA(BinaryFunction &BF, const FunctionFragment &FF) {
10631047
}
10641048
}
10651049
}
1050+
1051+
if (TTypeEncoding != dwarf::DW_EH_PE_omit)
1052+
Streamer.emitLabel(TTBaseLabel);
1053+
10661054
for (uint8_t const &Byte : BF.getLSDATypeIndexTable())
10671055
Streamer.emitIntValue(Byte, 1);
10681056
}

bolt/lib/Core/BinarySection.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,15 @@ void BinarySection::emitAsData(MCStreamer &Streamer,
142142
Streamer.emitLabel(BC.Ctx->getOrCreateSymbol("__hot_data_end"));
143143
}
144144

145+
uint64_t BinarySection::write(raw_ostream &OS) const {
146+
const uint64_t NumValidContentBytes =
147+
std::min<uint64_t>(getOutputContents().size(), getOutputSize());
148+
OS.write(getOutputContents().data(), NumValidContentBytes);
149+
if (getOutputSize() > NumValidContentBytes)
150+
OS.write_zeros(getOutputSize() - NumValidContentBytes);
151+
return getOutputSize();
152+
}
153+
145154
void BinarySection::flushPendingRelocations(raw_pwrite_stream &OS,
146155
SymbolResolverFuncTy Resolver) {
147156
if (PendingRelocations.empty() && Patches.empty())

0 commit comments

Comments
 (0)