Skip to content

Commit 1a350e4

Browse files
authored
Merge branch 'llvm:main' into main
2 parents b8ec0fb + 8287831 commit 1a350e4

File tree

6,610 files changed

+513667
-501033
lines changed

Some content is hidden

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

6,610 files changed

+513667
-501033
lines changed

.github/new-prs-labeler.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ mlgo:
668668
- llvm/lib/CodeGen/ML*
669669
- llvm/unittests/CodeGen/ML*
670670
- llvm/test/CodeGen/MLRegAlloc/**
671-
- llvm/utils/mlgo-utils/*
671+
- llvm/utils/mlgo-utils/**
672672

673673
tools:llvm-exegesis:
674674
- llvm/tools/llvm-exegesis/**

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

+43
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,42 @@ jobs:
191191
**/CMakeError.log
192192
**/CMakeOutput.log
193193
**/crash_diagnostics/*
194+
195+
macos:
196+
runs-on: macos-14
197+
needs: [ stage1 ]
198+
strategy:
199+
fail-fast: true
200+
matrix:
201+
config: [
202+
generic-cxx03,
203+
generic-cxx23,
204+
generic-modules,
205+
apple-configuration
206+
]
207+
steps:
208+
- uses: actions/checkout@v4
209+
- uses: maxim-lobanov/setup-xcode@v1
210+
with:
211+
xcode-version: 'latest'
212+
- uses: seanmiddleditch/gha-setup-ninja@master
213+
- name: Build and test
214+
run: |
215+
python3 -m venv .venv
216+
source .venv/bin/activate
217+
python -m pip install psutil
218+
bash libcxx/utils/ci/run-buildbot ${{ matrix.config }}
219+
- uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0
220+
if: always() # Upload artifacts even if the build or test suite fails
221+
with:
222+
name: macos-${{ matrix.config }}-results
223+
path: |
224+
**/test-results.xml
225+
**/*.abilist
226+
**/CMakeError.log
227+
**/CMakeOutput.log
228+
**/crash_diagnostics/*
229+
194230
windows:
195231
runs-on: windows-2022
196232
needs: [ stage1 ]
@@ -206,6 +242,7 @@ jobs:
206242
- { config: mingw-dll, mingw: true }
207243
- { config: mingw-static, mingw: true }
208244
- { config: mingw-dll-i686, mingw: true }
245+
- { config: mingw-incomplete-sysroot, mingw: true }
209246
steps:
210247
- uses: actions/checkout@v4
211248
- name: Install dependencies
@@ -224,6 +261,12 @@ jobs:
224261
del llvm-mingw*.zip
225262
mv llvm-mingw* c:\llvm-mingw
226263
echo "c:\llvm-mingw\bin" | Out-File -FilePath $Env:GITHUB_PATH -Encoding utf8 -Append
264+
- name: Simulate a from-scratch build of llvm-mingw
265+
if: ${{ matrix.config == 'mingw-incomplete-sysroot' }}
266+
run: |
267+
rm -r c:\llvm-mingw\include\c++
268+
rm -r c:\llvm-mingw\*-w64-mingw32\lib\libc++*
269+
rm -r c:\llvm-mingw\*-w64-mingw32\lib\libunwind*
227270
- name: Add Git Bash to the path
228271
run: |
229272
echo "c:\Program Files\Git\usr\bin" | Out-File -FilePath $Env:GITHUB_PATH -Encoding utf8 -Append

.github/workflows/pr-code-format.yml

+4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ on:
1212
jobs:
1313
code_formatter:
1414
runs-on: ubuntu-latest
15+
timeout-minutes: 30
16+
concurrency:
17+
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
18+
cancel-in-progress: true
1519
if: github.repository == 'llvm/llvm-project'
1620
steps:
1721
- name: Fetch LLVM sources

.github/workflows/release-asset-audit.py

+16-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
11
import github
22
import sys
33

4+
_SPECIAL_CASE_BINARIES = {
5+
"keith": {"clang+llvm-18.1.8-arm64-apple-macos11.tar.xz"},
6+
}
7+
8+
9+
def _is_valid(uploader_name, valid_uploaders, asset_name):
10+
if uploader_name in valid_uploaders:
11+
return True
12+
13+
if uploader_name in _SPECIAL_CASE_BINARIES:
14+
return asset_name in _SPECIAL_CASE_BINARIES[uploader_name]
15+
16+
return False
17+
18+
419
def main():
520
token = sys.argv[1]
621

@@ -41,7 +56,7 @@ def main():
4156
print(
4257
f"{asset.name} : {asset.uploader.login} [{created_at} {updated_at}] ( {asset.download_count} )"
4358
)
44-
if asset.uploader.login not in uploaders:
59+
if not _is_valid(asset.uploader.login, uploaders, asset.name):
4560
with open('comment', 'w') as file:
4661
file.write(f'@{asset.uploader.login} is not a valid uploader.')
4762
sys.exit(1)

.github/workflows/release-binaries-save-stage/action.yml

+6
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ inputs:
1010
required: true
1111
type: 'string'
1212

13+
permissions:
14+
contents: read
15+
1316
runs:
1417
using: "composite"
1518
steps:
@@ -18,6 +21,9 @@ runs:
1821
- name: Package Build and Source Directories
1922
shell: bash
2023
run: |
24+
# Remove .git/config to avoid leaking GITHUB_TOKEN stored there.
25+
# See https://unit42.paloaltonetworks.com/github-repo-artifacts-leak-tokens/
26+
rm -Rf .git/config
2127
# Windows does not support symlinks, so we need to dereference them.
2228
tar --exclude build/ ${{ (runner.os == 'Windows' && '-h') || '' }} -c . | zstd -T0 -c > ../llvm-project.tar.zst
2329
mv ../llvm-project.tar.zst .

.github/workflows/release-binaries.yml

-8
Original file line numberDiff line numberDiff line change
@@ -135,16 +135,8 @@ jobs:
135135
target_cmake_flags="$target_cmake_flags -DBOOTSTRAP_DARWIN_osx_ARCHS=$arches -DBOOTSTRAP_DARWIN_osx_BUILTIN_ARCHS=$arches"
136136
fi
137137
138-
# x86 macOS and x86 Windows have trouble building flang, so disable it.
139-
# Windows: https://github.com/llvm/llvm-project/issues/100202
140-
# macOS: 'rebase opcodes terminated early at offset 1 of 80016' when building __fortran_builtins.mod
141138
build_flang="true"
142139
143-
if [ "$target" = "Windows-X64" ]; then
144-
target_cmake_flags="$target_cmake_flags -DLLVM_RELEASE_ENABLE_PROJECTS=\"clang;lld;lldb;clang-tools-extra;bolt;polly;mlir\""
145-
build_flang="false"
146-
fi
147-
148140
if [ "${{ runner.os }}" = "Windows" ]; then
149141
# The build times out on Windows, so we need to disable LTO.
150142
target_cmake_flags="$target_cmake_flags -DLLVM_RELEASE_ENABLE_LTO=OFF"

.github/workflows/release-doxygen.yml

+6-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ on:
2525
description: 'Upload documentation'
2626
required: false
2727
type: boolean
28+
secrets:
29+
RELEASE_TASKS_USER_TOKEN:
30+
description: "Secret used to check user permissions."
31+
required: false
2832

2933
jobs:
3034
release-doxygen:
@@ -63,5 +67,6 @@ jobs:
6367
if: env.upload
6468
env:
6569
GITHUB_TOKEN: ${{ github.token }}
70+
USER_TOKEN: ${{ secrets.RELEASE_TASKS_USER_TOKEN }}
6671
run: |
67-
./llvm/utils/release/github-upload-release.py --token "$GITHUB_TOKEN" --release "${{ inputs.release-version }}" --user "${{ github.actor }}" upload --files ./*doxygen*.tar.xz
72+
./llvm/utils/release/github-upload-release.py --token "$GITHUB_TOKEN" --release "${{ inputs.release-version }}" --user "${{ github.actor }}" --user-token "$USER_TOKEN" upload --files ./*doxygen*.tar.xz

.github/workflows/release-lit.yml

+6-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ on:
1717
description: 'Release Version'
1818
required: true
1919
type: string
20+
secrets:
21+
RELEASE_TASKS_USER_TOKEN:
22+
description: "Secret used to check user permissions."
23+
required: false
2024

2125
jobs:
2226
release-lit:
@@ -36,8 +40,9 @@ jobs:
3640
- name: Check Permissions
3741
env:
3842
GITHUB_TOKEN: ${{ github.token }}
43+
USER_TOKEN: ${{ secrets.RELEASE_TASKS_USER_TOKEN }}
3944
run: |
40-
./llvm/utils/release/./github-upload-release.py --token "$GITHUB_TOKEN" --user ${{ github.actor }} check-permissions
45+
./llvm/utils/release/./github-upload-release.py --token "$GITHUB_TOKEN" --user ${{ github.actor }} --user-token "$USER_TOKEN" check-permissions
4146
4247
- name: Setup Cpp
4348
uses: aminya/setup-cpp@v1

.github/workflows/release-sources.yml

+4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ on:
1616
description: Release Version
1717
required: true
1818
type: string
19+
secrets:
20+
RELEASE_TASKS_USER_TOKEN:
21+
description: "Secret used to check user permissions."
22+
required: false
1923
# Run on pull_requests for testing purposes.
2024
pull_request:
2125
paths:

.github/workflows/release-tasks.yml

+12
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,19 @@ jobs:
6666
with:
6767
release-version: ${{ needs.validate-tag.outputs.release-version }}
6868
upload: true
69+
# Called workflows don't have access to secrets by default, so we need to explicitly pass secrets that we use.
70+
secrets:
71+
RELEASE_TASKS_USER_TOKEN: ${{ secrets.RELEASE_TASKS_USER_TOKEN }}
6972

7073
release-lit:
7174
name: Release Lit
7275
needs: validate-tag
7376
uses: ./.github/workflows/release-lit.yml
7477
with:
7578
release-version: ${{ needs.validate-tag.outputs.release-version }}
79+
# Called workflows don't have access to secrets by default, so we need to explicitly pass secrets that we use.
80+
secrets:
81+
RELEASE_TASKS_USER_TOKEN: ${{ secrets.RELEASE_TASKS_USER_TOKEN }}
7682

7783
release-binaries:
7884
name: Build Release Binaries
@@ -97,6 +103,9 @@ jobs:
97103
release-version: ${{ needs.validate-tag.outputs.release-version }}
98104
upload: true
99105
runs-on: ${{ matrix.runs-on }}
106+
# Called workflows don't have access to secrets by default, so we need to explicitly pass secrets that we use.
107+
secrets:
108+
RELEASE_TASKS_USER_TOKEN: ${{ secrets.RELEASE_TASKS_USER_TOKEN }}
100109

101110
release-sources:
102111
name: Package Release Sources
@@ -109,3 +118,6 @@ jobs:
109118
uses: ./.github/workflows/release-sources.yml
110119
with:
111120
release-version: ${{ needs.validate-tag.outputs.release-version }}
121+
# Called workflows don't have access to secrets by default, so we need to explicitly pass secrets that we use.
122+
secrets:
123+
RELEASE_TASKS_USER_TOKEN: ${{ secrets.RELEASE_TASKS_USER_TOKEN }}

bolt/include/bolt/Core/BinaryFunction.h

+2
Original file line numberDiff line numberDiff line change
@@ -1692,6 +1692,8 @@ class BinaryFunction {
16921692

16931693
void setPseudo(bool Pseudo) { IsPseudo = Pseudo; }
16941694

1695+
void setPreserveNops(bool Value) { PreserveNops = Value; }
1696+
16951697
BinaryFunction &setUsesGnuArgsSize(bool Uses = true) {
16961698
UsesGnuArgsSize = Uses;
16971699
return *this;

bolt/include/bolt/Utils/Utils.h

+5
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ std::string getEscapedName(const StringRef &Name);
4141
/// Return the unescaped name
4242
std::string getUnescapedName(const StringRef &Name);
4343

44+
/// Return a common part for a given \p Name wrt a given \p Suffixes list.
45+
/// Preserve the suffix if \p KeepSuffix is set, only dropping characters
46+
/// following it, otherwise drop the suffix as well.
47+
std::optional<StringRef> getCommonName(const StringRef Name, bool KeepSuffix,
48+
ArrayRef<StringRef> Suffixes);
4449
/// LTO-generated function names take a form:
4550
///
4651
/// <function_name>.lto_priv.<decimal_number>/...

bolt/lib/Core/BinaryFunction.cpp

+4-16
Original file line numberDiff line numberDiff line change
@@ -1339,22 +1339,10 @@ Error BinaryFunction::disassemble() {
13391339
BC.getBinaryFunctionContainingAddress(TargetAddress))
13401340
TargetFunc->setIgnored();
13411341

1342-
if (IsCall && containsAddress(TargetAddress)) {
1343-
if (TargetAddress == getAddress()) {
1344-
// Recursive call.
1345-
TargetSymbol = getSymbol();
1346-
} else {
1347-
if (BC.isX86()) {
1348-
// Dangerous old-style x86 PIC code. We may need to freeze this
1349-
// function, so preserve the function as is for now.
1350-
PreserveNops = true;
1351-
} else {
1352-
BC.errs() << "BOLT-WARNING: internal call detected at 0x"
1353-
<< Twine::utohexstr(AbsoluteInstrAddr)
1354-
<< " in function " << *this << ". Skipping.\n";
1355-
IsSimple = false;
1356-
}
1357-
}
1342+
if (IsCall && TargetAddress == getAddress()) {
1343+
// A recursive call. Calls to internal blocks are handled by
1344+
// ValidateInternalCalls pass.
1345+
TargetSymbol = getSymbol();
13581346
}
13591347

13601348
if (!TargetSymbol) {

bolt/lib/Passes/ValidateInternalCalls.cpp

+6-3
Original file line numberDiff line numberDiff line change
@@ -302,24 +302,27 @@ bool ValidateInternalCalls::analyzeFunction(BinaryFunction &Function) const {
302302
}
303303

304304
Error ValidateInternalCalls::runOnFunctions(BinaryContext &BC) {
305-
if (!BC.isX86())
306-
return Error::success();
307-
308305
// Look for functions that need validation. This should be pretty rare.
309306
std::set<BinaryFunction *> NeedsValidation;
310307
for (auto &BFI : BC.getBinaryFunctions()) {
311308
BinaryFunction &Function = BFI.second;
312309
for (BinaryBasicBlock &BB : Function) {
313310
for (MCInst &Inst : BB) {
314311
if (getInternalCallTarget(Function, Inst)) {
312+
BC.errs() << "BOLT-WARNING: internal call detected in function "
313+
<< Function << '\n';
315314
NeedsValidation.insert(&Function);
316315
Function.setSimple(false);
316+
Function.setPreserveNops(true);
317317
break;
318318
}
319319
}
320320
}
321321
}
322322

323+
if (!BC.isX86())
324+
return Error::success();
325+
323326
// Skip validation for non-relocation mode
324327
if (!BC.HasRelocations)
325328
return Error::success();

bolt/lib/Profile/DataAggregator.cpp

+17-15
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ MaxSamples("max-samples",
8888
cl::cat(AggregatorCategory));
8989

9090
extern cl::opt<opts::ProfileFormatKind> ProfileFormat;
91-
extern cl::opt<bool> ProfileUsePseudoProbes;
91+
extern cl::opt<bool> ProfileWritePseudoProbes;
9292
extern cl::opt<std::string> SaveProfile;
9393

9494
cl::opt<bool> ReadPreAggregated(
@@ -2300,7 +2300,7 @@ std::error_code DataAggregator::writeBATYAML(BinaryContext &BC,
23002300
yaml::bolt::BinaryProfile BP;
23012301

23022302
const MCPseudoProbeDecoder *PseudoProbeDecoder =
2303-
opts::ProfileUsePseudoProbes ? BC.getPseudoProbeDecoder() : nullptr;
2303+
opts::ProfileWritePseudoProbes ? BC.getPseudoProbeDecoder() : nullptr;
23042304

23052305
// Fill out the header info.
23062306
BP.Header.Version = 1;
@@ -2415,25 +2415,27 @@ std::error_code DataAggregator::writeBATYAML(BinaryContext &BC,
24152415
Fragments.insert(BF);
24162416
for (const BinaryFunction *F : Fragments) {
24172417
const uint64_t FuncAddr = F->getAddress();
2418-
const auto &FragmentProbes =
2419-
llvm::make_range(ProbeMap.lower_bound(FuncAddr),
2420-
ProbeMap.lower_bound(FuncAddr + F->getSize()));
2421-
for (const auto &[OutputAddress, Probes] : FragmentProbes) {
2418+
for (const MCDecodedPseudoProbe &Probe :
2419+
ProbeMap.find(FuncAddr, FuncAddr + F->getSize())) {
2420+
const uint32_t OutputAddress = Probe.getAddress();
24222421
const uint32_t InputOffset = BAT->translate(
24232422
FuncAddr, OutputAddress - FuncAddr, /*IsBranchSrc=*/true);
24242423
const unsigned BlockIndex = getBlock(InputOffset).second;
2425-
for (const MCDecodedPseudoProbe &Probe : Probes)
2426-
YamlBF.Blocks[BlockIndex].PseudoProbes.emplace_back(
2427-
yaml::bolt::PseudoProbeInfo{Probe.getGuid(), Probe.getIndex(),
2428-
Probe.getType()});
2424+
YamlBF.Blocks[BlockIndex].PseudoProbes.emplace_back(
2425+
yaml::bolt::PseudoProbeInfo{Probe.getGuid(), Probe.getIndex(),
2426+
Probe.getType()});
24292427
}
24302428
}
24312429
}
2432-
// Drop blocks without a hash, won't be useful for stale matching.
2433-
llvm::erase_if(YamlBF.Blocks,
2434-
[](const yaml::bolt::BinaryBasicBlockProfile &YamlBB) {
2435-
return YamlBB.Hash == (yaml::Hex64)0;
2436-
});
2430+
// Skip printing if there's no profile data
2431+
llvm::erase_if(
2432+
YamlBF.Blocks, [](const yaml::bolt::BinaryBasicBlockProfile &YamlBB) {
2433+
auto HasCount = [](const auto &SI) { return SI.Count; };
2434+
bool HasAnyCount = YamlBB.ExecCount ||
2435+
llvm::any_of(YamlBB.Successors, HasCount) ||
2436+
llvm::any_of(YamlBB.CallSites, HasCount);
2437+
return !HasAnyCount;
2438+
});
24372439
BP.Functions.emplace_back(YamlBF);
24382440
}
24392441
}

bolt/lib/Profile/YAMLProfileReader.cpp

+1-5
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,6 @@ llvm::cl::opt<bool>
4949
llvm::cl::opt<bool> ProfileUseDFS("profile-use-dfs",
5050
cl::desc("use DFS order for YAML profile"),
5151
cl::Hidden, cl::cat(BoltOptCategory));
52-
53-
llvm::cl::opt<bool> ProfileUsePseudoProbes(
54-
"profile-use-pseudo-probes",
55-
cl::desc("Use pseudo probes for profile generation and matching"),
56-
cl::Hidden, cl::cat(BoltOptCategory));
5752
} // namespace opts
5853

5954
namespace llvm {
@@ -373,6 +368,7 @@ Error YAMLProfileReader::preprocessProfile(BinaryContext &BC) {
373368
return errorCodeToError(EC);
374369
}
375370
yaml::Input YamlInput(MB.get()->getBuffer());
371+
YamlInput.setAllowUnknownKeys(true);
376372

377373
// Consume YAML file.
378374
YamlInput >> YamlBP;

0 commit comments

Comments
 (0)