Skip to content

Commit 7e94a3c

Browse files
authored
Merge branch 'main' into p/libc-dlfcn
2 parents f6ff1de + f295617 commit 7e94a3c

File tree

210 files changed

+5403
-1651
lines changed

Some content is hidden

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

210 files changed

+5403
-1651
lines changed

.ci/compute_projects.py

Lines changed: 19 additions & 0 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"},
@@ -55,6 +56,7 @@
5556
".ci": {
5657
"llvm",
5758
"clang",
59+
"CIR",
5860
"lld",
5961
"lldb",
6062
"bolt",
@@ -128,6 +130,7 @@
128130
"lldb": "check-lldb",
129131
"llvm": "check-llvm",
130132
"clang": "check-clang",
133+
"CIR": "check-clang-cir",
131134
"bolt": "check-bolt",
132135
"lld": "check-lld",
133136
"flang": "check-flang",
@@ -247,6 +250,14 @@ def _get_modified_projects(modified_files: list[str]) -> Set[str]:
247250
# capacity.
248251
if len(path_parts) > 3 and path_parts[:3] == ("llvm", "utils", "gn"):
249252
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.
250261
modified_projects.add(pathlib.Path(modified_file).parts[0])
251262
return modified_projects
252263

@@ -267,6 +278,13 @@ def get_env_variables(modified_files: list[str], platform: str) -> Set[str]:
267278
runtimes_check_targets_needs_reconfig = _compute_project_check_targets(
268279
runtimes_to_test_needs_reconfig
269280
)
281+
282+
# CIR is used as a pseudo-project in this script. It is built as part of the
283+
# clang build, but it requires an explicit option to enable. We set that
284+
# option here, and remove it from the projects_to_build list.
285+
enable_cir = "ON" if "CIR" in projects_to_build else "OFF"
286+
projects_to_build.discard("CIR")
287+
270288
# We use a semicolon to separate the projects/runtimes as they get passed
271289
# to the CMake invocation and thus we need to use the CMake list separator
272290
# (;). We use spaces to separate the check targets as they end up getting
@@ -279,6 +297,7 @@ def get_env_variables(modified_files: list[str], platform: str) -> Set[str]:
279297
"runtimes_check_targets_needs_reconfig": " ".join(
280298
sorted(runtimes_check_targets_needs_reconfig)
281299
),
300+
"enable_cir": enable_cir,
282301
}
283302

284303

.ci/compute_projects_test.py

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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,6 +199,7 @@ 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(
@@ -237,7 +269,7 @@ def test_ci(self):
237269
)
238270
self.assertEqual(
239271
env_variables["project_check_targets"],
240-
"check-bolt check-clang check-clang-tools check-flang check-lld check-lldb check-llvm check-mlir check-polly",
272+
"check-bolt check-clang check-clang-cir check-clang-tools check-flang check-lld check-lldb check-llvm check-mlir check-polly",
241273
)
242274
self.assertEqual(
243275
env_variables["runtimes_to_build"],

.ci/monolithic-linux.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ targets="${2}"
4848
runtimes="${3}"
4949
runtime_targets="${4}"
5050
runtime_targets_needs_reconfig="${5}"
51+
enable_cir="${6}"
5152

5253
lit_args="-v --xunit-xml-output ${BUILD_DIR}/test-results.xml --use-unique-output-file-name --timeout=1200 --time-tests"
5354

@@ -67,6 +68,7 @@ cmake -S "${MONOREPO_ROOT}"/llvm -B "${BUILD_DIR}" \
6768
-G Ninja \
6869
-D CMAKE_PREFIX_PATH="${HOME}/.local" \
6970
-D CMAKE_BUILD_TYPE=Release \
71+
-D CLANG_ENABLE_CIR=${enable_cir} \
7072
-D LLVM_ENABLE_ASSERTIONS=ON \
7173
-D LLVM_BUILD_EXAMPLES=ON \
7274
-D COMPILER_RT_BUILD_LIBFUZZER=OFF \

.github/workflows/premerge.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ jobs:
6262
export CC=/opt/llvm/bin/clang
6363
export CXX=/opt/llvm/bin/clang++
6464
65-
./.ci/monolithic-linux.sh "${projects_to_build}" "${project_check_targets}" "${runtimes_to_build}" "${runtimes_check_targets}" "${runtimes_check_targets_needs_reconfig}"
65+
./.ci/monolithic-linux.sh "${projects_to_build}" "${project_check_targets}" "${runtimes_to_build}" "${runtimes_check_targets}" "${runtimes_check_targets_needs_reconfig}" "${enable_cir}"
6666
- name: Upload Artifacts
6767
if: '!cancelled()'
6868
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0

clang/docs/LibClang.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,3 +404,9 @@ following situations are explicitly unsupported:
404404
compatible across library versions.
405405
* For the same reason as above, serializing objects from one version of the
406406
library and deserializing with a different version is also not supported.
407+
408+
Note: because libclang is a wrapper around the compiler frontend, it is not a
409+
`security-sensitive component`_ of the LLVM Project. Consider using a sandbox
410+
or some other mitigation approach if processing untrusted input.
411+
412+
.. _security-sensitive component: https://llvm.org/docs/Security.html#what-is-considered-a-security-issue

clang/include/clang/Basic/BuiltinsAMDGPU.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -675,6 +675,7 @@ TARGET_BUILTIN(__builtin_amdgcn_rsq_bf16, "yy", "nc", "bf16-trans-insts")
675675
TARGET_BUILTIN(__builtin_amdgcn_log_bf16, "yy", "nc", "bf16-trans-insts")
676676
TARGET_BUILTIN(__builtin_amdgcn_exp2_bf16, "yy", "nc", "bf16-trans-insts")
677677
TARGET_BUILTIN(__builtin_amdgcn_sin_bf16, "yy", "nc", "bf16-trans-insts")
678+
TARGET_BUILTIN(__builtin_amdgcn_cos_bf16, "yy", "nc", "bf16-trans-insts")
678679

679680
TARGET_BUILTIN(__builtin_amdgcn_cvt_f16_fp8, "hiIi", "nc", "gfx1250-insts")
680681
TARGET_BUILTIN(__builtin_amdgcn_cvt_f16_bf8, "hiIi", "nc", "gfx1250-insts")

clang/lib/CodeGen/TargetBuiltins/AMDGPU.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,7 @@ Value *CodeGenFunction::EmitAMDGPUBuiltinExpr(unsigned BuiltinID,
433433
return emitBuiltinWithOneOverloadedType<1>(*this, E, Intrinsic::amdgcn_sin);
434434
case AMDGPU::BI__builtin_amdgcn_cosf:
435435
case AMDGPU::BI__builtin_amdgcn_cosh:
436+
case AMDGPU::BI__builtin_amdgcn_cos_bf16:
436437
return emitBuiltinWithOneOverloadedType<1>(*this, E, Intrinsic::amdgcn_cos);
437438
case AMDGPU::BI__builtin_amdgcn_dispatch_ptr:
438439
return EmitAMDGPUDispatchPtr(*this, E);

clang/test/CodeGenOpenCL/builtins-amdgcn-gfx1250.cl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,25 @@ void test_sin_bf16(global __bf16* out, __bf16 a)
156156
*out = __builtin_amdgcn_sin_bf16(a);
157157
}
158158

159+
// CHECK-LABEL: @test_cos_bf16(
160+
// CHECK-NEXT: entry:
161+
// CHECK-NEXT: [[OUT_ADDR:%.*]] = alloca ptr addrspace(1), align 8, addrspace(5)
162+
// CHECK-NEXT: [[A_ADDR:%.*]] = alloca bfloat, align 2, addrspace(5)
163+
// CHECK-NEXT: [[OUT_ADDR_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[OUT_ADDR]] to ptr
164+
// CHECK-NEXT: [[A_ADDR_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[A_ADDR]] to ptr
165+
// CHECK-NEXT: store ptr addrspace(1) [[OUT:%.*]], ptr [[OUT_ADDR_ASCAST]], align 8
166+
// CHECK-NEXT: store bfloat [[A:%.*]], ptr [[A_ADDR_ASCAST]], align 2
167+
// CHECK-NEXT: [[TMP0:%.*]] = load bfloat, ptr [[A_ADDR_ASCAST]], align 2
168+
// CHECK-NEXT: [[TMP1:%.*]] = call bfloat @llvm.amdgcn.cos.bf16(bfloat [[TMP0]])
169+
// CHECK-NEXT: [[TMP2:%.*]] = load ptr addrspace(1), ptr [[OUT_ADDR_ASCAST]], align 8
170+
// CHECK-NEXT: store bfloat [[TMP1]], ptr addrspace(1) [[TMP2]], align 2
171+
// CHECK-NEXT: ret void
172+
//
173+
void test_cos_bf16(global __bf16* out, __bf16 a)
174+
{
175+
*out = __builtin_amdgcn_cos_bf16(a);
176+
}
177+
159178
// CHECK-LABEL: @test_cvt_f16_fp8(
160179
// CHECK-NEXT: entry:
161180
// CHECK-NEXT: [[OUT_ADDR:%.*]] = alloca ptr addrspace(1), align 8, addrspace(5)

compiler-rt/lib/tysan/lit.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ config.substitutions.append( ("%clangxx_tysan ", build_invocation(clang_tysan_cx
2727
config.suffixes = ['.c', '.cc', '.cpp']
2828

2929
# TypeSanitizer tests are currently supported on Linux only.
30-
if config.host_os not in ['Linux']:
30+
if config.target_os not in ['Linux']:
3131
config.unsupported = True
3232

3333
if config.target_arch != 'aarch64':

compiler-rt/test/asan/lit.cfg.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def get_required_attr(config, attr_name):
2828
# tests to prevent regressions.
2929
# Currently, detect_leaks for asan tests only work on Intel MacOS.
3030
if (
31-
config.host_os == "Darwin"
31+
config.target_os == "Darwin"
3232
and config.apple_platform == "osx"
3333
and config.target_arch == "x86_64"
3434
):
@@ -45,7 +45,7 @@ def get_required_attr(config, attr_name):
4545
# Setup source root.
4646
config.test_source_root = os.path.dirname(__file__)
4747

48-
if config.host_os not in ["FreeBSD", "NetBSD"]:
48+
if config.target_os not in ["FreeBSD", "NetBSD"]:
4949
libdl_flag = "-ldl"
5050
else:
5151
libdl_flag = ""
@@ -125,17 +125,17 @@ def build_invocation(compile_flags, with_lto=False):
125125
("%clangxx_asan_lto ", build_invocation(clang_asan_cxxflags, True))
126126
)
127127
if config.asan_dynamic:
128-
if config.host_os in ["Linux", "FreeBSD", "NetBSD", "SunOS"]:
128+
if config.target_os in ["Linux", "FreeBSD", "NetBSD", "SunOS"]:
129129
shared_libasan_path = os.path.join(
130130
config.compiler_rt_libdir,
131131
"libclang_rt.asan{}.so".format(config.target_suffix),
132132
)
133-
elif config.host_os == "Darwin":
133+
elif config.target_os == "Darwin":
134134
shared_libasan_path = os.path.join(
135135
config.compiler_rt_libdir,
136136
"libclang_rt.asan_{}_dynamic.dylib".format(config.apple_platform),
137137
)
138-
elif config.host_os == "Windows":
138+
elif config.target_os == "Windows":
139139
shared_libasan_path = os.path.join(
140140
config.compiler_rt_libdir,
141141
"clang_rt.asan_dynamic-{}.lib".format(config.target_suffix),
@@ -274,16 +274,16 @@ def build_invocation(compile_flags, with_lto=False):
274274
and (config.target_arch in ["x86_64", "i386", "i686", "aarch64"])
275275
)
276276
leak_detection_linux = (
277-
(config.host_os == "Linux")
277+
(config.target_os == "Linux")
278278
and (not config.android)
279279
and (config.target_arch in ["x86_64", "i386", "riscv64", "loongarch64"])
280280
)
281281
leak_detection_mac = (
282-
(config.host_os == "Darwin")
282+
(config.target_os == "Darwin")
283283
and (config.apple_platform == "osx")
284284
and (config.target_arch == "x86_64")
285285
)
286-
leak_detection_netbsd = (config.host_os == "NetBSD") and (
286+
leak_detection_netbsd = (config.target_os == "NetBSD") and (
287287
config.target_arch in ["x86_64", "i386"]
288288
)
289289
if (
@@ -296,7 +296,7 @@ def build_invocation(compile_flags, with_lto=False):
296296

297297
# Add the RT libdir to PATH directly so that we can successfully run the gtest
298298
# binary to list its tests.
299-
if config.host_os == "Windows":
299+
if config.target_os == "Windows":
300300
os.environ["PATH"] = os.path.pathsep.join(
301301
[config.compiler_rt_libdir, os.environ.get("PATH", "")]
302302
)
@@ -310,10 +310,10 @@ def build_invocation(compile_flags, with_lto=False):
310310
# Default test suffixes.
311311
config.suffixes = [".c", ".cpp"]
312312

313-
if config.host_os == "Darwin":
313+
if config.target_os == "Darwin":
314314
config.suffixes.append(".mm")
315315

316-
if config.host_os == "Windows":
316+
if config.target_os == "Windows":
317317
config.substitutions.append(("%fPIC", ""))
318318
config.substitutions.append(("%fPIE", ""))
319319
config.substitutions.append(("%pie", ""))
@@ -323,11 +323,11 @@ def build_invocation(compile_flags, with_lto=False):
323323
config.substitutions.append(("%pie", "-pie"))
324324

325325
# Only run the tests on supported OSs.
326-
if config.host_os not in ["Linux", "Darwin", "FreeBSD", "SunOS", "Windows", "NetBSD"]:
326+
if config.target_os not in ["Linux", "Darwin", "FreeBSD", "SunOS", "Windows", "NetBSD"]:
327327
config.unsupported = True
328328

329329
if not config.parallelism_group:
330330
config.parallelism_group = "shadow-memory"
331331

332-
if config.host_os == "NetBSD":
332+
if config.target_os == "NetBSD":
333333
config.substitutions.insert(0, ("%run", config.netbsd_noaslr_prefix))

0 commit comments

Comments
 (0)