diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index e08424404..024c768c1 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -62,7 +62,7 @@ add_custom_command(OUTPUT ${BAKE_FILE_OUTPUT_FILE} --base-var=${BAKE_FILE_DATA_BASE_VARIABLE_NAME} --base-size-var=${BAKE_FILE_SIZE_BASE_VARIABLE_NAME} WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" - DEPENDS ${BAKE_FILE_INPUT_FILE} ${BAKE_FILE_PYTHON_FILE} + DEPENDS ${BAKE_FILE_INPUT_FILE} ${BAKE_FILE_PYTHON_FILE} ${BAKE_FILE_BASE_HEADER_FILE} ) add_custom_target(clspv_baked_opencl_header diff --git a/deps.json b/deps.json index 1289b76a2..86c123e4a 100644 --- a/deps.json +++ b/deps.json @@ -6,7 +6,7 @@ "subrepo" : "llvm/llvm-project", "branch" : "main", "subdir" : "third_party/llvm", - "commit" : "76f20099a5ab72a261661ecb545dceed52e5592d" + "commit" : "c7d65e4466eafe518937c59ef9a242234ed7a08a" }, { "name" : "SPIRV-Headers", @@ -14,7 +14,7 @@ "subrepo" : "KhronosGroup/SPIRV-Headers", "branch" : "main", "subdir" : "third_party/SPIRV-Headers", - "commit" : "aa331ab0ffcb3a67021caa1a0c1c9017712f2f31" + "commit" : "fc7d2462765183c784a0c46beb13eee9e506a067" }, { "name" : "SPIRV-Tools", @@ -22,7 +22,7 @@ "subrepo" : "KhronosGroup/SPIRV-Tools", "branch" : "main", "subdir" : "third_party/SPIRV-Tools", - "commit" : "5d2bc6f064f00935dd552aa13afbff40e66458c5" + "commit" : "a996591b1c67e789e88e99ae3881272f5fc47374" } ] } diff --git a/lib/Compiler.cpp b/lib/Compiler.cpp index 5d91895d5..45b0aab51 100644 --- a/lib/Compiler.cpp +++ b/lib/Compiler.cpp @@ -54,6 +54,7 @@ #include "clspv/opencl_builtins_header.h" #include "Builtins.h" +#include "BuiltinsEnum.h" #include "Constants.h" #include "FrontendPlugin.h" #include "Passes.h" @@ -1103,6 +1104,24 @@ ProgramToModule(llvm::LLVMContext &context, return action.takeModule(); } +// Clang generates definitions for the following builtins: +// * sqrt +// +// These interfere with linking cllib builtins so we strip them. +// See https://reviews.llvm.org/D156743 +// TODO(#1231): find a better solution for this. +void StripBuiltinDefinitions(llvm::Module *module) { + for (auto &F : module->functions()) { + if (F.isDeclaration()) + continue; + + const auto info = clspv::Builtins::Lookup(&F); + if (info.getType() == clspv::Builtins::kSqrt) { + F.deleteBody(); + } + } +} + int CompileModule(const llvm::StringRef &input_filename, std::unique_ptr &module, std::vector *output_buffer, @@ -1146,6 +1165,8 @@ int CompilePrograms(const std::vector &programs, ProgramToModule(context, "source", program, output_log, &error)); if (error != 0) return error; + + StripBuiltinDefinitions(modules.back().get()); } assert(modules.size() > 0 && modules.back() != nullptr); @@ -1171,6 +1192,8 @@ int CompileProgram(const llvm::StringRef &input_filename, return error; } + StripBuiltinDefinitions(module.get()); + return CompileModule(input_filename, module, output_buffer, output_log); } diff --git a/lib/Option.cpp b/lib/Option.cpp index 0c3b8f5eb..9097d8648 100644 --- a/lib/Option.cpp +++ b/lib/Option.cpp @@ -219,8 +219,9 @@ llvm::cl::opt std430_ubo_layout( llvm::cl::opt int8_support("int8", llvm::cl::init(true), llvm::cl::desc("Allow 8-bit integers")); +// TODO(#1231): long vector support is required due to sqrt. llvm::cl::opt long_vector_support( - "long-vector", llvm::cl::init(false), + "long-vector", llvm::cl::init(true), llvm::cl::desc("Allow vectors of 8 and 16 elements. Experimental")); llvm::cl::opt cl_arm_non_uniform_work_group_size( diff --git a/test/LongVectorLowering/Frontend/lowering_disabled_function_body.cl b/test/LongVectorLowering/Frontend/lowering_disabled_function_body.cl index 7c1862f64..aad6f7d4d 100644 --- a/test/LongVectorLowering/Frontend/lowering_disabled_function_body.cl +++ b/test/LongVectorLowering/Frontend/lowering_disabled_function_body.cl @@ -1,4 +1,6 @@ // RUN: clspv %target %s -verify +// TODO(#1231) +// XFAIL: * // // Test that long-vector types are rejected when the support is not enabled. diff --git a/test/LongVectorLowering/Frontend/lowering_disabled_function_param_array.cl b/test/LongVectorLowering/Frontend/lowering_disabled_function_param_array.cl index 743385ec4..603656e60 100644 --- a/test/LongVectorLowering/Frontend/lowering_disabled_function_param_array.cl +++ b/test/LongVectorLowering/Frontend/lowering_disabled_function_param_array.cl @@ -1,4 +1,6 @@ // RUN: clspv %target %s -verify +// TODO(#1231) +// XFAIL: * // // Test that long-vector types are rejected when the support is not enabled. diff --git a/test/LongVectorLowering/Frontend/lowering_disabled_function_param_pointer.cl b/test/LongVectorLowering/Frontend/lowering_disabled_function_param_pointer.cl index 58634d3be..c47f47f0e 100644 --- a/test/LongVectorLowering/Frontend/lowering_disabled_function_param_pointer.cl +++ b/test/LongVectorLowering/Frontend/lowering_disabled_function_param_pointer.cl @@ -1,4 +1,6 @@ // RUN: clspv %target %s -verify +// TODO(#1231) +// XFAIL: * // // Test that long-vector types are rejected when the support is not enabled. diff --git a/test/LongVectorLowering/Frontend/lowering_disabled_function_param_scalar.cl b/test/LongVectorLowering/Frontend/lowering_disabled_function_param_scalar.cl index 586710c4b..8d7d16acf 100644 --- a/test/LongVectorLowering/Frontend/lowering_disabled_function_param_scalar.cl +++ b/test/LongVectorLowering/Frontend/lowering_disabled_function_param_scalar.cl @@ -1,4 +1,6 @@ // RUN: clspv %target %s -verify +// TODO(#1231) +// XFAIL: * // // Test that long-vector types are rejected when the support is not enabled. diff --git a/test/LongVectorLowering/Frontend/lowering_disabled_function_param_struct.cl b/test/LongVectorLowering/Frontend/lowering_disabled_function_param_struct.cl index 788da4b73..7b2888289 100644 --- a/test/LongVectorLowering/Frontend/lowering_disabled_function_param_struct.cl +++ b/test/LongVectorLowering/Frontend/lowering_disabled_function_param_struct.cl @@ -1,4 +1,6 @@ // RUN: clspv %target %s -verify +// TODO(#1231) +// XFAIL: * // // Test that long-vector types are rejected when the support is not enabled. diff --git a/test/LongVectorLowering/Frontend/lowering_disabled_kernel_param_pointer.cl b/test/LongVectorLowering/Frontend/lowering_disabled_kernel_param_pointer.cl index 1658d1ed9..a47702d1c 100644 --- a/test/LongVectorLowering/Frontend/lowering_disabled_kernel_param_pointer.cl +++ b/test/LongVectorLowering/Frontend/lowering_disabled_kernel_param_pointer.cl @@ -1,4 +1,6 @@ // RUN: clspv %target %s -verify +// TODO(#1231) +// XFAIL: * // // Test that long-vector types are rejected when the support is not enabled.