Skip to content

Commit 1bae34e

Browse files
committed
Merge remote-tracking branch 'origin/main' into vpbundlerecipe
2 parents 201c5d7 + 08964d6 commit 1bae34e

File tree

65 files changed

+698
-173
lines changed

Some content is hidden

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

65 files changed

+698
-173
lines changed

.github/new-prs-labeler.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,10 @@ llvm:instcombine:
632632
- llvm/test/Transforms/InstCombine/**
633633
- llvm/test/Transforms/InstSimplify/**
634634

635+
llvm:vectorcombine:
636+
- llvm/lib/Transforms/Vectorize/VectorCombine.cpp
637+
- llvm/test/Transforms/VectorCombine/**
638+
635639
clangd:
636640
- clang-tools-extra/clangd/**
637641

.github/workflows/libclang-python-tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ on:
1010
- 'main'
1111
paths:
1212
- 'clang/bindings/python/**'
13+
- 'clang/test/bindings/python/**'
1314
- 'clang/tools/libclang/**'
14-
- 'clang/CMakeList.txt'
1515
- '.github/workflows/libclang-python-tests.yml'
1616
- '.github/workflows/llvm-project-tests.yml'
1717
pull_request:
1818
paths:
1919
- 'clang/bindings/python/**'
20+
- 'clang/test/bindings/python/**'
2021
- 'clang/tools/libclang/**'
21-
- 'clang/CMakeList.txt'
2222
- '.github/workflows/libclang-python-tests.yml'
2323
- '.github/workflows/llvm-project-tests.yml'
2424

clang/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,6 @@ if( CLANG_INCLUDE_TESTS )
530530
clang_unit_site_config=${CMAKE_CURRENT_BINARY_DIR}/test/Unit/lit.site.cfg
531531
)
532532
add_subdirectory(test)
533-
add_subdirectory(bindings/python/tests)
534533

535534
if(CLANG_BUILT_STANDALONE)
536535
umbrella_lit_testsuite_end(check-all)

clang/bindings/python/tests/CMakeLists.txt

Lines changed: 0 additions & 66 deletions
This file was deleted.

clang/lib/Sema/SemaChecking.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10805,10 +10805,9 @@ static std::optional<IntRange> TryGetExprRange(ASTContext &C, const Expr *E,
1080510805
return std::nullopt;
1080610806

1080710807
// If the range was previously non-negative, we need an extra bit for the
10808-
// sign bit. If the range was not non-negative, we need an extra bit
10809-
// because the negation of the most-negative value is one bit wider than
10810-
// that value.
10811-
return IntRange(SubRange->Width + 1, false);
10808+
// sign bit. Otherwise, we need an extra bit because the negation of the
10809+
// most-negative value is one bit wider than that value.
10810+
return IntRange(std::min(SubRange->Width + 1, MaxWidth), false);
1081210811
}
1081310812

1081410813
case UO_Not: {
@@ -10825,7 +10824,9 @@ static std::optional<IntRange> TryGetExprRange(ASTContext &C, const Expr *E,
1082510824

1082610825
// The width increments by 1 if the sub-expression cannot be negative
1082710826
// since it now can be.
10828-
return IntRange(SubRange->Width + (int)SubRange->NonNegative, false);
10827+
return IntRange(
10828+
std::min(SubRange->Width + (int)SubRange->NonNegative, MaxWidth),
10829+
false);
1082910830
}
1083010831

1083110832
default:

clang/lib/Sema/SemaHLSL.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ static ResourceClass getResourceClass(RegisterType RT) {
120120
llvm_unreachable("unexpected RegisterType value");
121121
}
122122

123-
static Builtin::ID getSpecConstBuiltinId(QualType Type) {
123+
static Builtin::ID getSpecConstBuiltinId(const Type *Type) {
124124
const auto *BT = dyn_cast<BuiltinType>(Type);
125125
if (!BT) {
126126
if (!Type->isEnumeralType())
@@ -654,7 +654,8 @@ SemaHLSL::mergeVkConstantIdAttr(Decl *D, const AttributeCommonInfo &AL,
654654

655655
auto *VD = cast<VarDecl>(D);
656656

657-
if (getSpecConstBuiltinId(VD->getType()) == Builtin::NotBuiltin) {
657+
if (getSpecConstBuiltinId(VD->getType()->getUnqualifiedDesugaredType()) ==
658+
Builtin::NotBuiltin) {
658659
Diag(VD->getLocation(), diag::err_specialization_const);
659660
return nullptr;
660661
}
@@ -3972,7 +3973,8 @@ bool SemaHLSL::handleInitialization(VarDecl *VDecl, Expr *&Init) {
39723973
return false;
39733974
}
39743975

3975-
Builtin::ID BID = getSpecConstBuiltinId(VDecl->getType());
3976+
Builtin::ID BID =
3977+
getSpecConstBuiltinId(VDecl->getType()->getUnqualifiedDesugaredType());
39763978

39773979
// Argument 1: The ID from the attribute
39783980
int ConstantID = ConstIdAttr->getId();

clang/test/AST/HLSL/vk.spec-constant.usage.hlsl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,17 @@ const unsigned short ushort_const = 10;
6464
[[vk::constant_id(6)]]
6565
const unsigned int uint_const = 12;
6666

67+
// CHECK: VarDecl {{.*}} uint_const_2 'const hlsl_private uint':'const hlsl_private unsigned int' static cinit
68+
// CHECK-NEXT: CallExpr {{.*}} 'unsigned int'
69+
// CHECK-NEXT: ImplicitCastExpr {{.*}} 'unsigned int (*)(unsigned int, unsigned int) noexcept' <FunctionToPointerDecay>
70+
// CHECK-NEXT: DeclRefExpr {{.*}} 'unsigned int (unsigned int, unsigned int) noexcept' lvalue Function {{.*}} '__builtin_get_spirv_spec_constant_uint' 'unsigned int (unsigned int, unsigned int) noexcept'
71+
// CHECK-NEXT: ImplicitCastExpr {{.*}} 'unsigned int' <IntegralCast>
72+
// CHECK-NEXT: IntegerLiteral {{.*}} 'int' 6
73+
// CHECK-NEXT: ImplicitCastExpr {{.*}} 'unsigned int' <IntegralCast>
74+
// CHECK-NEXT: IntegerLiteral {{.*}} 'int' 12
75+
[[vk::constant_id(6)]]
76+
const uint uint_const_2 = 12;
77+
6778

6879
// CHECK: VarDecl {{.*}} ulong_const 'const hlsl_private unsigned long long' static cinit
6980
// CHECK-NEXT: CallExpr {{.*}} 'unsigned long long'

clang/test/CMakeLists.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,17 @@ add_custom_target(clang-test)
205205
add_dependencies(clang-test check-clang)
206206
set_target_properties(clang-test PROPERTIES FOLDER "Clang/Tests")
207207

208+
# Allow running Clang Python binding tests separately from CI.
209+
add_lit_testsuite(check-clang-python "Running the Clang Python tests"
210+
${CMAKE_CURRENT_BINARY_DIR}
211+
#LIT ${LLVM_LIT}
212+
PARAMS ${CLANG_TEST_PARAMS}
213+
DEPENDS ${CLANG_TEST_DEPS}
214+
ARGS ${CLANG_TEST_EXTRA_ARGS} --filter=bindings.sh
215+
# Avoid running tests twice.
216+
EXCLUDE_FROM_CHECK_ALL
217+
)
218+
208219
# FIXME: This logic can be removed once all buildbots have moved
209220
# debuginfo-test from clang/test to llvm/projects or monorepo.
210221
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/debuginfo-tests)

clang/test/CodeGenHLSL/vk-features/vk.spec-constant.hlsl

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ const unsigned short ushort_const = 10;
2121
[[vk::constant_id(6)]]
2222
const unsigned int uint_const = 12;
2323

24+
[[vk::constant_id(6)]]
25+
const uint uint_const_2 = 12;
26+
2427
[[vk::constant_id(7)]]
2528
const unsigned long long ulong_const = 25;
2629

@@ -50,6 +53,7 @@ void main() {
5053
long long l = long_const;
5154
unsigned short us = ushort_const;
5255
unsigned int ui = uint_const;
56+
uint ui2 = uint_const_2;
5357
unsigned long long ul = ulong_const;
5458
half h = half_const;
5559
float f = float_const;
@@ -63,6 +67,7 @@ void main() {
6367
// CHECK: @_ZL10long_const = internal addrspace(10) global i64 0, align 8
6468
// CHECK: @_ZL12ushort_const = internal addrspace(10) global i16 0, align 2
6569
// CHECK: @_ZL10uint_const = internal addrspace(10) global i32 0, align 4
70+
// CHECK: @_ZL12uint_const_2 = internal addrspace(10) global i32 0, align 4
6671
// CHECK: @_ZL11ulong_const = internal addrspace(10) global i64 0, align 8
6772
// CHECK: @_ZL10half_const = internal addrspace(10) global float 0.000000e+00, align 4
6873
// CHECK: @_ZL11float_const = internal addrspace(10) global float 0.000000e+00, align 4
@@ -79,6 +84,7 @@ void main() {
7984
// CHECK-NEXT: [[L:%.*]] = alloca i64, align 8
8085
// CHECK-NEXT: [[US:%.*]] = alloca i16, align 2
8186
// CHECK-NEXT: [[UI:%.*]] = alloca i32, align 4
87+
// CHECK-NEXT: [[UI2:%.*]] = alloca i32, align 4
8288
// CHECK-NEXT: [[UL:%.*]] = alloca i64, align 8
8389
// CHECK-NEXT: [[H:%.*]] = alloca float, align 4
8490
// CHECK-NEXT: [[F:%.*]] = alloca float, align 4
@@ -98,16 +104,18 @@ void main() {
98104
// CHECK-NEXT: store i16 [[TMP5]], ptr [[US]], align 2
99105
// CHECK-NEXT: [[TMP6:%.*]] = load i32, ptr addrspace(10) @_ZL10uint_const, align 4
100106
// CHECK-NEXT: store i32 [[TMP6]], ptr [[UI]], align 4
101-
// CHECK-NEXT: [[TMP7:%.*]] = load i64, ptr addrspace(10) @_ZL11ulong_const, align 8
102-
// CHECK-NEXT: store i64 [[TMP7]], ptr [[UL]], align 8
103-
// CHECK-NEXT: [[TMP8:%.*]] = load float, ptr addrspace(10) @_ZL10half_const, align 4
104-
// CHECK-NEXT: store float [[TMP8]], ptr [[H]], align 4
105-
// CHECK-NEXT: [[TMP9:%.*]] = load float, ptr addrspace(10) @_ZL11float_const, align 4
106-
// CHECK-NEXT: store float [[TMP9]], ptr [[F]], align 4
107-
// CHECK-NEXT: [[TMP10:%.*]] = load double, ptr addrspace(10) @_ZL12double_const, align 8
108-
// CHECK-NEXT: store double [[TMP10]], ptr [[D]], align 8
109-
// CHECK-NEXT: [[TMP11:%.*]] = load i32, ptr addrspace(10) @_ZL10enum_const, align 4
110-
// CHECK-NEXT: store i32 [[TMP11]], ptr [[E]], align 4
107+
// CHECK-NEXT: [[TMP7:%.*]] = load i32, ptr addrspace(10) @_ZL12uint_const_2, align 4
108+
// CHECK-NEXT: store i32 [[TMP7]], ptr [[UI2]], align 4
109+
// CHECK-NEXT: [[TMP8:%.*]] = load i64, ptr addrspace(10) @_ZL11ulong_const, align 8
110+
// CHECK-NEXT: store i64 [[TMP8]], ptr [[UL]], align 8
111+
// CHECK-NEXT: [[TMP9:%.*]] = load float, ptr addrspace(10) @_ZL10half_const, align 4
112+
// CHECK-NEXT: store float [[TMP9]], ptr [[H]], align 4
113+
// CHECK-NEXT: [[TMP10:%.*]] = load float, ptr addrspace(10) @_ZL11float_const, align 4
114+
// CHECK-NEXT: store float [[TMP10]], ptr [[F]], align 4
115+
// CHECK-NEXT: [[TMP11:%.*]] = load double, ptr addrspace(10) @_ZL12double_const, align 8
116+
// CHECK-NEXT: store double [[TMP11]], ptr [[D]], align 8
117+
// CHECK-NEXT: [[TMP12:%.*]] = load i32, ptr addrspace(10) @_ZL10enum_const, align 4
118+
// CHECK-NEXT: store i32 [[TMP12]], ptr [[E]], align 4
111119
// CHECK-NEXT: ret void
112120
//
113121
// CHECK-LABEL: define internal spir_func void @__cxx_global_var_init(
@@ -169,12 +177,21 @@ void main() {
169177
// CHECK-SAME: ) #[[ATTR3]] {
170178
// CHECK-NEXT: [[ENTRY:.*:]]
171179
// CHECK-NEXT: [[TMP0:%.*]] = call token @llvm.experimental.convergence.entry()
180+
// CHECK-NEXT: [[TMP1:%.*]] = call i32 @_Z20__spirv_SpecConstantij(i32 6, i32 12)
181+
// CHECK-NEXT: store i32 [[TMP1]], ptr addrspace(10) @_ZL12uint_const_2, align 4
182+
// CHECK-NEXT: ret void
183+
//
184+
//
185+
// CHECK-LABEL: define internal spir_func void @__cxx_global_var_init.7(
186+
// CHECK-SAME: ) #[[ATTR3]] {
187+
// CHECK-NEXT: [[ENTRY:.*:]]
188+
// CHECK-NEXT: [[TMP0:%.*]] = call token @llvm.experimental.convergence.entry()
172189
// CHECK-NEXT: [[TMP1:%.*]] = call i64 @_Z20__spirv_SpecConstantiy(i32 7, i64 25)
173190
// CHECK-NEXT: store i64 [[TMP1]], ptr addrspace(10) @_ZL11ulong_const, align 8
174191
// CHECK-NEXT: ret void
175192
//
176193
//
177-
// CHECK-LABEL: define internal spir_func void @__cxx_global_var_init.7(
194+
// CHECK-LABEL: define internal spir_func void @__cxx_global_var_init.8(
178195
// CHECK-SAME: ) #[[ATTR3]] {
179196
// CHECK-NEXT: [[ENTRY:.*:]]
180197
// CHECK-NEXT: [[TMP0:%.*]] = call token @llvm.experimental.convergence.entry()
@@ -183,7 +200,7 @@ void main() {
183200
// CHECK-NEXT: ret void
184201
//
185202
//
186-
// CHECK-LABEL: define internal spir_func void @__cxx_global_var_init.8(
203+
// CHECK-LABEL: define internal spir_func void @__cxx_global_var_init.9(
187204
// CHECK-SAME: ) #[[ATTR3]] {
188205
// CHECK-NEXT: [[ENTRY:.*:]]
189206
// CHECK-NEXT: [[TMP0:%.*]] = call token @llvm.experimental.convergence.entry()
@@ -192,7 +209,7 @@ void main() {
192209
// CHECK-NEXT: ret void
193210
//
194211
//
195-
// CHECK-LABEL: define internal spir_func void @__cxx_global_var_init.9(
212+
// CHECK-LABEL: define internal spir_func void @__cxx_global_var_init.10(
196213
// CHECK-SAME: ) #[[ATTR3]] {
197214
// CHECK-NEXT: [[ENTRY:.*:]]
198215
// CHECK-NEXT: [[TMP0:%.*]] = call token @llvm.experimental.convergence.entry()
@@ -201,7 +218,7 @@ void main() {
201218
// CHECK-NEXT: ret void
202219
//
203220
//
204-
// CHECK-LABEL: define internal spir_func void @__cxx_global_var_init.10(
221+
// CHECK-LABEL: define internal spir_func void @__cxx_global_var_init.11(
205222
// CHECK-SAME: ) #[[ATTR3]] {
206223
// CHECK-NEXT: [[ENTRY:.*:]]
207224
// CHECK-NEXT: [[TMP0:%.*]] = call token @llvm.experimental.convergence.entry()

clang/test/Sema/implicit-int-conversion-on-int.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,11 @@ unsigned long long test_ull(unsigned long long x) {
4848
unsigned _BitInt(16) test_unsigned_bit_int(unsigned _BitInt(16) x) {
4949
return -x;
5050
}
51+
52+
unsigned test_shift_minus(int i) {
53+
return -(1 << i);
54+
}
55+
56+
unsigned test_shift_not(int i) {
57+
return ~(1 << i);
58+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/sh
2+
3+
# UNSUPPORTED: !libclang-loadable
4+
5+
# Tests fail on Windows, and need someone knowledgeable to fix.
6+
# It's not clear whether it's a test or a valid binding problem.
7+
# XFAIL: target={{.*windows.*}}
8+
9+
# The Python FFI interface is broken on AIX: https://bugs.python.org/issue38628.
10+
# XFAIL: target={{.*-aix.*}}
11+
12+
# Hexagon has known test failures that need to be addressed.
13+
# SystemZ has broken Python/FFI interface:
14+
# https://reviews.llvm.org/D52840#1265716
15+
# XFAIL: target={{(hexagon|s390x)-.*}}
16+
# python SEGVs on Linux/sparc64 when loading libclang.so. Seems to be an FFI
17+
# issue, too.
18+
# XFAIL: target={{sparc.*-.*-linux.*}}
19+
20+
# Tests will fail if cross-compiling for a different target, as tests will try
21+
# to use the host Python3_EXECUTABLE and make FFI calls to functions in target
22+
# libraries.
23+
#
24+
# FIXME: Consider a solution that allows better control over these tests in
25+
# a crosscompiling scenario. e.g. registering them with lit to allow them to
26+
# be explicitly skipped via appropriate LIT_ARGS, or adding a mechanism to
27+
# allow specifying a python interpreter compiled for the target that could
28+
# be executed using qemu-user.
29+
# XFAIL: !native
30+
31+
# RUN: env PYTHONPATH=%S/../../../bindings/python \
32+
# RUN: CLANG_LIBRARY_PATH=%libdir \
33+
# RUN: %python -m unittest discover -s %S/tests
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
def is_libclang_loadable():
2+
# Do not try to run if libclang was built with sanitizers because
3+
# the sanitizer library will likely be loaded too late to perform
4+
# interception and will then fail.
5+
# We could use LD_PRELOAD/DYLD_INSERT_LIBRARIES but this isn't
6+
# portable so its easier just to not run the tests when building
7+
# with ASan.
8+
if config.llvm_use_sanitizer != "":
9+
return False
10+
try:
11+
sys.path.append(os.path.join(config.clang_src_dir, "bindings/python"))
12+
from clang.cindex import Config
13+
conf = Config()
14+
Config.set_library_path(config.clang_lib_dir)
15+
conf.lib
16+
return True
17+
except Exception as e:
18+
# Expected failure modes are considered benign when nothing can be
19+
# done about them.
20+
#
21+
# Cannot load a 32-bit libclang.so into a 64-bit python.
22+
if "wrong ELF class: ELFCLASS32" in str(e):
23+
return False
24+
# If libclang.so is missing, it must have been disabled intentionally,
25+
# e.g. by building with LLVM_ENABLE_PIC=OFF.
26+
elif "No such file or directory" in str(e):
27+
return False
28+
# Unexpected failure modes need to be investigated to either fix an
29+
# underlying bug or accept the failure, so return True. This causes
30+
# tests to run and FAIL, drawing developer attention.
31+
else:
32+
print("warning: unhandled failure in is_libclang_loadable: "
33+
+ str(e), file=sys.stderr)
34+
return True
35+
36+
if is_libclang_loadable():
37+
config.available_features.add("libclang-loadable")
38+
39+
config.substitutions.append(('%libdir', config.clang_lib_dir))
40+
41+
config.suffixes = ['.sh']

0 commit comments

Comments
 (0)