Skip to content

Commit b182036

Browse files
authored
Merge branch 'main' into GISel_trunc_sat
2 parents 85d6bab + 0740db9 commit b182036

File tree

2,030 files changed

+93283
-42929
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,030 files changed

+93283
-42929
lines changed

.github/workflows/containers/github-action-ci-windows/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ RUN powershell -Command \
8585
RUN git config --system core.longpaths true & \
8686
git config --global core.autocrlf false
8787
88-
ARG RUNNER_VERSION=2.325.0
88+
ARG RUNNER_VERSION=2.326.0
8989
ENV RUNNER_VERSION=$RUNNER_VERSION
9090
9191
RUN powershell -Command \

.github/workflows/containers/github-action-ci/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ WORKDIR /home/gha
8686

8787
FROM ci-container as ci-container-agent
8888

89-
ENV GITHUB_RUNNER_VERSION=2.325.0
89+
ENV GITHUB_RUNNER_VERSION=2.326.0
9090

9191
RUN mkdir actions-runner && \
9292
cd actions-runner && \

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

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,40 @@ jobs:
1515
strategy:
1616
fail-fast: false
1717
matrix:
18-
build_type: [Debug, Release, MinSizeRel]
18+
# Build basic linux configuration with Debug/Release/MinSizeRel and all
19+
# other configurations in Debug only.
1920
include:
2021
- os: ubuntu-24.04
22+
build_type: Debug
23+
ccache-variant: sccache
24+
c_compiler: clang-21
25+
cpp_compiler: clang++-21
26+
target: x86_64-unknown-linux-llvm
27+
include_scudo: ON
28+
- os: ubuntu-24.04
29+
build_type: Release
30+
ccache-variant: sccache
31+
c_compiler: clang-21
32+
cpp_compiler: clang++-21
33+
target: x86_64-unknown-linux-llvm
34+
include_scudo: ON
35+
- os: ubuntu-24.04
36+
build_type: MinSizeRel
2137
ccache-variant: sccache
2238
c_compiler: clang-21
2339
cpp_compiler: clang++-21
2440
target: x86_64-unknown-linux-llvm
2541
include_scudo: ON
2642
# TODO: remove ccache logic when https://github.com/hendrikmuhs/ccache-action/issues/279 is resolved.
2743
- os: ubuntu-24.04-arm
44+
build_type: Debug
2845
ccache-variant: ccache
2946
c_compiler: clang-21
3047
cpp_compiler: clang++-21
3148
target: aarch64-unknown-linux-llvm
3249
include_scudo: ON
3350
- os: ubuntu-24.04
51+
build_type: Debug
3452
ccache-variant: ccache
3553
c_compiler: clang-21
3654
cpp_compiler: clang++-21
@@ -97,7 +115,7 @@ jobs:
97115
-DCMAKE_C_COMPILER_LAUNCHER=${{ matrix.ccache-variant }} \
98116
-DCMAKE_CXX_COMPILER_LAUNCHER=${{ matrix.ccache-variant }} \
99117
-DCMAKE_INSTALL_PREFIX=${{ steps.strings.outputs.build-install-dir }} \
100-
-DLLVM_RUNTIMES_TARGET=${{ matrix.target }} \
118+
-DLLVM_RUNTIME_TARGETS=${{ matrix.target }} \
101119
-DLLVM_ENABLE_RUNTIMES="$RUNTIMES" \
102120
-DLLVM_LIBC_FULL_BUILD=ON \
103121
-G Ninja \

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
# Set fail-fast to false to ensure that feedback is delivered for all matrix combinations.
1717
fail-fast: false
1818
matrix:
19-
build_type: [Debug, Release, MinSizeRel]
19+
os: [ubuntu-24.04, ubuntu-24.04-arm, windows-2022, windows-2025, macos-14]
2020
include:
2121
# TODO: add linux gcc when it is fixed
2222
- os: ubuntu-24.04
@@ -96,7 +96,7 @@ jobs:
9696
cmake -B ${{ steps.strings.outputs.build-output-dir }}
9797
-DCMAKE_CXX_COMPILER=${{ matrix.compiler.cpp_compiler }}
9898
-DCMAKE_C_COMPILER=${{ matrix.compiler.c_compiler }}
99-
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
99+
-DCMAKE_BUILD_TYPE=Debug
100100
-DCMAKE_C_COMPILER_LAUNCHER=${{ matrix.ccache-variant }}
101101
-DCMAKE_CXX_COMPILER_LAUNCHER=${{ matrix.ccache-variant }}
102102
-DCMAKE_POLICY_DEFAULT_CMP0141=NEW
@@ -110,7 +110,6 @@ jobs:
110110
cmake
111111
--build ${{ steps.strings.outputs.build-output-dir }}
112112
--parallel
113-
--config MinSizeRel
114113
--target libc
115114
116115
- name: Test

bolt/include/bolt/Profile/DataAggregator.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,7 @@ class DataAggregator : public DataReader {
236236

237237
/// Launch a perf subprocess with given args and save output for later
238238
/// parsing.
239-
void launchPerfProcess(StringRef Name, PerfProcessInfo &PPI,
240-
const char *ArgsString, bool Wait);
239+
void launchPerfProcess(StringRef Name, PerfProcessInfo &PPI, StringRef Args);
241240

242241
/// Delete all temporary files created to hold the output generated by spawned
243242
/// subprocesses during the aggregation job

bolt/lib/Profile/DataAggregator.cpp

Lines changed: 48 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -197,34 +197,27 @@ void DataAggregator::start() {
197197

198198
if (opts::BasicAggregation) {
199199
launchPerfProcess("events without LBR", MainEventsPPI,
200-
"script -F pid,event,ip",
201-
/*Wait = */ false);
200+
"script -F pid,event,ip");
202201
} else if (!opts::ITraceAggregation.empty()) {
203202
// Disable parsing memory profile from trace data, unless requested by user.
204203
if (!opts::ParseMemProfile.getNumOccurrences())
205204
opts::ParseMemProfile = false;
206-
207-
std::string ItracePerfScriptArgs = llvm::formatv(
208-
"script -F pid,brstack --itrace={0}", opts::ITraceAggregation);
209205
launchPerfProcess("branch events with itrace", MainEventsPPI,
210-
ItracePerfScriptArgs.c_str(),
211-
/*Wait = */ false);
206+
"script -F pid,brstack --itrace=" +
207+
opts::ITraceAggregation);
212208
} else {
213-
launchPerfProcess("branch events", MainEventsPPI, "script -F pid,brstack",
214-
/*Wait = */ false);
209+
launchPerfProcess("branch events", MainEventsPPI, "script -F pid,brstack");
215210
}
216211

217212
if (opts::ParseMemProfile)
218-
launchPerfProcess("mem events", MemEventsPPI, "script -F pid,event,addr,ip",
219-
/*Wait = */ false);
213+
launchPerfProcess("mem events", MemEventsPPI,
214+
"script -F pid,event,addr,ip");
220215

221216
launchPerfProcess("process events", MMapEventsPPI,
222-
"script --show-mmap-events --no-itrace",
223-
/*Wait = */ false);
217+
"script --show-mmap-events --no-itrace");
224218

225219
launchPerfProcess("task events", TaskEventsPPI,
226-
"script --show-task-events --no-itrace",
227-
/*Wait = */ false);
220+
"script --show-task-events --no-itrace");
228221
}
229222

230223
void DataAggregator::abort() {
@@ -246,13 +239,13 @@ void DataAggregator::abort() {
246239
}
247240

248241
void DataAggregator::launchPerfProcess(StringRef Name, PerfProcessInfo &PPI,
249-
const char *ArgsString, bool Wait) {
242+
StringRef Args) {
250243
SmallVector<StringRef, 4> Argv;
251244

252245
outs() << "PERF2BOLT: spawning perf job to read " << Name << '\n';
253246
Argv.push_back(PerfPath.data());
254247

255-
StringRef(ArgsString).split(Argv, ' ');
248+
Args.split(Argv, ' ');
256249
Argv.push_back("-f");
257250
Argv.push_back("-i");
258251
Argv.push_back(Filename.c_str());
@@ -286,64 +279,45 @@ void DataAggregator::launchPerfProcess(StringRef Name, PerfProcessInfo &PPI,
286279
<< "\n";
287280
});
288281

289-
if (Wait)
290-
PPI.PI.ReturnCode = sys::ExecuteAndWait(PerfPath.data(), Argv,
291-
/*envp*/ std::nullopt, Redirects);
292-
else
293-
PPI.PI = sys::ExecuteNoWait(PerfPath.data(), Argv, /*envp*/ std::nullopt,
294-
Redirects);
282+
PPI.PI = sys::ExecuteNoWait(PerfPath.data(), Argv, /*envp*/ std::nullopt,
283+
Redirects);
295284
}
296285

297286
void DataAggregator::processFileBuildID(StringRef FileBuildID) {
287+
auto WarningCallback = [](int ReturnCode, StringRef ErrBuf) {
288+
errs() << "PERF-ERROR: return code " << ReturnCode << "\n" << ErrBuf;
289+
};
290+
298291
PerfProcessInfo BuildIDProcessInfo;
299-
launchPerfProcess("buildid list",
300-
BuildIDProcessInfo,
301-
"buildid-list",
302-
/*Wait = */true);
303-
304-
if (BuildIDProcessInfo.PI.ReturnCode != 0) {
305-
ErrorOr<std::unique_ptr<MemoryBuffer>> MB =
306-
MemoryBuffer::getFileOrSTDIN(BuildIDProcessInfo.StderrPath.data());
307-
StringRef ErrBuf = (*MB)->getBuffer();
308-
309-
errs() << "PERF-ERROR: return code " << BuildIDProcessInfo.PI.ReturnCode
310-
<< '\n';
311-
errs() << ErrBuf;
292+
launchPerfProcess("buildid list", BuildIDProcessInfo, "buildid-list");
293+
if (prepareToParse("buildid", BuildIDProcessInfo, WarningCallback))
312294
return;
313-
}
314295

315-
ErrorOr<std::unique_ptr<MemoryBuffer>> MB =
316-
MemoryBuffer::getFileOrSTDIN(BuildIDProcessInfo.StdoutPath.data());
317-
if (std::error_code EC = MB.getError()) {
318-
errs() << "Cannot open " << BuildIDProcessInfo.StdoutPath.data() << ": "
319-
<< EC.message() << "\n";
296+
std::optional<StringRef> FileName = getFileNameForBuildID(FileBuildID);
297+
if (FileName && *FileName == sys::path::filename(BC->getFilename())) {
298+
outs() << "PERF2BOLT: matched build-id and file name\n";
320299
return;
321300
}
322301

323-
FileBuf = std::move(*MB);
324-
ParsingBuf = FileBuf->getBuffer();
325-
326-
std::optional<StringRef> FileName = getFileNameForBuildID(FileBuildID);
327-
if (!FileName) {
328-
if (hasAllBuildIDs()) {
329-
errs() << "PERF2BOLT-ERROR: failed to match build-id from perf output. "
330-
"This indicates the input binary supplied for data aggregation "
331-
"is not the same recorded by perf when collecting profiling "
332-
"data, or there were no samples recorded for the binary. "
333-
"Use -ignore-build-id option to override.\n";
334-
if (!opts::IgnoreBuildID)
335-
abort();
336-
} else {
337-
errs() << "PERF2BOLT-WARNING: build-id will not be checked because perf "
338-
"data was recorded without it\n";
339-
return;
340-
}
341-
} else if (*FileName != llvm::sys::path::filename(BC->getFilename())) {
302+
if (FileName) {
342303
errs() << "PERF2BOLT-WARNING: build-id matched a different file name\n";
343304
BuildIDBinaryName = std::string(*FileName);
344-
} else {
345-
outs() << "PERF2BOLT: matched build-id and file name\n";
305+
return;
346306
}
307+
308+
if (!hasAllBuildIDs()) {
309+
errs() << "PERF2BOLT-WARNING: build-id will not be checked because perf "
310+
"data was recorded without it\n";
311+
return;
312+
}
313+
314+
errs() << "PERF2BOLT-ERROR: failed to match build-id from perf output. "
315+
"This indicates the input binary supplied for data aggregation "
316+
"is not the same recorded by perf when collecting profiling "
317+
"data, or there were no samples recorded for the binary. "
318+
"Use -ignore-build-id option to override.\n";
319+
if (!opts::IgnoreBuildID)
320+
abort();
347321
}
348322

349323
bool DataAggregator::checkPerfDataMagic(StringRef FileName) {
@@ -432,14 +406,24 @@ int DataAggregator::prepareToParse(StringRef Name, PerfProcessInfo &Process,
432406
std::string Error;
433407
outs() << "PERF2BOLT: waiting for perf " << Name
434408
<< " collection to finish...\n";
435-
sys::ProcessInfo PI = sys::Wait(Process.PI, std::nullopt, &Error);
409+
std::optional<sys::ProcessStatistics> PS;
410+
sys::ProcessInfo PI = sys::Wait(Process.PI, std::nullopt, &Error, &PS);
436411

437412
if (!Error.empty()) {
438413
errs() << "PERF-ERROR: " << PerfPath << ": " << Error << "\n";
439414
deleteTempFiles();
440415
exit(1);
441416
}
442417

418+
LLVM_DEBUG({
419+
const float UserSec = 1.f * PS->UserTime.count() / 1e6;
420+
const float TotalSec = 1.f * PS->TotalTime.count() / 1e6;
421+
const float PeakGiB = 1.f * PS->PeakMemory / (1 << 20);
422+
dbgs() << formatv("Finished in {0:f2}s user time, {1:f2}s total time, "
423+
"{2:f2} GiB peak RSS\n",
424+
UserSec, TotalSec, PeakGiB);
425+
});
426+
443427
if (PI.ReturnCode != 0) {
444428
ErrorOr<std::unique_ptr<MemoryBuffer>> ErrorMB =
445429
MemoryBuffer::getFileOrSTDIN(Process.StderrPath.data());

bolt/lib/Target/X86/X86MCPlusBuilder.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2441,6 +2441,7 @@ class X86MCPlusBuilder : public MCPlusBuilder {
24412441

24422442
assert(FKI.TargetOffset == 0 && "0-bit relocation offset expected");
24432443
const uint64_t RelOffset = Fixup.getOffset();
2444+
auto [RelSymbol, RelAddend] = extractFixupExpr(Fixup);
24442445

24452446
uint32_t RelType;
24462447
if (Fixup.isPCRel()) {
@@ -2452,6 +2453,9 @@ class X86MCPlusBuilder : public MCPlusBuilder {
24522453
case 32: RelType = ELF::R_X86_64_PC32; break;
24532454
case 64: RelType = ELF::R_X86_64_PC64; break;
24542455
}
2456+
// Adjust PC-relative fixup offsets, which are calculated from the start
2457+
// of the next instruction.
2458+
RelAddend -= FKI.TargetSize / 8;
24552459
} else {
24562460
switch (FKI.TargetSize) {
24572461
default:
@@ -2463,8 +2467,6 @@ class X86MCPlusBuilder : public MCPlusBuilder {
24632467
}
24642468
}
24652469

2466-
auto [RelSymbol, RelAddend] = extractFixupExpr(Fixup);
2467-
24682470
return Relocation({RelOffset, RelSymbol, RelType, RelAddend, 0});
24692471
}
24702472

clang-tools-extra/clang-tidy/ClangTidy.cpp

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ namespace clang::tidy {
5555

5656
namespace {
5757
#if CLANG_TIDY_ENABLE_STATIC_ANALYZER
58-
static const char *AnalyzerCheckNamePrefix = "clang-analyzer-";
58+
#define ANALYZER_CHECK_NAME_PREFIX "clang-analyzer-"
59+
static constexpr llvm::StringLiteral AnalyzerCheckNamePrefix =
60+
ANALYZER_CHECK_NAME_PREFIX;
5961

6062
class AnalyzerDiagnosticConsumer : public ento::PathDiagnosticConsumer {
6163
public:
@@ -351,10 +353,9 @@ ClangTidyASTConsumerFactory::ClangTidyASTConsumerFactory(
351353
static void
352354
setStaticAnalyzerCheckerOpts(const ClangTidyOptions &Opts,
353355
clang::AnalyzerOptions &AnalyzerOptions) {
354-
StringRef AnalyzerPrefix(AnalyzerCheckNamePrefix);
355356
for (const auto &Opt : Opts.CheckOptions) {
356357
StringRef OptName(Opt.getKey());
357-
if (!OptName.consume_front(AnalyzerPrefix))
358+
if (!OptName.consume_front(AnalyzerCheckNamePrefix))
358359
continue;
359360
// Analyzer options are always local options so we can ignore priority.
360361
AnalyzerOptions.Config[OptName] = Opt.getValue().Value;
@@ -476,7 +477,8 @@ std::vector<std::string> ClangTidyASTConsumerFactory::getCheckNames() {
476477
#if CLANG_TIDY_ENABLE_STATIC_ANALYZER
477478
for (const auto &AnalyzerCheck : getAnalyzerCheckersAndPackages(
478479
Context, Context.canEnableAnalyzerAlphaCheckers()))
479-
CheckNames.push_back(AnalyzerCheckNamePrefix + AnalyzerCheck.first);
480+
CheckNames.emplace_back(
481+
(AnalyzerCheckNamePrefix + AnalyzerCheck.first).str());
480482
#endif // CLANG_TIDY_ENABLE_STATIC_ANALYZER
481483

482484
llvm::sort(CheckNames);
@@ -668,18 +670,19 @@ getAllChecksAndOptions(bool AllowEnablingAnalyzerAlphaCheckers) {
668670
Buffer.append(AnalyzerCheck);
669671
Result.Checks.insert(Buffer);
670672
}
671-
for (std::string OptionName : {
673+
674+
static constexpr llvm::StringLiteral OptionNames[] = {
672675
#define GET_CHECKER_OPTIONS
673676
#define CHECKER_OPTION(TYPE, CHECKER, OPTION_NAME, DESCRIPTION, DEFAULT, \
674677
RELEASE, HIDDEN) \
675-
Twine(AnalyzerCheckNamePrefix).concat(CHECKER ":" OPTION_NAME).str(),
678+
ANALYZER_CHECK_NAME_PREFIX CHECKER ":" OPTION_NAME,
676679

677680
#include "clang/StaticAnalyzer/Checkers/Checkers.inc"
678681
#undef CHECKER_OPTION
679682
#undef GET_CHECKER_OPTIONS
680-
}) {
681-
Result.Options.insert(OptionName);
682-
}
683+
};
684+
685+
Result.Options.insert_range(OptionNames);
683686
#endif // CLANG_TIDY_ENABLE_STATIC_ANALYZER
684687

685688
Context.setOptionsCollector(&Result.Options);

clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,9 @@ void ClangTidyDiagnosticConsumer::forwardDiagnostic(const Diagnostic &Info) {
544544
case clang::DiagnosticsEngine::ak_attr:
545545
Builder << reinterpret_cast<Attr *>(Info.getRawArg(Index));
546546
break;
547+
case clang::DiagnosticsEngine::ak_attr_info:
548+
Builder << reinterpret_cast<AttributeCommonInfo *>(Info.getRawArg(Index));
549+
break;
547550
case clang::DiagnosticsEngine::ak_addrspace:
548551
Builder << static_cast<LangAS>(Info.getRawArg(Index));
549552
break;

clang-tools-extra/clang-tidy/abseil/AbseilMatcher.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ AST_POLYMORPHIC_MATCHER(
4646
if (PrefixPosition == StringRef::npos)
4747
return false;
4848
Path = Path.drop_front(PrefixPosition + AbslPrefix.size());
49-
static const char *AbseilLibraries[] = {
49+
static constexpr llvm::StringLiteral AbseilLibraries[] = {
5050
"algorithm", "base", "container", "debugging", "flags",
5151
"hash", "iterator", "memory", "meta", "numeric",
5252
"profiling", "random", "status", "strings", "synchronization",
5353
"time", "types", "utility"};
54-
return llvm::any_of(AbseilLibraries, [&](const char *Library) {
54+
return llvm::any_of(AbseilLibraries, [&](llvm::StringLiteral Library) {
5555
return Path.starts_with(Library);
5656
});
5757
}

0 commit comments

Comments
 (0)