diff --git a/src/CodeGen_Hexagon.cpp b/src/CodeGen_Hexagon.cpp index c680fdb1a82e..fa194c6d2c91 100644 --- a/src/CodeGen_Hexagon.cpp +++ b/src/CodeGen_Hexagon.cpp @@ -1025,6 +1025,23 @@ Value *CodeGen_Hexagon::interleave_vectors(const vector &v) { int native_elements = native_vector_bits() / element_ty->getScalarSizeInBits(); int result_elements = get_vector_num_elements(v_ty) * v.size(); + if (element_bits == 1) { + // If this is a vector of booleans, convert it to a vector of bytes, + // interleave that, and convert back. This avoids routing predicate + // (mask) vectors through the vdelta-based byte shuffle network + // below, which assumes native-vector-sized byte data: small, + // sub-native-width concatenations of predicates (as produced here + // when the number of lanes is much smaller than a native HVX + // vector) can trip up LLVM's Hexagon backend during DAG combining. + vector i8_v(v.size()); + for (size_t i = 0; i < v.size(); i++) { + llvm::Type *i8_ty = get_vector_type(i8_t, get_vector_num_elements(v[i]->getType())); + i8_v[i] = builder->CreateIntCast(v[i], i8_ty, true); + } + Value *result = interleave_vectors(i8_v); + llvm::Type *result_ty = get_vector_type(element_ty, result_elements); + return builder->CreateIntCast(result, result_ty, true); + } if (v.size() == 2) { // Interleaving two vectors. Value *a = v[0]; diff --git a/src/JITModule.cpp b/src/JITModule.cpp index 4bdba15bdf25..1cf7ba1c141c 100644 --- a/src/JITModule.cpp +++ b/src/JITModule.cpp @@ -448,7 +448,21 @@ void compile_module_impl( dtorRunner->add(dtors); // Resolve system symbols (like pthread, dl and others) +#if defined(__GNUC__) && !defined(__clang__) + // GCC's -Wuninitialized/-Wmaybe-uninitialized misfires on the move + // constructor of the default-constructed llvm::unique_function + // (AddAbsoluteSymbolsFn) that GetForCurrentProcess() takes by default + // argument, after LLVM's unique_function was refactored upstream + // (llvm/llvm-project#208251). Which of the two warnings fires depends + // on the GCC version, so both are silenced here. +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wuninitialized" +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" +#endif auto gen = llvm::orc::DynamicLibrarySearchGenerator::GetForCurrentProcess(target_data_layout.getGlobalPrefix()); +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC diagnostic pop +#endif internal_assert(gen) << llvm::toString(gen.takeError()) << "\n"; JIT->getMainJITDylib().addGenerator(std::move(gen.get())); diff --git a/test/fuzz/lossless_cast.cpp b/test/fuzz/lossless_cast.cpp index 01ef1c38e8d7..cca4047ae5ed 100644 --- a/test/fuzz/lossless_cast.cpp +++ b/test/fuzz/lossless_cast.cpp @@ -267,27 +267,46 @@ FUZZ_TEST(lossless_cast, FuzzingContext &fuzz) { buf_u8.fill(fuzz); buf_i8.fill(fuzz); - Expr e1 = random_expr(fuzz); - Expr simplified = simplify(e1); + // random_expr() can produce deeply-nested expressions, and simplify(), + // lower_intrinsics(), and friends visit them recursively. Unlike the + // Pipeline lowering/codegen path (which already runs on a large stack + // via Internal::run_with_large_stack), these calls would otherwise run + // directly on the calling thread's stack, which can be too small on + // some CI configurations. + Expr e1, e2; + ConstantInterval bounds; + bool skip = false; + bool has_ub = false; + run_with_large_stack([&]() { + e1 = random_expr(fuzz); + Expr simplified = simplify(e1); + + if (might_have_ub(e1) || + might_have_ub(simplified) || + might_have_ub(lower_intrinsics(simplified))) { + skip = true; + return; + } - if (might_have_ub(e1) || - might_have_ub(simplified) || - might_have_ub(lower_intrinsics(simplified))) { - return 0; - } + // We're also going to test constant_integer_bounds here. + bounds = constant_integer_bounds(e1); - // We're also going to test constant_integer_bounds here. - ConstantInterval bounds = constant_integer_bounds(e1); + std::vector target_types = {UInt(32), Int(32), UInt(16), Int(16)}; + Type target = fuzz.PickValueInVector(target_types); + e2 = lossless_cast(target, e1); + if (!e2.defined()) { + skip = true; + return; + } - std::vector target_types = {UInt(32), Int(32), UInt(16), Int(16)}; - Type target = fuzz.PickValueInVector(target_types); - Expr e2 = lossless_cast(target, e1); + has_ub = definitely_has_ub(e2); + }); - if (!e2.defined()) { + if (skip) { return 0; } - if (definitely_has_ub(e2)) { + if (has_ub) { std::cerr << "lossless_cast introduced ub:\n" << "e1 = " << e1 << "\n" << "e2 = " << e2 << "\n" diff --git a/uv.lock b/uv.lock index 7cc651765b49..625f0f7800c9 100644 --- a/uv.lock +++ b/uv.lock @@ -178,7 +178,7 @@ ci-llvm-22 = [ ] ci-llvm-main = [ { name = "cmake" }, - { name = "halide-llvm", version = "23.0.0.dev95984+gbaa69e92", source = { registry = "https://pypi.halide-lang.org/simple" } }, + { name = "halide-llvm", version = "23.0.0.dev100667+g9bf20bdf", source = { registry = "https://pypi.halide-lang.org/simple" } }, { name = "ninja" }, { name = "onnx", marker = "platform_machine != 'armv7l' and platform_machine != 'armv8l'" }, { name = "pre-commit" }, @@ -346,7 +346,7 @@ wheels = [ [[package]] name = "halide-llvm" -version = "23.0.0.dev95984+gbaa69e92" +version = "23.0.0.dev100667+g9bf20bdf" source = { registry = "https://pypi.halide-lang.org/simple" } resolution-markers = [ "(python_full_version >= '3.11' and platform_machine == 'armv7l' and sys_platform != 'armv7l' and sys_platform != 'armv8l') or (python_full_version >= '3.11' and platform_machine == 'armv8l' and sys_platform != 'armv7l' and sys_platform != 'armv8l')", @@ -363,14 +363,14 @@ resolution-markers = [ "(python_full_version < '3.11' and platform_machine != 'armv7l' and platform_machine != 'armv8l' and sys_platform == 'armv7l') or (python_full_version < '3.11' and platform_machine != 'armv7l' and platform_machine != 'armv8l' and sys_platform == 'armv8l')", ] wheels = [ - { url = "https://pypi.halide-lang.org/packages/halide_llvm-23.0.0.dev95984+gbaa69e92-py3-none-macosx_11_0_arm64.whl", hash = "sha256:6e20a00865c98086bc132dc1f6963a882d6dfc858a435728835fb6396c220752" }, - { url = "https://pypi.halide-lang.org/packages/halide_llvm-23.0.0.dev95984+gbaa69e92-py3-none-macosx_11_0_x86_64.whl", hash = "sha256:431e97802719a2713fb07c7519e9c85d2ae3322087e46350284ae454b0b1cd4a" }, - { url = "https://pypi.halide-lang.org/packages/halide_llvm-23.0.0.dev95984+gbaa69e92-py3-none-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:96a2bc0f893b643c9f4aa5324d305628101d7ef29e549ca974fccb1bd9ee1fbf" }, - { url = "https://pypi.halide-lang.org/packages/halide_llvm-23.0.0.dev95984+gbaa69e92-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:968aefab0d44587509029b1070d2ef84ff096faff42702cbac511a6fbfb7e08c" }, - { url = "https://pypi.halide-lang.org/packages/halide_llvm-23.0.0.dev95984+gbaa69e92-py3-none-manylinux_2_28_i686.whl", hash = "sha256:00778ea8b791318a1b5d9225c6c39b429e4d6f37128414b74d073cf986144c87" }, - { url = "https://pypi.halide-lang.org/packages/halide_llvm-23.0.0.dev95984+gbaa69e92-py3-none-manylinux_2_31_armv7l.whl", hash = "sha256:73c69bd047bf2be695e16f1564a2f6f723d43b27b0483ec2eb47879300716582" }, - { url = "https://pypi.halide-lang.org/packages/halide_llvm-23.0.0.dev95984+gbaa69e92-py3-none-win32.whl", hash = "sha256:afafbaceb5f633e3c5efbf41a7b5cbf78cbcbe36d627b62eeca0fcbf9465f2e5" }, - { url = "https://pypi.halide-lang.org/packages/halide_llvm-23.0.0.dev95984+gbaa69e92-py3-none-win_amd64.whl", hash = "sha256:9c87f8dc2f415b86de17c3873a6662174b59aa7bc14374d2fe1fb4f0112482b2" }, + { url = "https://pypi.halide-lang.org/packages/halide_llvm-23.0.0.dev100667+g9bf20bdf-py3-none-macosx_11_0_arm64.whl", hash = "sha256:bc6ecef649b0eeb2d9b5827e8664652d6722ffe4ee98bac3febd3e223629d0d0" }, + { url = "https://pypi.halide-lang.org/packages/halide_llvm-23.0.0.dev100667+g9bf20bdf-py3-none-macosx_11_0_x86_64.whl", hash = "sha256:0fc4450b99b599300ff0088ed798082e1c7129e72a71a55a7ed29fd942d15886" }, + { url = "https://pypi.halide-lang.org/packages/halide_llvm-23.0.0.dev100667+g9bf20bdf-py3-none-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:0c00ff01a0c1b43e321cf0491d70d568868c65dc738d59ba054df550b36de6f1" }, + { url = "https://pypi.halide-lang.org/packages/halide_llvm-23.0.0.dev100667+g9bf20bdf-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:9dfc5476b8647fb1eab8d6441303d34f065aabfea2d11d547afec94adb27b71b" }, + { url = "https://pypi.halide-lang.org/packages/halide_llvm-23.0.0.dev100667+g9bf20bdf-py3-none-manylinux_2_28_i686.whl", hash = "sha256:182725f20d81737cd3d03ea384eaf9f05fbb6070fe57d22880d5efd90b6eae78" }, + { url = "https://pypi.halide-lang.org/packages/halide_llvm-23.0.0.dev100667+g9bf20bdf-py3-none-manylinux_2_31_armv7l.whl", hash = "sha256:c14abaadf6781b2fbec4495c2d0558ae7fe25c17de05dde8e1b5e88f4de8fe33" }, + { url = "https://pypi.halide-lang.org/packages/halide_llvm-23.0.0.dev100667+g9bf20bdf-py3-none-win32.whl", hash = "sha256:0bff9d935c76af54c0d656f76dd9f9c935784ccc549bf194eb4fedf9f26ce36e" }, + { url = "https://pypi.halide-lang.org/packages/halide_llvm-23.0.0.dev100667+g9bf20bdf-py3-none-win_amd64.whl", hash = "sha256:0b32ab7ab02d63fb66664061da597dee70d5039c7be381a3f5ca73d30733b06f" }, ] [[package]]