Skip to content

Commit 79ca956

Browse files
Merge branch 'tracking' of https://github.com/abhishek-kaushik22/llvm-project into tracking
2 parents ac4766b + 09ab913 commit 79ca956

File tree

16,975 files changed

+1111755
-550079
lines changed

Some content is hidden

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

16,975 files changed

+1111755
-550079
lines changed

.ci/compute_projects.py

Lines changed: 80 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
PROJECT_DEPENDENCIES = {
2020
"llvm": set(),
2121
"clang": {"llvm"},
22+
"CIR": {"clang", "mlir"},
2223
"bolt": {"clang", "lld", "llvm"},
2324
"clang-tools-extra": {"clang", "llvm"},
2425
"compiler-rt": {"clang", "lld"},
@@ -52,8 +53,20 @@
5253
"clang": {"clang-tools-extra", "cross-project-tests"},
5354
"mlir": {"flang"},
5455
# Test everything if ci scripts are changed.
55-
# FIXME: Figure out what is missing and add here.
56-
".ci": {"llvm", "clang", "lld", "lldb"},
56+
".ci": {
57+
"llvm",
58+
"clang",
59+
"CIR",
60+
"lld",
61+
"lldb",
62+
"bolt",
63+
"clang-tools-extra",
64+
"mlir",
65+
"polly",
66+
"flang",
67+
"libclc",
68+
"openmp",
69+
},
5770
}
5871

5972
# This mapping describes runtimes that should be enabled for a specific project,
@@ -66,6 +79,8 @@
6679
DEPENDENT_RUNTIMES_TO_TEST = {
6780
"clang": {"compiler-rt"},
6881
"clang-tools-extra": {"libc"},
82+
"libc": {"libc"},
83+
".ci": {"compiler-rt", "libc"},
6984
}
7085
DEPENDENT_RUNTIMES_TO_TEST_NEEDS_RECONFIG = {
7186
"llvm": {"libcxx", "libcxxabi", "libunwind"},
@@ -115,6 +130,7 @@
115130
"lldb": "check-lldb",
116131
"llvm": "check-llvm",
117132
"clang": "check-clang",
133+
"CIR": "check-clang-cir",
118134
"bolt": "check-bolt",
119135
"lld": "check-lld",
120136
"flang": "check-flang",
@@ -128,20 +144,35 @@
128144

129145
RUNTIMES = {"libcxx", "libcxxabi", "libunwind", "compiler-rt", "libc"}
130146

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

132165
def _add_dependencies(projects: Set[str], runtimes: Set[str]) -> Set[str]:
133166
projects_with_dependents = set(projects)
134167
current_projects_count = 0
135168
while current_projects_count != len(projects_with_dependents):
136169
current_projects_count = len(projects_with_dependents)
137170
for project in list(projects_with_dependents):
138-
if project not in PROJECT_DEPENDENCIES:
139-
continue
140-
projects_with_dependents.update(PROJECT_DEPENDENCIES[project])
171+
if project in PROJECT_DEPENDENCIES:
172+
projects_with_dependents.update(PROJECT_DEPENDENCIES[project])
141173
for runtime in runtimes:
142-
if runtime not in PROJECT_DEPENDENCIES:
143-
continue
144-
projects_with_dependents.update(PROJECT_DEPENDENCIES[runtime])
174+
if runtime in PROJECT_DEPENDENCIES:
175+
projects_with_dependents.update(PROJECT_DEPENDENCIES[runtime])
145176
return projects_with_dependents
146177

147178

@@ -187,18 +218,16 @@ def _compute_projects_to_build(
187218
def _compute_project_check_targets(projects_to_test: Set[str]) -> Set[str]:
188219
check_targets = set()
189220
for project_to_test in projects_to_test:
190-
if project_to_test not in PROJECT_CHECK_TARGETS:
191-
continue
192-
check_targets.add(PROJECT_CHECK_TARGETS[project_to_test])
221+
if project_to_test in PROJECT_CHECK_TARGETS:
222+
check_targets.add(PROJECT_CHECK_TARGETS[project_to_test])
193223
return check_targets
194224

195225

196226
def _compute_runtimes_to_test(modified_projects: Set[str], platform: str) -> Set[str]:
197227
runtimes_to_test = set()
198228
for modified_project in modified_projects:
199-
if modified_project not in DEPENDENT_RUNTIMES_TO_TEST:
200-
continue
201-
runtimes_to_test.update(DEPENDENT_RUNTIMES_TO_TEST[modified_project])
229+
if modified_project in DEPENDENT_RUNTIMES_TO_TEST:
230+
runtimes_to_test.update(DEPENDENT_RUNTIMES_TO_TEST[modified_project])
202231
return _exclude_projects(runtimes_to_test, platform)
203232

204233

@@ -207,11 +236,10 @@ def _compute_runtimes_to_test_needs_reconfig(
207236
) -> Set[str]:
208237
runtimes_to_test = set()
209238
for modified_project in modified_projects:
210-
if modified_project not in DEPENDENT_RUNTIMES_TO_TEST_NEEDS_RECONFIG:
211-
continue
212-
runtimes_to_test.update(
213-
DEPENDENT_RUNTIMES_TO_TEST_NEEDS_RECONFIG[modified_project]
214-
)
239+
if modified_project in DEPENDENT_RUNTIMES_TO_TEST_NEEDS_RECONFIG:
240+
runtimes_to_test.update(
241+
DEPENDENT_RUNTIMES_TO_TEST_NEEDS_RECONFIG[modified_project]
242+
)
215243
return _exclude_projects(runtimes_to_test, platform)
216244

217245

@@ -225,21 +253,34 @@ def _compute_runtimes_to_build(
225253
return _exclude_projects(runtimes_to_build, platform)
226254

227255

256+
def _path_matches(matcher: tuple[str], file_path: tuple[str]) -> bool:
257+
if len(file_path) < len(matcher):
258+
return False
259+
for match_part, file_part in zip(matcher, file_path):
260+
if match_part == "*" or file_part == "*":
261+
continue
262+
if match_part != file_part:
263+
return False
264+
return True
265+
266+
267+
def _get_modified_projects_for_file(modified_file: str) -> Set[str]:
268+
modified_projects = set()
269+
path_parts = pathlib.Path(modified_file).parts
270+
for meta_project_files in META_PROJECTS.keys():
271+
if _path_matches(meta_project_files, path_parts):
272+
meta_project = META_PROJECTS[meta_project_files]
273+
if meta_project in SKIP_PROJECTS:
274+
return set()
275+
modified_projects.add(meta_project)
276+
modified_projects.add(pathlib.Path(modified_file).parts[0])
277+
return modified_projects
278+
279+
228280
def _get_modified_projects(modified_files: list[str]) -> Set[str]:
229281
modified_projects = set()
230282
for modified_file in modified_files:
231-
path_parts = pathlib.Path(modified_file).parts
232-
# Exclude files in the docs directory. They do not impact an test
233-
# targets and there is a separate workflow used for ensuring the
234-
# documentation builds.
235-
if len(path_parts) > 2 and path_parts[1] == "docs":
236-
continue
237-
# Exclude files for the gn build. We do not test it within premerge
238-
# and changes occur often enough that they otherwise take up
239-
# capacity.
240-
if len(path_parts) > 3 and path_parts[:3] == ("llvm", "utils", "gn"):
241-
continue
242-
modified_projects.add(pathlib.Path(modified_file).parts[0])
283+
modified_projects.update(_get_modified_projects_for_file(modified_file))
243284
return modified_projects
244285

245286

@@ -259,6 +300,13 @@ def get_env_variables(modified_files: list[str], platform: str) -> Set[str]:
259300
runtimes_check_targets_needs_reconfig = _compute_project_check_targets(
260301
runtimes_to_test_needs_reconfig
261302
)
303+
304+
# CIR is used as a pseudo-project in this script. It is built as part of the
305+
# clang build, but it requires an explicit option to enable. We set that
306+
# option here, and remove it from the projects_to_build list.
307+
enable_cir = "ON" if "CIR" in projects_to_build else "OFF"
308+
projects_to_build.discard("CIR")
309+
262310
# We use a semicolon to separate the projects/runtimes as they get passed
263311
# to the CMake invocation and thus we need to use the CMake list separator
264312
# (;). We use spaces to separate the check targets as they end up getting
@@ -271,6 +319,7 @@ def get_env_variables(modified_files: list[str], platform: str) -> Set[str]:
271319
"runtimes_check_targets_needs_reconfig": " ".join(
272320
sorted(runtimes_check_targets_needs_reconfig)
273321
),
322+
"enable_cir": enable_cir,
274323
}
275324

276325

.ci/compute_projects_test.py

Lines changed: 112 additions & 7 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

@@ -104,6 +104,10 @@ def test_clang(self):
104104
env_variables["runtimes_check_targets_needs_reconfig"],
105105
"check-cxx check-cxxabi check-unwind",
106106
)
107+
self.assertEqual(
108+
env_variables["enable_cir"],
109+
"OFF",
110+
)
107111

108112
def test_clang_windows(self):
109113
env_variables = compute_projects.get_env_variables(
@@ -126,6 +130,32 @@ def test_clang_windows(self):
126130
env_variables["runtimes_check_targets_needs_reconfig"],
127131
"check-cxx check-cxxabi check-unwind",
128132
)
133+
self.assertEqual(env_variables["enable_cir"], "OFF")
134+
135+
def test_cir(self):
136+
env_variables = compute_projects.get_env_variables(
137+
["clang/lib/CIR/CMakeLists.txt"], "Linux"
138+
)
139+
self.assertEqual(
140+
env_variables["projects_to_build"],
141+
"clang;clang-tools-extra;lld;llvm;mlir",
142+
)
143+
self.assertEqual(
144+
env_variables["project_check_targets"],
145+
"check-clang check-clang-cir check-clang-tools",
146+
)
147+
self.assertEqual(
148+
env_variables["runtimes_to_build"], "compiler-rt;libcxx;libcxxabi;libunwind"
149+
)
150+
self.assertEqual(
151+
env_variables["runtimes_check_targets"],
152+
"check-compiler-rt",
153+
)
154+
self.assertEqual(
155+
env_variables["runtimes_check_targets_needs_reconfig"],
156+
"check-cxx check-cxxabi check-unwind",
157+
)
158+
self.assertEqual(env_variables["enable_cir"], "ON")
129159

130160
def test_bolt(self):
131161
env_variables = compute_projects.get_env_variables(
@@ -158,6 +188,7 @@ def test_mlir(self):
158188
self.assertEqual(env_variables["runtimes_to_build"], "")
159189
self.assertEqual(env_variables["runtimes_check_targets"], "")
160190
self.assertEqual(env_variables["runtimes_check_targets_needs_reconfig"], "")
191+
self.assertEqual(env_variables["enable_cir"], "OFF")
161192

162193
def test_flang(self):
163194
env_variables = compute_projects.get_env_variables(
@@ -168,10 +199,11 @@ def test_flang(self):
168199
self.assertEqual(env_variables["runtimes_to_build"], "")
169200
self.assertEqual(env_variables["runtimes_check_targets"], "")
170201
self.assertEqual(env_variables["runtimes_check_targets_needs_reconfig"], "")
202+
self.assertEqual(env_variables["enable_cir"], "OFF")
171203

172204
def test_invalid_subproject(self):
173205
env_variables = compute_projects.get_env_variables(
174-
["third-party/benchmark/CMakeLists.txt"], "Linux"
206+
["llvm-libgcc/CMakeLists.txt"], "Linux"
175207
)
176208
self.assertEqual(env_variables["projects_to_build"], "")
177209
self.assertEqual(env_variables["project_check_targets"], "")
@@ -187,7 +219,7 @@ def test_top_level_file(self):
187219
self.assertEqual(env_variables["runtimes_check_targets"], "")
188220
self.assertEqual(env_variables["runtimes_check_targets_needs_reconfig"], "")
189221

190-
def test_exclude_runtiems_in_projects(self):
222+
def test_exclude_libcxx_in_projects(self):
191223
env_variables = compute_projects.get_env_variables(
192224
["libcxx/CMakeLists.txt"], "Linux"
193225
)
@@ -197,6 +229,16 @@ def test_exclude_runtiems_in_projects(self):
197229
self.assertEqual(env_variables["runtimes_check_targets"], "")
198230
self.assertEqual(env_variables["runtimes_check_targets_needs_reconfig"], "")
199231

232+
def test_include_libc_in_runtimes(self):
233+
env_variables = compute_projects.get_env_variables(
234+
["libc/CMakeLists.txt"], "Linux"
235+
)
236+
self.assertEqual(env_variables["projects_to_build"], "clang;lld")
237+
self.assertEqual(env_variables["project_check_targets"], "")
238+
self.assertEqual(env_variables["runtimes_to_build"], "libc")
239+
self.assertEqual(env_variables["runtimes_check_targets"], "check-libc")
240+
self.assertEqual(env_variables["runtimes_check_targets_needs_reconfig"], "")
241+
200242
def test_exclude_docs(self):
201243
env_variables = compute_projects.get_env_variables(
202244
["llvm/docs/CIBestPractices.rst"], "Linux"
@@ -221,18 +263,21 @@ def test_ci(self):
221263
env_variables = compute_projects.get_env_variables(
222264
[".ci/compute_projects.py"], "Linux"
223265
)
224-
self.assertEqual(env_variables["projects_to_build"], "clang;lld;lldb;llvm")
266+
self.assertEqual(
267+
env_variables["projects_to_build"],
268+
"bolt;clang;clang-tools-extra;flang;libclc;lld;lldb;llvm;mlir;polly",
269+
)
225270
self.assertEqual(
226271
env_variables["project_check_targets"],
227-
"check-clang check-lld check-lldb check-llvm",
272+
"check-bolt check-clang check-clang-cir check-clang-tools check-flang check-lld check-lldb check-llvm check-mlir check-polly",
228273
)
229274
self.assertEqual(
230275
env_variables["runtimes_to_build"],
231-
"libcxx;libcxxabi;libunwind",
276+
"compiler-rt;libc;libcxx;libcxxabi;libunwind",
232277
)
233278
self.assertEqual(
234279
env_variables["runtimes_check_targets"],
235-
"",
280+
"check-compiler-rt check-libc",
236281
)
237282
self.assertEqual(
238283
env_variables["runtimes_check_targets_needs_reconfig"],
@@ -263,6 +308,66 @@ def test_clang_tools_extra(self):
263308
self.assertEqual(env_variables["runtimes_check_targets"], "check-libc")
264309
self.assertEqual(env_variables["runtimes_check_targets_needs_reconfig"], "")
265310

311+
def test_premerge_workflow(self):
312+
env_variables = compute_projects.get_env_variables(
313+
[".github/workflows/premerge.yaml"], "Linux"
314+
)
315+
self.assertEqual(
316+
env_variables["projects_to_build"],
317+
"bolt;clang;clang-tools-extra;flang;libclc;lld;lldb;llvm;mlir;polly",
318+
)
319+
self.assertEqual(
320+
env_variables["project_check_targets"],
321+
"check-bolt check-clang check-clang-cir check-clang-tools check-flang check-lld check-lldb check-llvm check-mlir check-polly",
322+
)
323+
self.assertEqual(
324+
env_variables["runtimes_to_build"],
325+
"compiler-rt;libc;libcxx;libcxxabi;libunwind",
326+
)
327+
self.assertEqual(
328+
env_variables["runtimes_check_targets"],
329+
"check-compiler-rt check-libc",
330+
)
331+
self.assertEqual(
332+
env_variables["runtimes_check_targets_needs_reconfig"],
333+
"check-cxx check-cxxabi check-unwind",
334+
)
335+
336+
def test_other_github_workflow(self):
337+
env_variables = compute_projects.get_env_variables(
338+
[".github/workflows/docs.yml"], "Linux"
339+
)
340+
self.assertEqual(env_variables["projects_to_build"], "")
341+
self.assertEqual(env_variables["project_check_targets"], "")
342+
self.assertEqual(env_variables["runtimes_to_build"], "")
343+
self.assertEqual(env_variables["runtimes_check_targets"], "")
344+
self.assertEqual(env_variables["runtimes_check_targets_needs_reconfig"], "")
345+
346+
def test_third_party_benchmark(self):
347+
env_variables = compute_projects.get_env_variables(
348+
["third-party/benchmark/CMakeLists.txt"], "Linux"
349+
)
350+
self.assertEqual(
351+
env_variables["projects_to_build"],
352+
"bolt;clang;clang-tools-extra;flang;libclc;lld;lldb;llvm;mlir;polly",
353+
)
354+
self.assertEqual(
355+
env_variables["project_check_targets"],
356+
"check-bolt check-clang check-clang-cir check-clang-tools check-flang check-lld check-lldb check-llvm check-mlir check-polly",
357+
)
358+
self.assertEqual(
359+
env_variables["runtimes_to_build"],
360+
"compiler-rt;libc;libcxx;libcxxabi;libunwind",
361+
)
362+
self.assertEqual(
363+
env_variables["runtimes_check_targets"],
364+
"check-compiler-rt check-libc",
365+
)
366+
self.assertEqual(
367+
env_variables["runtimes_check_targets_needs_reconfig"],
368+
"check-cxx check-cxxabi check-unwind",
369+
)
370+
266371

267372
if __name__ == "__main__":
268373
unittest.main()

0 commit comments

Comments
 (0)