Skip to content

Commit 3484451

Browse files
authored
Merge branch 'main' into carrot-licm-coroutine
2 parents df25fb1 + 0fffb9f commit 3484451

File tree

8,922 files changed

+436801
-211864
lines changed

Some content is hidden

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

8,922 files changed

+436801
-211864
lines changed

.ci/compute_projects.py

Lines changed: 49 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
"clang": {"compiler-rt"},
8181
"clang-tools-extra": {"libc"},
8282
"libc": {"libc"},
83+
"compiler-rt": {"compiler-rt"},
8384
".ci": {"compiler-rt", "libc"},
8485
}
8586
DEPENDENT_RUNTIMES_TO_TEST_NEEDS_RECONFIG = {
@@ -100,6 +101,9 @@
100101
"libc", # No Windows Support.
101102
"lldb", # TODO(issues/132800): Needs environment setup.
102103
"bolt", # No Windows Support.
104+
"libcxx",
105+
"libcxxabi",
106+
"libunwind",
103107
}
104108

105109
# These are projects that we should test if the project itself is changed but
@@ -118,6 +122,9 @@
118122
"lldb",
119123
"openmp",
120124
"polly",
125+
"libcxx",
126+
"libcxxabi",
127+
"libunwind",
121128
}
122129

123130
PROJECT_CHECK_TARGETS = {
@@ -144,6 +151,23 @@
144151

145152
RUNTIMES = {"libcxx", "libcxxabi", "libunwind", "compiler-rt", "libc"}
146153

154+
# Meta projects are projects that need explicit handling but do not reside
155+
# in their own top level folder. To add a meta project, the start of the path
156+
# for the metaproject should be mapped to the name of the project below.
157+
# Multiple paths can map to the same metaproject.
158+
META_PROJECTS = {
159+
("clang", "lib", "CIR"): "CIR",
160+
("clang", "test", "CIR"): "CIR",
161+
("clang", "include", "clang", "CIR"): "CIR",
162+
("*", "docs"): "docs",
163+
("llvm", "utils", "gn"): "gn",
164+
(".github", "workflows", "premerge.yaml"): ".ci",
165+
("third-party",): ".ci",
166+
}
167+
168+
# Projects that should not run any tests. These need to be metaprojects.
169+
SKIP_PROJECTS = ["docs", "gn"]
170+
147171

148172
def _add_dependencies(projects: Set[str], runtimes: Set[str]) -> Set[str]:
149173
projects_with_dependents = set(projects)
@@ -236,29 +260,34 @@ def _compute_runtimes_to_build(
236260
return _exclude_projects(runtimes_to_build, platform)
237261

238262

263+
def _path_matches(matcher: tuple[str], file_path: tuple[str]) -> bool:
264+
if len(file_path) < len(matcher):
265+
return False
266+
for match_part, file_part in zip(matcher, file_path):
267+
if match_part == "*" or file_part == "*":
268+
continue
269+
if match_part != file_part:
270+
return False
271+
return True
272+
273+
274+
def _get_modified_projects_for_file(modified_file: str) -> Set[str]:
275+
modified_projects = set()
276+
path_parts = pathlib.Path(modified_file).parts
277+
for meta_project_files in META_PROJECTS.keys():
278+
if _path_matches(meta_project_files, path_parts):
279+
meta_project = META_PROJECTS[meta_project_files]
280+
if meta_project in SKIP_PROJECTS:
281+
return set()
282+
modified_projects.add(meta_project)
283+
modified_projects.add(pathlib.Path(modified_file).parts[0])
284+
return modified_projects
285+
286+
239287
def _get_modified_projects(modified_files: list[str]) -> Set[str]:
240288
modified_projects = set()
241289
for modified_file in modified_files:
242-
path_parts = pathlib.Path(modified_file).parts
243-
# Exclude files in the docs directory. They do not impact an test
244-
# targets and there is a separate workflow used for ensuring the
245-
# documentation builds.
246-
if len(path_parts) > 2 and path_parts[1] == "docs":
247-
continue
248-
# Exclude files for the gn build. We do not test it within premerge
249-
# and changes occur often enough that they otherwise take up
250-
# capacity.
251-
if len(path_parts) > 3 and path_parts[:3] == ("llvm", "utils", "gn"):
252-
continue
253-
# If the file is in the clang/lib/CIR directory, add the CIR project.
254-
if len(path_parts) > 3 and (
255-
path_parts[:3] == ("clang", "lib", "CIR")
256-
or path_parts[:3] == ("clang", "test", "CIR")
257-
or path_parts[:4] == ("clang", "include", "clang", "CIR")
258-
):
259-
modified_projects.add("CIR")
260-
# Fall through to add clang.
261-
modified_projects.add(pathlib.Path(modified_file).parts[0])
290+
modified_projects.update(_get_modified_projects_for_file(modified_file))
262291
return modified_projects
263292

264293

.ci/compute_projects_test.py

Lines changed: 119 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
22
# See https://llvm.org/LICENSE.txt for license information.
33
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4-
"""Does some stuff."""
4+
"""Tests for compute_projects.py"""
55

66
import unittest
77

@@ -45,16 +45,14 @@ def test_llvm_windows(self):
4545
env_variables["project_check_targets"],
4646
"check-clang check-clang-tools check-lld check-llvm check-mlir check-polly",
4747
)
48-
self.assertEqual(
49-
env_variables["runtimes_to_build"], "libcxx;libcxxabi;libunwind"
50-
)
48+
self.assertEqual(env_variables["runtimes_to_build"], "")
5149
self.assertEqual(
5250
env_variables["runtimes_check_targets"],
5351
"",
5452
)
5553
self.assertEqual(
5654
env_variables["runtimes_check_targets_needs_reconfig"],
57-
"check-cxx check-cxxabi check-unwind",
55+
"",
5856
)
5957

6058
def test_llvm_mac(self):
@@ -69,16 +67,14 @@ def test_llvm_mac(self):
6967
env_variables["project_check_targets"],
7068
"check-clang check-clang-tools check-lld check-llvm check-mlir",
7169
)
72-
self.assertEqual(
73-
env_variables["runtimes_to_build"], "libcxx;libcxxabi;libunwind"
74-
)
70+
self.assertEqual(env_variables["runtimes_to_build"], "")
7571
self.assertEqual(
7672
env_variables["runtimes_check_targets"],
7773
"",
7874
)
7975
self.assertEqual(
8076
env_variables["runtimes_check_targets_needs_reconfig"],
81-
"check-cxx check-cxxabi check-unwind",
77+
"",
8278
)
8379

8480
def test_clang(self):
@@ -119,19 +115,43 @@ def test_clang_windows(self):
119115
self.assertEqual(
120116
env_variables["project_check_targets"], "check-clang check-clang-tools"
121117
)
122-
self.assertEqual(
123-
env_variables["runtimes_to_build"], "libcxx;libcxxabi;libunwind"
124-
)
118+
self.assertEqual(env_variables["runtimes_to_build"], "")
125119
self.assertEqual(
126120
env_variables["runtimes_check_targets"],
127121
"",
128122
)
129123
self.assertEqual(
130124
env_variables["runtimes_check_targets_needs_reconfig"],
131-
"check-cxx check-cxxabi check-unwind",
125+
"",
132126
)
133127
self.assertEqual(env_variables["enable_cir"], "OFF")
134128

129+
def test_compiler_rt(self):
130+
env_variables = compute_projects.get_env_variables(
131+
["compiler-rt/lib/asan/asan_allocator.cpp"], "Linux"
132+
)
133+
self.assertEqual(
134+
env_variables["projects_to_build"],
135+
"clang;lld",
136+
)
137+
self.assertEqual(
138+
env_variables["project_check_targets"],
139+
"",
140+
)
141+
self.assertEqual(env_variables["runtimes_to_build"], "compiler-rt")
142+
self.assertEqual(
143+
env_variables["runtimes_check_targets"],
144+
"check-compiler-rt",
145+
)
146+
self.assertEqual(
147+
env_variables["runtimes_check_targets_needs_reconfig"],
148+
"",
149+
)
150+
self.assertEqual(
151+
env_variables["enable_cir"],
152+
"OFF",
153+
)
154+
135155
def test_cir(self):
136156
env_variables = compute_projects.get_env_variables(
137157
["clang/lib/CIR/CMakeLists.txt"], "Linux"
@@ -203,7 +223,7 @@ def test_flang(self):
203223

204224
def test_invalid_subproject(self):
205225
env_variables = compute_projects.get_env_variables(
206-
["third-party/benchmark/CMakeLists.txt"], "Linux"
226+
["llvm-libgcc/CMakeLists.txt"], "Linux"
207227
)
208228
self.assertEqual(env_variables["projects_to_build"], "")
209229
self.assertEqual(env_variables["project_check_targets"], "")
@@ -284,6 +304,31 @@ def test_ci(self):
284304
"check-cxx check-cxxabi check-unwind",
285305
)
286306

307+
def test_windows_ci(self):
308+
env_variables = compute_projects.get_env_variables(
309+
[".ci/compute_projects.py"], "Windows"
310+
)
311+
self.assertEqual(
312+
env_variables["projects_to_build"],
313+
"clang;clang-tools-extra;libclc;lld;llvm;mlir;polly",
314+
)
315+
self.assertEqual(
316+
env_variables["project_check_targets"],
317+
"check-clang check-clang-cir check-clang-tools check-lld check-llvm check-mlir check-polly",
318+
)
319+
self.assertEqual(
320+
env_variables["runtimes_to_build"],
321+
"",
322+
)
323+
self.assertEqual(
324+
env_variables["runtimes_check_targets"],
325+
"",
326+
)
327+
self.assertEqual(
328+
env_variables["runtimes_check_targets_needs_reconfig"],
329+
"",
330+
)
331+
287332
def test_lldb(self):
288333
env_variables = compute_projects.get_env_variables(
289334
["lldb/CMakeLists.txt"], "Linux"
@@ -308,6 +353,66 @@ def test_clang_tools_extra(self):
308353
self.assertEqual(env_variables["runtimes_check_targets"], "check-libc")
309354
self.assertEqual(env_variables["runtimes_check_targets_needs_reconfig"], "")
310355

356+
def test_premerge_workflow(self):
357+
env_variables = compute_projects.get_env_variables(
358+
[".github/workflows/premerge.yaml"], "Linux"
359+
)
360+
self.assertEqual(
361+
env_variables["projects_to_build"],
362+
"bolt;clang;clang-tools-extra;flang;libclc;lld;lldb;llvm;mlir;polly",
363+
)
364+
self.assertEqual(
365+
env_variables["project_check_targets"],
366+
"check-bolt check-clang check-clang-cir check-clang-tools check-flang check-lld check-lldb check-llvm check-mlir check-polly",
367+
)
368+
self.assertEqual(
369+
env_variables["runtimes_to_build"],
370+
"compiler-rt;libc;libcxx;libcxxabi;libunwind",
371+
)
372+
self.assertEqual(
373+
env_variables["runtimes_check_targets"],
374+
"check-compiler-rt check-libc",
375+
)
376+
self.assertEqual(
377+
env_variables["runtimes_check_targets_needs_reconfig"],
378+
"check-cxx check-cxxabi check-unwind",
379+
)
380+
381+
def test_other_github_workflow(self):
382+
env_variables = compute_projects.get_env_variables(
383+
[".github/workflows/docs.yml"], "Linux"
384+
)
385+
self.assertEqual(env_variables["projects_to_build"], "")
386+
self.assertEqual(env_variables["project_check_targets"], "")
387+
self.assertEqual(env_variables["runtimes_to_build"], "")
388+
self.assertEqual(env_variables["runtimes_check_targets"], "")
389+
self.assertEqual(env_variables["runtimes_check_targets_needs_reconfig"], "")
390+
391+
def test_third_party_benchmark(self):
392+
env_variables = compute_projects.get_env_variables(
393+
["third-party/benchmark/CMakeLists.txt"], "Linux"
394+
)
395+
self.assertEqual(
396+
env_variables["projects_to_build"],
397+
"bolt;clang;clang-tools-extra;flang;libclc;lld;lldb;llvm;mlir;polly",
398+
)
399+
self.assertEqual(
400+
env_variables["project_check_targets"],
401+
"check-bolt check-clang check-clang-cir check-clang-tools check-flang check-lld check-lldb check-llvm check-mlir check-polly",
402+
)
403+
self.assertEqual(
404+
env_variables["runtimes_to_build"],
405+
"compiler-rt;libc;libcxx;libcxxabi;libunwind",
406+
)
407+
self.assertEqual(
408+
env_variables["runtimes_check_targets"],
409+
"check-compiler-rt check-libc",
410+
)
411+
self.assertEqual(
412+
env_variables["runtimes_check_targets_needs_reconfig"],
413+
"check-cxx check-cxxabi check-unwind",
414+
)
415+
311416

312417
if __name__ == "__main__":
313418
unittest.main()

.ci/generate_test_report_github.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,25 @@
44
"""Script to generate a build report for Github."""
55

66
import argparse
7+
import platform
78

89
import generate_test_report_lib
910

11+
PLATFORM_TITLES = {
12+
"Windows": ":window: Windows x64 Test Results",
13+
"Linux": ":penguin: Linux x64 Test Results",
14+
}
15+
1016
if __name__ == "__main__":
1117
parser = argparse.ArgumentParser()
18+
parser.add_argument("return_code", help="The build's return code.", type=int)
1219
parser.add_argument(
13-
"title", help="Title of the test report, without Markdown formatting."
20+
"build_test_logs", help="Paths to JUnit report files and ninja logs.", nargs="*"
1421
)
15-
parser.add_argument("return_code", help="The build's return code.", type=int)
16-
parser.add_argument("junit_files", help="Paths to JUnit report files.", nargs="*")
1722
args = parser.parse_args()
1823

1924
report = generate_test_report_lib.generate_report_from_files(
20-
args.title, args.return_code, args.junit_files
25+
PLATFORM_TITLES[platform.system()], args.return_code, args.build_test_logs
2126
)
2227

2328
print(report)

0 commit comments

Comments
 (0)