Skip to content

Commit 69a7aad

Browse files
Merge branch 'main' into aix_getHostInfo2
2 parents a47e464 + e3ee6bb commit 69a7aad

File tree

2,717 files changed

+69862
-43890
lines changed

Some content is hidden

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

2,717 files changed

+69862
-43890
lines changed

.ci/metrics/metrics.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,16 @@
2121
# Lists the Github workflows we want to track. Maps the Github job name to
2222
# the metric name prefix in grafana.
2323
# This metric name is also used as a key in the job->name map.
24-
GITHUB_WORKFLOW_TO_TRACK = {"LLVM Premerge Checks": "github_llvm_premerge_checks"}
24+
GITHUB_WORKFLOW_TO_TRACK = {"CI Checks": "github_llvm_premerge_checks"}
2525

2626
# Lists the Github jobs to track for a given workflow. The key is the stable
2727
# name (metric name) of the workflow (see GITHUB_WORKFLOW_TO_TRACK).
2828
# Each value is a map to link the github job name to the corresponding metric
2929
# name.
3030
GITHUB_JOB_TO_TRACK = {
3131
"github_llvm_premerge_checks": {
32-
"Linux Premerge Checks (Test Only - Please Ignore Results)": "premerge_linux",
33-
"Windows Premerge Checks (Test Only - Please Ignore Results)": "premerge_windows",
32+
"Build and Test Linux (Test Only - Please Ignore Results)": "premerge_linux",
33+
"Build and Test Windows (Test Only - Please Ignore Results)": "premerge_windows",
3434
}
3535
}
3636

.github/workflows/libc-fullbuild-tests.yml

Lines changed: 42 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,23 @@ jobs:
1919
include:
2020
- os: ubuntu-24.04
2121
ccache-variant: sccache
22-
c_compiler: clang-20
23-
cpp_compiler: clang++-20
22+
c_compiler: clang-21
23+
cpp_compiler: clang++-21
24+
target: x86_64-unknown-linux-llvm
25+
include_scudo: ON
2426
# TODO: remove ccache logic when https://github.com/hendrikmuhs/ccache-action/issues/279 is resolved.
2527
- os: ubuntu-24.04-arm
2628
ccache-variant: ccache
27-
c_compiler: clang-20
28-
cpp_compiler: clang++-20
29+
c_compiler: clang-21
30+
cpp_compiler: clang++-21
31+
target: aarch64-unknown-linux-llvm
32+
include_scudo: ON
33+
- os: ubuntu-24.04
34+
ccache-variant: ccache
35+
c_compiler: clang-21
36+
cpp_compiler: clang++-21
37+
target: x86_64-unknown-uefi-llvm
38+
include_scudo: OFF
2939
# TODO: add back gcc build when it is fixed
3040
# - c_compiler: gcc
3141
# cpp_compiler: g++
@@ -53,7 +63,7 @@ jobs:
5363
run: |
5464
wget https://apt.llvm.org/llvm.sh
5565
chmod +x llvm.sh
56-
sudo ./llvm.sh 20
66+
sudo ./llvm.sh 21
5767
sudo apt-get update
5868
sudo apt-get install -y libmpfr-dev libgmp-dev libmpc-dev ninja-build linux-libc-dev
5969
sudo ln -sf /usr/include/$(uname -p)-linux-gnu/asm /usr/include/asm
@@ -68,22 +78,31 @@ jobs:
6878
# Configure libc fullbuild with scudo.
6979
# Use MinSizeRel to reduce the size of the build.
7080
- name: Configure CMake
71-
run: >
72-
cmake -B ${{ steps.strings.outputs.build-output-dir }}
73-
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
74-
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
75-
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
76-
-DCMAKE_C_COMPILER_LAUNCHER=${{ matrix.ccache-variant }}
77-
-DCMAKE_CXX_COMPILER_LAUNCHER=${{ matrix.ccache-variant }}
78-
-DCMAKE_INSTALL_PREFIX=${{ steps.strings.outputs.build-install-dir }}
79-
-DLLVM_ENABLE_RUNTIMES="libc;compiler-rt"
80-
-DLLVM_LIBC_FULL_BUILD=ON
81-
-DLLVM_LIBC_INCLUDE_SCUDO=ON
82-
-DCOMPILER_RT_BUILD_SCUDO_STANDALONE_WITH_LLVM_LIBC=ON
83-
-DCOMPILER_RT_BUILD_GWP_ASAN=OFF
84-
-DCOMPILER_RT_SCUDO_STANDALONE_BUILD_SHARED=OFF
85-
-G Ninja
86-
-S ${{ github.workspace }}/runtimes
81+
run: |
82+
export RUNTIMES="libc"
83+
84+
if [[ ${{ matrix.include_scudo}} == "ON" ]]; then
85+
export RUNTIMES="$RUNTIMES;compiler-rt"
86+
export CMAKE_FLAGS="
87+
-DLLVM_LIBC_INCLUDE_SCUDO=ON
88+
-DCOMPILER_RT_BUILD_SCUDO_STANDALONE_WITH_LLVM_LIBC=ON
89+
-DCOMPILER_RT_BUILD_GWP_ASAN=OFF
90+
-DCOMPILER_RT_SCUDO_STANDALONE_BUILD_SHARED=OFF"
91+
fi
92+
93+
cmake -B ${{ steps.strings.outputs.build-output-dir }} \
94+
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} \
95+
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }} \
96+
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
97+
-DCMAKE_C_COMPILER_LAUNCHER=${{ matrix.ccache-variant }} \
98+
-DCMAKE_CXX_COMPILER_LAUNCHER=${{ matrix.ccache-variant }} \
99+
-DCMAKE_INSTALL_PREFIX=${{ steps.strings.outputs.build-install-dir }} \
100+
-DLLVM_RUNTIMES_TARGET=${{ matrix.target }} \
101+
-DLLVM_ENABLE_RUNTIMES="$RUNTIMES" \
102+
-DLLVM_LIBC_FULL_BUILD=ON \
103+
-G Ninja \
104+
-S ${{ github.workspace }}/runtimes \
105+
$CMAKE_FLAGS
87106
88107
- name: Build
89108
run: >
@@ -93,6 +112,8 @@ jobs:
93112
--target install
94113
95114
- name: Test
115+
# Skip UEFI tests until we have testing set up.
116+
if: ${{ ! endsWith(matrix.target, '-uefi-llvm') }}
96117
run: >
97118
cmake
98119
--build ${{ steps.strings.outputs.build-output-dir }}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
stage1:
3838
if: github.repository_owner == 'llvm'
3939
runs-on: libcxx-self-hosted-linux
40-
container: ghcr.io/llvm/libcxx-linux-builder:b6bb9dc5abd7c6452c13a53fa8949cb259db459b
40+
container: ghcr.io/llvm/libcxx-linux-builder:2b57ebb50b6d418e70382e655feaa619b558e254
4141
continue-on-error: false
4242
strategy:
4343
fail-fast: false
@@ -75,7 +75,7 @@ jobs:
7575
stage2:
7676
if: github.repository_owner == 'llvm'
7777
runs-on: libcxx-self-hosted-linux
78-
container: ghcr.io/llvm/libcxx-linux-builder:b6bb9dc5abd7c6452c13a53fa8949cb259db459b
78+
container: ghcr.io/llvm/libcxx-linux-builder:2b57ebb50b6d418e70382e655feaa619b558e254
7979
needs: [ stage1 ]
8080
continue-on-error: false
8181
strategy:
@@ -163,7 +163,7 @@ jobs:
163163
- config: 'generic-msan'
164164
machine: libcxx-self-hosted-linux
165165
runs-on: ${{ matrix.machine }}
166-
container: ghcr.io/llvm/libcxx-linux-builder:b6bb9dc5abd7c6452c13a53fa8949cb259db459b
166+
container: ghcr.io/llvm/libcxx-linux-builder:2b57ebb50b6d418e70382e655feaa619b558e254
167167
steps:
168168
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
169169
- name: ${{ matrix.config }}

.github/workflows/premerge.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: LLVM Premerge Checks
1+
name: CI Checks
22

33
permissions:
44
contents: read
@@ -25,7 +25,7 @@ concurrency:
2525

2626
jobs:
2727
premerge-checks-linux:
28-
name: Linux Premerge Checks (Test Only - Please Ignore Results)
28+
name: Build and Test Linux (Test Only - Please Ignore Results)
2929
if: >-
3030
github.repository_owner == 'llvm' &&
3131
(github.event_name != 'pull_request' || github.event.action != 'closed')
@@ -74,7 +74,7 @@ jobs:
7474
include-hidden-files: 'true'
7575

7676
premerge-checks-windows:
77-
name: Windows Premerge Checks (Test Only - Please Ignore Results)
77+
name: Build and Test Windows (Test Only - Please Ignore Results)
7878
if: >-
7979
github.repository_owner == 'llvm' &&
8080
(github.event_name != 'pull_request' || github.event.action != 'closed')

bolt/docs/BinaryAnalysis.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -180,12 +180,6 @@ The following are current known cases of false negatives:
180180
[prototype branch](
181181
https://github.com/llvm/llvm-project/compare/main...kbeyls:llvm-project:bolt-gadget-scanner-prototype).
182182

183-
BOLT cannot currently handle functions with `cfi_negate_ra_state` correctly,
184-
i.e. any binaries built with `-mbranch-protection=pac-ret`. The scanner is meant
185-
to be used on specifically such binaries, so this is a major limitation! Work is
186-
going on in PR [#120064](https://github.com/llvm/llvm-project/pull/120064) to
187-
fix this.
188-
189183
## How to add your own binary analysis
190184

191185
_TODO: this section needs to be written. Ideally, we should have a simple

bolt/include/bolt/Profile/DataAggregator.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,10 +197,6 @@ class DataAggregator : public DataReader {
197197

198198
BoltAddressTranslation *BAT{nullptr};
199199

200-
/// Whether pre-aggregated profile needs to convert branch profile into call
201-
/// to continuation fallthrough profile.
202-
bool NeedsConvertRetProfileToCallCont{false};
203-
204200
/// Update function execution profile with a recorded trace.
205201
/// A trace is region of code executed between two LBR entries supplied in
206202
/// execution order.

bolt/lib/Core/BinaryFunction.cpp

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ extern cl::opt<bool> StrictMode;
6565
extern cl::opt<bool> UpdateDebugSections;
6666
extern cl::opt<unsigned> Verbosity;
6767

68+
extern bool BinaryAnalysisMode;
69+
extern bool HeatmapMode;
6870
extern bool processAllFunctions();
6971

7072
static cl::opt<bool> CheckEncoding(
@@ -2760,13 +2762,19 @@ struct CFISnapshot {
27602762
}
27612763
case MCCFIInstruction::OpAdjustCfaOffset:
27622764
case MCCFIInstruction::OpWindowSave:
2763-
case MCCFIInstruction::OpNegateRAState:
27642765
case MCCFIInstruction::OpNegateRAStateWithPC:
27652766
case MCCFIInstruction::OpLLVMDefAspaceCfa:
27662767
case MCCFIInstruction::OpLabel:
27672768
case MCCFIInstruction::OpValOffset:
27682769
llvm_unreachable("unsupported CFI opcode");
27692770
break;
2771+
case MCCFIInstruction::OpNegateRAState:
2772+
if (!(opts::BinaryAnalysisMode || opts::HeatmapMode)) {
2773+
llvm_unreachable("BOLT-ERROR: binaries using pac-ret hardening (e.g. "
2774+
"as produced by '-mbranch-protection=pac-ret') are "
2775+
"currently not supported by BOLT.");
2776+
}
2777+
break;
27702778
case MCCFIInstruction::OpRememberState:
27712779
case MCCFIInstruction::OpRestoreState:
27722780
case MCCFIInstruction::OpGnuArgsSize:
@@ -2900,13 +2908,19 @@ struct CFISnapshotDiff : public CFISnapshot {
29002908
return CFAReg == Instr.getRegister() && CFAOffset == Instr.getOffset();
29012909
case MCCFIInstruction::OpAdjustCfaOffset:
29022910
case MCCFIInstruction::OpWindowSave:
2903-
case MCCFIInstruction::OpNegateRAState:
29042911
case MCCFIInstruction::OpNegateRAStateWithPC:
29052912
case MCCFIInstruction::OpLLVMDefAspaceCfa:
29062913
case MCCFIInstruction::OpLabel:
29072914
case MCCFIInstruction::OpValOffset:
29082915
llvm_unreachable("unsupported CFI opcode");
29092916
return false;
2917+
case MCCFIInstruction::OpNegateRAState:
2918+
if (!(opts::BinaryAnalysisMode || opts::HeatmapMode)) {
2919+
llvm_unreachable("BOLT-ERROR: binaries using pac-ret hardening (e.g. "
2920+
"as produced by '-mbranch-protection=pac-ret') are "
2921+
"currently not supported by BOLT.");
2922+
}
2923+
break;
29102924
case MCCFIInstruction::OpRememberState:
29112925
case MCCFIInstruction::OpRestoreState:
29122926
case MCCFIInstruction::OpGnuArgsSize:
@@ -3051,13 +3065,19 @@ BinaryFunction::unwindCFIState(int32_t FromState, int32_t ToState,
30513065
break;
30523066
case MCCFIInstruction::OpAdjustCfaOffset:
30533067
case MCCFIInstruction::OpWindowSave:
3054-
case MCCFIInstruction::OpNegateRAState:
30553068
case MCCFIInstruction::OpNegateRAStateWithPC:
30563069
case MCCFIInstruction::OpLLVMDefAspaceCfa:
30573070
case MCCFIInstruction::OpLabel:
30583071
case MCCFIInstruction::OpValOffset:
30593072
llvm_unreachable("unsupported CFI opcode");
30603073
break;
3074+
case MCCFIInstruction::OpNegateRAState:
3075+
if (!(opts::BinaryAnalysisMode || opts::HeatmapMode)) {
3076+
llvm_unreachable("BOLT-ERROR: binaries using pac-ret hardening (e.g. "
3077+
"as produced by '-mbranch-protection=pac-ret') are "
3078+
"currently not supported by BOLT.");
3079+
}
3080+
break;
30613081
case MCCFIInstruction::OpGnuArgsSize:
30623082
// do not affect CFI state
30633083
break;

bolt/lib/Passes/PatchEntries.cpp

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -98,21 +98,10 @@ Error PatchEntries::runOnFunctions(BinaryContext &BC) {
9898
});
9999

100100
if (!Success) {
101-
// We can't change output layout for AArch64 due to LongJmp pass
102-
if (BC.isAArch64()) {
103-
if (opts::ForcePatch) {
104-
BC.errs() << "BOLT-ERROR: unable to patch entries in " << Function
105-
<< "\n";
106-
return createFatalBOLTError("");
107-
}
108-
109-
continue;
110-
}
111-
112101
// If the original function entries cannot be patched, then we cannot
113102
// safely emit new function body.
114103
BC.errs() << "BOLT-WARNING: failed to patch entries in " << Function
115-
<< ". The function will not be optimized.\n";
104+
<< ". The function will not be optimized\n";
116105
Function.setIgnored();
117106
continue;
118107
}

bolt/lib/Profile/DataAggregator.cpp

Lines changed: 7 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -720,23 +720,6 @@ bool DataAggregator::doBranch(uint64_t From, uint64_t To, uint64_t Count,
720720
: isReturn(Func.disassembleInstructionAtOffset(Offset));
721721
};
722722

723-
// Returns whether \p Offset in \p Func may be a call continuation excluding
724-
// entry points and landing pads.
725-
auto checkCallCont = [&](const BinaryFunction &Func, const uint64_t Offset) {
726-
// No call continuation at a function start.
727-
if (!Offset)
728-
return false;
729-
730-
// FIXME: support BAT case where the function might be in empty state
731-
// (split fragments declared non-simple).
732-
if (!Func.hasCFG())
733-
return false;
734-
735-
// The offset should not be an entry point or a landing pad.
736-
const BinaryBasicBlock *ContBB = Func.getBasicBlockAtOffset(Offset);
737-
return ContBB && !ContBB->isEntryPoint() && !ContBB->isLandingPad();
738-
};
739-
740723
// Mutates \p Addr to an offset into the containing function, performing BAT
741724
// offset translation and parent lookup.
742725
//
@@ -749,8 +732,7 @@ bool DataAggregator::doBranch(uint64_t From, uint64_t To, uint64_t Count,
749732

750733
Addr -= Func->getAddress();
751734

752-
bool IsRetOrCallCont =
753-
IsFrom ? checkReturn(*Func, Addr) : checkCallCont(*Func, Addr);
735+
bool IsRet = IsFrom && checkReturn(*Func, Addr);
754736

755737
if (BAT)
756738
Addr = BAT->translate(Func->getAddress(), Addr, IsFrom);
@@ -761,24 +743,16 @@ bool DataAggregator::doBranch(uint64_t From, uint64_t To, uint64_t Count,
761743
NumColdSamples += Count;
762744

763745
if (!ParentFunc)
764-
return std::pair{Func, IsRetOrCallCont};
746+
return std::pair{Func, IsRet};
765747

766-
return std::pair{ParentFunc, IsRetOrCallCont};
748+
return std::pair{ParentFunc, IsRet};
767749
};
768750

769-
uint64_t ToOrig = To;
770751
auto [FromFunc, IsReturn] = handleAddress(From, /*IsFrom*/ true);
771-
auto [ToFunc, IsCallCont] = handleAddress(To, /*IsFrom*/ false);
752+
auto [ToFunc, _] = handleAddress(To, /*IsFrom*/ false);
772753
if (!FromFunc && !ToFunc)
773754
return false;
774755

775-
// Record call to continuation trace.
776-
if (NeedsConvertRetProfileToCallCont && FromFunc != ToFunc &&
777-
(IsReturn || IsCallCont)) {
778-
LBREntry First{ToOrig - 1, ToOrig - 1, false};
779-
LBREntry Second{ToOrig, ToOrig, false};
780-
return doTrace(First, Second, Count);
781-
}
782756
// Ignore returns.
783757
if (IsReturn)
784758
return true;
@@ -1235,21 +1209,14 @@ std::error_code DataAggregator::parseAggregatedLBREntry() {
12351209
ErrorOr<StringRef> TypeOrErr = parseString(FieldSeparator);
12361210
if (std::error_code EC = TypeOrErr.getError())
12371211
return EC;
1238-
// Pre-aggregated profile with branches and fallthroughs needs to convert
1239-
// return profile into call to continuation fall-through.
1240-
auto Type = AggregatedLBREntry::BRANCH;
1241-
if (TypeOrErr.get() == "B") {
1242-
NeedsConvertRetProfileToCallCont = true;
1212+
auto Type = AggregatedLBREntry::TRACE;
1213+
if (LLVM_LIKELY(TypeOrErr.get() == "T")) {
1214+
} else if (TypeOrErr.get() == "B") {
12431215
Type = AggregatedLBREntry::BRANCH;
12441216
} else if (TypeOrErr.get() == "F") {
1245-
NeedsConvertRetProfileToCallCont = true;
12461217
Type = AggregatedLBREntry::FT;
12471218
} else if (TypeOrErr.get() == "f") {
1248-
NeedsConvertRetProfileToCallCont = true;
12491219
Type = AggregatedLBREntry::FT_EXTERNAL_ORIGIN;
1250-
} else if (TypeOrErr.get() == "T") {
1251-
// Trace is expanded into B and [Ff]
1252-
Type = AggregatedLBREntry::TRACE;
12531220
} else {
12541221
reportError("expected T, B, F or f");
12551222
return make_error_code(llvm::errc::io_error);

bolt/lib/Rewrite/BinaryPassManager.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,10 @@ Error BinaryFunctionPassManager::runAllPasses(BinaryContext &BC) {
497497
// memory profiling data.
498498
Manager.registerPass(std::make_unique<ReorderData>());
499499

500+
// Patch original function entries
501+
if (BC.HasRelocations)
502+
Manager.registerPass(std::make_unique<PatchEntries>());
503+
500504
if (BC.isAArch64()) {
501505
Manager.registerPass(
502506
std::make_unique<ADRRelaxationPass>(PrintAdrRelaxation));
@@ -524,10 +528,6 @@ Error BinaryFunctionPassManager::runAllPasses(BinaryContext &BC) {
524528
// Assign each function an output section.
525529
Manager.registerPass(std::make_unique<AssignSections>());
526530

527-
// Patch original function entries
528-
if (BC.HasRelocations)
529-
Manager.registerPass(std::make_unique<PatchEntries>());
530-
531531
// This pass turns tail calls into jumps which makes them invisible to
532532
// function reordering. It's unsafe to use any CFG or instruction analysis
533533
// after this point.

0 commit comments

Comments
 (0)