Skip to content

Commit a096cb0

Browse files
author
iclsrc
committed
Merge from 'main' to 'sycl-web' (80 commits)
2 parents ddeb120 + 254ef5f commit a096cb0

File tree

433 files changed

+17083
-9677
lines changed

Some content is hidden

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

433 files changed

+17083
-9677
lines changed

.ci/metrics/metrics_test.py

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
2+
# See https://llvm.org/LICENSE.txt for license information.
3+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4+
"""Tests for metrics.py"""
5+
6+
from dataclasses import dataclass
7+
import requests
8+
import unittest
9+
import unittest.mock
10+
11+
import metrics
12+
13+
14+
class TestMetrics(unittest.TestCase):
15+
def test_upload_gauge_metric(self):
16+
"""Test that we can upload a gauge metric correctly.
17+
18+
Also verify that we pass around parameters like API keys and user IDs
19+
correctly to the HTTP POST request.
20+
"""
21+
test_metrics = [metrics.GaugeMetric("gauge_test", 5, 1000)]
22+
return_value = requests.Response()
23+
return_value.status_code = 204
24+
with unittest.mock.patch(
25+
"requests.post", return_value=return_value
26+
) as post_mock:
27+
metrics.upload_metrics(test_metrics, "test_userid", "test_api_key")
28+
self.assertSequenceEqual(post_mock.call_args.args, [metrics.GRAFANA_URL])
29+
self.assertEqual(
30+
post_mock.call_args.kwargs["data"], "gauge_test value=5 1000"
31+
)
32+
self.assertEqual(
33+
post_mock.call_args.kwargs["auth"], ("test_userid", "test_api_key")
34+
)
35+
36+
def test_upload_job_metric(self):
37+
"""Test that we can upload a job metric correctly."""
38+
test_metrics = [
39+
metrics.JobMetrics("test_job", 5, 10, 1, 1000, 7, "test_workflow")
40+
]
41+
return_value = requests.Response()
42+
return_value.status_code = 204
43+
with unittest.mock.patch(
44+
"requests.post", return_value=return_value
45+
) as post_mock:
46+
metrics.upload_metrics(test_metrics, "test_userid", "test_aoi_key")
47+
self.assertEqual(
48+
post_mock.call_args.kwargs["data"],
49+
"test_job queue_time=5,run_time=10,status=1 1000",
50+
)
51+
52+
def test_upload_unknown_metric(self):
53+
"""Test we report an error if we encounter an unknown metric type."""
54+
55+
@dataclass
56+
class FakeMetric:
57+
fake_data: str
58+
59+
test_metrics = [FakeMetric("test")]
60+
61+
with self.assertRaises(ValueError):
62+
metrics.upload_metrics(test_metrics, "test_userid", "test_api_key")
63+
64+
def test_bad_response_code(self):
65+
"""Test that we gracefully handle HTTP response errors."""
66+
test_metrics = [metrics.GaugeMetric("gauge_test", 5, 1000)]
67+
return_value = requests.Response()
68+
return_value.status_code = 403
69+
# Just assert that we continue running here and do not raise anything.
70+
with unittest.mock.patch("requests.post", return_value=return_value) as _:
71+
metrics.upload_metrics(test_metrics, "test_userid", "test_api_key")
72+
73+
74+
if __name__ == "__main__":
75+
unittest.main()

.github/workflows/check-ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ jobs:
3131
- name: Install Python Dependencies
3232
run: |
3333
pip3 install -r .ci/all_requirements.txt
34+
pip3 install -r .ci/metrics/requirements.lock.txt
3435
pip3 install pytest==8.4.1
3536
- name: Run Tests
3637
working-directory: .ci

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ RUN powershell -Command \
9090
RUN git config --system core.longpaths true & \
9191
git config --global core.autocrlf false
9292
93-
ARG RUNNER_VERSION=2.326.0
93+
ARG RUNNER_VERSION=2.327.0
9494
ENV RUNNER_VERSION=$RUNNER_VERSION
9595
9696
RUN powershell -Command \

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

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

9797
FROM ci-container as ci-container-agent
9898

99-
ENV GITHUB_RUNNER_VERSION=2.326.0
99+
ENV GITHUB_RUNNER_VERSION=2.327.0
100100

101101
RUN mkdir actions-runner && \
102102
cd actions-runner && \

.github/workflows/premerge.yaml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ jobs:
6262
# why we do not hardcode it.
6363
export SCCACHE_GCS_BUCKET=$CACHE_GCS_BUCKET
6464
export SCCACHE_GCS_RW_MODE=READ_WRITE
65+
66+
# Set the idle timeout to zero to ensure sccache runs for the
67+
# entire duration of the job. Otherwise it might stop if we run
68+
# several test suites in a row and discard statistics that we want
69+
# to save in the end.
70+
export SCCACHE_IDLE_TIMEOUT=0
6571
sccache --start-server
6672
6773
./.ci/monolithic-linux.sh "${projects_to_build}" "${project_check_targets}" "${runtimes_to_build}" "${runtimes_check_targets}" "${runtimes_check_targets_needs_reconfig}" "${enable_cir}"
@@ -110,7 +116,9 @@ jobs:
110116
shell: cmd
111117
run: |
112118
call C:\\BuildTools\\Common7\\Tools\\VsDevCmd.bat -arch=amd64 -host_arch=amd64
113-
bash -c "export SCCACHE_GCS_BUCKET=$CACHE_GCS_BUCKET; export SCCACHE_GCS_RW_MODE=READ_WRITE; sccache --start-server; .ci/monolithic-windows.sh \"${{ steps.vars.outputs.windows-projects }}\" \"${{ steps.vars.outputs.windows-check-targets }}\""
119+
# See the comments above in the Linux job for why we define each of
120+
# these environment variables.
121+
bash -c "export SCCACHE_GCS_BUCKET=$CACHE_GCS_BUCKET; export SCCACHE_GCS_RW_MODE=READ_WRITE; export SCCACHE_IDLE_TIMEOUT=0; sccache --start-server; .ci/monolithic-windows.sh \"${{ steps.vars.outputs.windows-projects }}\" \"${{ steps.vars.outputs.windows-check-targets }}\""
114122
- name: Upload Artifacts
115123
if: '!cancelled()'
116124
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0

bolt/lib/Rewrite/RewriteInstance.cpp

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4260,31 +4260,25 @@ void RewriteInstance::patchELFPHDRTable() {
42604260
const ELFFile<ELF64LE> &Obj = ELF64LEFile->getELFFile();
42614261
raw_fd_ostream &OS = Out->os();
42624262

4263-
// Write/re-write program headers.
42644263
Phnum = Obj.getHeader().e_phnum;
4265-
if (PHDRTableOffset) {
4266-
// Writing new pheader table and adding one new entry for R+X segment.
4267-
Phnum += 1;
4268-
if (NewWritableSegmentSize) {
4269-
// Adding one more entry for R+W segment.
4270-
Phnum += 1;
4271-
}
4272-
} else {
4264+
4265+
if (BC->NewSegments.empty()) {
4266+
BC->outs() << "BOLT-INFO: not adding new segments\n";
4267+
return;
4268+
}
4269+
4270+
if (opts::UseGnuStack) {
42734271
assert(!PHDRTableAddress && "unexpected address for program header table");
4274-
PHDRTableOffset = Obj.getHeader().e_phoff;
4275-
if (NewWritableSegmentSize) {
4272+
if (BC->NewSegments.size() > 1) {
42764273
BC->errs() << "BOLT-ERROR: unable to add writable segment\n";
42774274
exit(1);
42784275
}
4276+
} else {
4277+
Phnum += BC->NewSegments.size();
42794278
}
42804279

4281-
if (opts::Instrument)
4282-
Phnum += 2;
4283-
4284-
if (BC->NewSegments.empty()) {
4285-
BC->outs() << "BOLT-INFO: not adding new segments\n";
4286-
return;
4287-
}
4280+
if (!PHDRTableOffset)
4281+
PHDRTableOffset = Obj.getHeader().e_phoff;
42884282

42894283
const uint64_t SavedPos = OS.tell();
42904284
OS.seek(PHDRTableOffset);

clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ def main():
177177
parser.add_argument(
178178
"-j",
179179
type=int,
180-
default=1,
180+
default=0,
181181
help="number of tidy instances to be run in parallel.",
182182
)
183183
parser.add_argument(
@@ -318,6 +318,7 @@ def main():
318318
if max_task_count == 0:
319319
max_task_count = multiprocessing.cpu_count()
320320
max_task_count = min(len(lines_by_file), max_task_count)
321+
print(f"Running clang-tidy in {max_task_count} threads...")
321322

322323
combine_fixes = False
323324
export_fixes_dir = None

clang-tools-extra/clang-tidy/tool/run-clang-tidy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ async def main() -> None:
548548
files = {f for f in files if file_name_re.search(f)}
549549

550550
print(
551-
"Running clang-tidy for",
551+
f"Running clang-tidy in {max_task} threads for",
552552
len(files),
553553
"files out of",
554554
number_files_in_database,

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -207,13 +207,9 @@ FormatStringConverter::FormatStringConverter(
207207
ArgsOffset(FormatArgOffset + 1), LangOpts(LO) {
208208
assert(ArgsOffset <= NumArgs);
209209
FormatExpr = llvm::dyn_cast<StringLiteral>(
210-
Args[FormatArgOffset]->IgnoreImplicitAsWritten());
210+
Args[FormatArgOffset]->IgnoreUnlessSpelledInSource());
211211

212-
if (!FormatExpr || !FormatExpr->isOrdinary()) {
213-
// Function must have a narrow string literal as its first argument.
214-
conversionNotPossible("first argument is not a narrow string literal");
215-
return;
216-
}
212+
assert(FormatExpr && FormatExpr->isOrdinary());
217213

218214
if (const std::optional<StringRef> MaybeMacroName =
219215
formatStringContainsUnreplaceableMacro(Call, FormatExpr, SM, PP);

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ Improvements to clang-query
9393
Improvements to clang-tidy
9494
--------------------------
9595

96+
- The :program:`run-clang-tidy.py` and :program:`clang-tidy-diff.py` scripts
97+
now run checks in parallel by default using all available hardware threads.
98+
Both scripts display the number of threads being used in their output.
99+
96100
New checks
97101
^^^^^^^^^^
98102

@@ -124,6 +128,16 @@ Changes in existing checks
124128
- Improved :doc:`misc-header-include-cycle
125129
<clang-tidy/checks/misc/header-include-cycle>` check performance.
126130

131+
- Improved :doc:`modernize-use-std-format
132+
<clang-tidy/checks/modernize/use-std-format>` check to correctly match
133+
when the format string is converted to a different type by an implicit
134+
constructor call.
135+
136+
- Improved :doc:`modernize-use-std-print
137+
<clang-tidy/checks/modernize/use-std-print>` check to correctly match
138+
when the format string is converted to a different type by an implicit
139+
constructor call.
140+
127141
- Improved :doc:`portability-template-virtual-member-function
128142
<clang-tidy/checks/portability/template-virtual-member-function>` check to
129143
avoid false positives on pure virtual member functions.

0 commit comments

Comments
 (0)