From 6a628fa0b507eefd3ed1608b39f4702ea56d1093 Mon Sep 17 00:00:00 2001 From: Naveen Saini Date: Fri, 20 Aug 2021 09:45:25 +0800 Subject: llvm/12.0.0: apply opencl-clang recommend patches https://github.com/intel/opencl-clang/tree/ocl-open-120/patches Signed-off-by: Naveen Saini Signed-off-by: Anuj Mittal --- ...1-Remove-__IMAGE_SUPPORT__-macro-for-SPIR.patch | 51 --- ...AGE_SUPPORT__-macro-for-SPIR-since-SPIR-d.patch | 51 +++ ...ng-ParseCommandLineOptions-in-BackendUtil.patch | 52 ++++ .../llvm12-0003-Support-cl_ext_float_atomics.patch | 344 +++++++++++++++++++++ .../clang/llvm-project-source.bbappend | 4 +- 5 files changed, 450 insertions(+), 52 deletions(-) delete mode 100644 dynamic-layers/clang-layer/recipes-devtools/clang/files/0001-Remove-__IMAGE_SUPPORT__-macro-for-SPIR.patch create mode 100644 dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm12-0001-Remove-__IMAGE_SUPPORT__-macro-for-SPIR-since-SPIR-d.patch create mode 100644 dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm12-0002-Avoid-calling-ParseCommandLineOptions-in-BackendUtil.patch create mode 100644 dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm12-0003-Support-cl_ext_float_atomics.patch diff --git a/dynamic-layers/clang-layer/recipes-devtools/clang/files/0001-Remove-__IMAGE_SUPPORT__-macro-for-SPIR.patch b/dynamic-layers/clang-layer/recipes-devtools/clang/files/0001-Remove-__IMAGE_SUPPORT__-macro-for-SPIR.patch deleted file mode 100644 index c0696652..00000000 --- a/dynamic-layers/clang-layer/recipes-devtools/clang/files/0001-Remove-__IMAGE_SUPPORT__-macro-for-SPIR.patch +++ /dev/null @@ -1,51 +0,0 @@ -From dccea3a4e68c9a4ce069f2f0a2a24df057199db1 Mon Sep 17 00:00:00 2001 -From: haonanya -Date: Tue, 11 May 2021 11:13:02 +0800 -Subject: [PATCH] Remove __IMAGE_SUPPORT__ macro for SPIR since SPIR doesn't - require image support - -Upstream-Status: Backport [Taken from opencl-clang patches, https://github.com/intel/opencl-clang/blob/ocl-open-120/patches/clang/0001-Remove-__IMAGE_SUPPORT__-macro-for-SPIR.patch] - -Signed-off-by: haonanya -Signed-off-by: Naveen Saini ---- - clang/lib/Frontend/InitPreprocessor.cpp | 3 --- - clang/test/Preprocessor/predefined-macros.c | 2 -- - 2 files changed, 5 deletions(-) - -diff --git a/clang/lib/Frontend/InitPreprocessor.cpp b/clang/lib/Frontend/InitPreprocessor.cpp -index c64a912ce919..c60972c96e5d 100644 ---- a/clang/lib/Frontend/InitPreprocessor.cpp -+++ b/clang/lib/Frontend/InitPreprocessor.cpp -@@ -1121,9 +1121,6 @@ static void InitializePredefinedMacros(const TargetInfo &TI, - // OpenCL definitions. - if (LangOpts.OpenCL) { - TI.getOpenCLFeatureDefines(LangOpts, Builder); -- -- if (TI.getTriple().isSPIR()) -- Builder.defineMacro("__IMAGE_SUPPORT__"); - } - - if (TI.hasInt128Type() && LangOpts.CPlusPlus && LangOpts.GNUMode) { -diff --git a/clang/test/Preprocessor/predefined-macros.c b/clang/test/Preprocessor/predefined-macros.c -index e406b9a70570..88606518c7de 100644 ---- a/clang/test/Preprocessor/predefined-macros.c -+++ b/clang/test/Preprocessor/predefined-macros.c -@@ -188,14 +188,12 @@ - - // RUN: %clang_cc1 %s -E -dM -o - -x cl -triple spir-unknown-unknown \ - // RUN: | FileCheck -match-full-lines %s --check-prefix=CHECK-SPIR --// CHECK-SPIR-DAG: #define __IMAGE_SUPPORT__ 1 - // CHECK-SPIR-DAG: #define __SPIR__ 1 - // CHECK-SPIR-DAG: #define __SPIR32__ 1 - // CHECK-SPIR-NOT: #define __SPIR64__ 1 - - // RUN: %clang_cc1 %s -E -dM -o - -x cl -triple spir64-unknown-unknown \ - // RUN: | FileCheck -match-full-lines %s --check-prefix=CHECK-SPIR64 --// CHECK-SPIR64-DAG: #define __IMAGE_SUPPORT__ 1 - // CHECK-SPIR64-DAG: #define __SPIR__ 1 - // CHECK-SPIR64-DAG: #define __SPIR64__ 1 - // CHECK-SPIR64-NOT: #define __SPIR32__ 1 --- -2.17.1 - diff --git a/dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm12-0001-Remove-__IMAGE_SUPPORT__-macro-for-SPIR-since-SPIR-d.patch b/dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm12-0001-Remove-__IMAGE_SUPPORT__-macro-for-SPIR-since-SPIR-d.patch new file mode 100644 index 00000000..7e6c4f92 --- /dev/null +++ b/dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm12-0001-Remove-__IMAGE_SUPPORT__-macro-for-SPIR-since-SPIR-d.patch @@ -0,0 +1,51 @@ +From 3632f727dfd786a8eca50bd01219669bbe7b0df9 Mon Sep 17 00:00:00 2001 +From: haonanya +Date: Tue, 11 May 2021 11:13:02 +0800 +Subject: [PATCH 1/3] Remove __IMAGE_SUPPORT__ macro for SPIR since SPIR + doesn't require image support + +Upstream-Status: Backport [Taken from opencl-clang patches, https://github.com/intel/opencl-clang/blob/ocl-open-120/patches/clang/0001-Remove-__IMAGE_SUPPORT__-macro-for-SPIR.patch] + +Signed-off-by: haonanya +Signed-off-by: Naveen Saini +--- + clang/lib/Frontend/InitPreprocessor.cpp | 3 --- + clang/test/Preprocessor/predefined-macros.c | 2 -- + 2 files changed, 5 deletions(-) + +diff --git a/clang/lib/Frontend/InitPreprocessor.cpp b/clang/lib/Frontend/InitPreprocessor.cpp +index c64a912ce919..c60972c96e5d 100644 +--- a/clang/lib/Frontend/InitPreprocessor.cpp ++++ b/clang/lib/Frontend/InitPreprocessor.cpp +@@ -1121,9 +1121,6 @@ static void InitializePredefinedMacros(const TargetInfo &TI, + // OpenCL definitions. + if (LangOpts.OpenCL) { + TI.getOpenCLFeatureDefines(LangOpts, Builder); +- +- if (TI.getTriple().isSPIR()) +- Builder.defineMacro("__IMAGE_SUPPORT__"); + } + + if (TI.hasInt128Type() && LangOpts.CPlusPlus && LangOpts.GNUMode) { +diff --git a/clang/test/Preprocessor/predefined-macros.c b/clang/test/Preprocessor/predefined-macros.c +index e406b9a70570..88606518c7de 100644 +--- a/clang/test/Preprocessor/predefined-macros.c ++++ b/clang/test/Preprocessor/predefined-macros.c +@@ -188,14 +188,12 @@ + + // RUN: %clang_cc1 %s -E -dM -o - -x cl -triple spir-unknown-unknown \ + // RUN: | FileCheck -match-full-lines %s --check-prefix=CHECK-SPIR +-// CHECK-SPIR-DAG: #define __IMAGE_SUPPORT__ 1 + // CHECK-SPIR-DAG: #define __SPIR__ 1 + // CHECK-SPIR-DAG: #define __SPIR32__ 1 + // CHECK-SPIR-NOT: #define __SPIR64__ 1 + + // RUN: %clang_cc1 %s -E -dM -o - -x cl -triple spir64-unknown-unknown \ + // RUN: | FileCheck -match-full-lines %s --check-prefix=CHECK-SPIR64 +-// CHECK-SPIR64-DAG: #define __IMAGE_SUPPORT__ 1 + // CHECK-SPIR64-DAG: #define __SPIR__ 1 + // CHECK-SPIR64-DAG: #define __SPIR64__ 1 + // CHECK-SPIR64-NOT: #define __SPIR32__ 1 +-- +2.17.1 + diff --git a/dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm12-0002-Avoid-calling-ParseCommandLineOptions-in-BackendUtil.patch b/dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm12-0002-Avoid-calling-ParseCommandLineOptions-in-BackendUtil.patch new file mode 100644 index 00000000..4f7d3e51 --- /dev/null +++ b/dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm12-0002-Avoid-calling-ParseCommandLineOptions-in-BackendUtil.patch @@ -0,0 +1,52 @@ +From 06cf750d2ef892eaa4f0ff5d0a9e9e5c49697264 Mon Sep 17 00:00:00 2001 +From: Raphael Isemann +Date: Thu, 1 Apr 2021 18:41:44 +0200 +Subject: [PATCH 2/3] Avoid calling ParseCommandLineOptions in BackendUtil if + possible + +Calling `ParseCommandLineOptions` should only be called from `main` as the +CommandLine setup code isn't thread-safe. As BackendUtil is part of the +generic Clang FrontendAction logic, a process which has several threads executing +Clang FrontendActions will randomly crash in the unsafe setup code. + +This patch avoids calling the function unless either the debug-pass option or +limit-float-precision option is set. Without these two options set the +`ParseCommandLineOptions` call doesn't do anything beside parsing +the command line `clang` which doesn't set any options. + +See also D99652 where LLDB received a workaround for this crash. + +Reviewed By: JDevlieghere + +Differential Revision: https://reviews.llvm.org/D99740 + +Upstream-Status: Backport [Taken from opencl-clang patches; https://github.com/intel/opencl-clang/blob/ocl-open-120/patches/clang/0002-Avoid-calling-ParseCommandLineOptions-in-BackendUtil.patch] + +Signed-off-by: Naveen Saini +--- + clang/lib/CodeGen/BackendUtil.cpp | 8 ++++++++ + 1 file changed, 8 insertions(+) + +diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp +index 52bcd971dc8c..f9f891247530 100644 +--- a/clang/lib/CodeGen/BackendUtil.cpp ++++ b/clang/lib/CodeGen/BackendUtil.cpp +@@ -850,7 +850,15 @@ static void setCommandLineOpts(const CodeGenOptions &CodeGenOpts) { + BackendArgs.push_back("-limit-float-precision"); + BackendArgs.push_back(CodeGenOpts.LimitFloatPrecision.c_str()); + } ++ // Check for the default "clang" invocation that won't set any cl::opt values. ++ // Skip trying to parse the command line invocation to avoid the issues ++ // described below. ++ if (BackendArgs.size() == 1) ++ return; + BackendArgs.push_back(nullptr); ++ // FIXME: The command line parser below is not thread-safe and shares a global ++ // state, so this call might crash or overwrite the options of another Clang ++ // instance in the same process. + llvm::cl::ParseCommandLineOptions(BackendArgs.size() - 1, + BackendArgs.data()); + } +-- +2.17.1 + diff --git a/dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm12-0003-Support-cl_ext_float_atomics.patch b/dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm12-0003-Support-cl_ext_float_atomics.patch new file mode 100644 index 00000000..99dbb81c --- /dev/null +++ b/dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm12-0003-Support-cl_ext_float_atomics.patch @@ -0,0 +1,344 @@ +From f1a24eeb89342186c6c718e02dd394775620799f Mon Sep 17 00:00:00 2001 +From: haonanya +Date: Wed, 28 Jul 2021 14:20:08 +0800 +Subject: [PATCH 3/3] Support cl_ext_float_atomics + +Upstream-Status: Backport [Taken from opencl-clang patches; https://github.com/intel/opencl-clang/blob/ocl-open-120/patches/clang/0003-OpenCL-Support-cl_ext_float_atomics.patch] + +Signed-off-by: haonanya +Signed-off-by: Naveen Saini +--- + clang/lib/Headers/opencl-c-base.h | 19 +++ + clang/lib/Headers/opencl-c.h | 195 ++++++++++++++++++++++++++ + clang/test/Headers/opencl-c-header.cl | 72 ++++++++++ + 3 files changed, 286 insertions(+) + +diff --git a/clang/lib/Headers/opencl-c-base.h b/clang/lib/Headers/opencl-c-base.h +index e8dcd70377e5..c8b6d36029ec 100644 +--- a/clang/lib/Headers/opencl-c-base.h ++++ b/clang/lib/Headers/opencl-c-base.h +@@ -21,6 +21,25 @@ + #define cl_khr_subgroup_shuffle 1 + #define cl_khr_subgroup_shuffle_relative 1 + #define cl_khr_subgroup_clustered_reduce 1 ++#define cl_ext_float_atomics ++#ifdef cl_khr_fp16 ++#define __opencl_c_ext_fp16_global_atomic_load_store 1 ++#define __opencl_c_ext_fp16_local_atomic_load_store 1 ++#define __opencl_c_ext_fp16_global_atomic_add 1 ++#define __opencl_c_ext_fp16_local_atomic_add 1 ++#define __opencl_c_ext_fp16_global_atomic_min_max 1 ++#define __opencl_c_ext_fp16_local_atomic_min_max 1 ++#endif ++#ifdef __opencl_c_fp64 ++#define __opencl_c_ext_fp64_global_atomic_add 1 ++#define __opencl_c_ext_fp64_local_atomic_add 1 ++#define __opencl_c_ext_fp64_global_atomic_min_max 1 ++#define __opencl_c_ext_fp64_local_atomic_min_max 1 ++#endif ++#define __opencl_c_ext_fp32_global_atomic_add 1 ++#define __opencl_c_ext_fp32_local_atomic_add 1 ++#define __opencl_c_ext_fp32_global_atomic_min_max 1 ++#define __opencl_c_ext_fp32_local_atomic_min_max 1 + #endif // defined(__SPIR__) + #endif // (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200) + +diff --git a/clang/lib/Headers/opencl-c.h b/clang/lib/Headers/opencl-c.h +index ab665628c8e1..6676da858d2a 100644 +--- a/clang/lib/Headers/opencl-c.h ++++ b/clang/lib/Headers/opencl-c.h +@@ -13531,6 +13531,201 @@ intptr_t __ovld atomic_fetch_max_explicit(volatile atomic_intptr_t *object, uint + intptr_t __ovld atomic_fetch_max_explicit(volatile atomic_intptr_t *object, uintptr_t opermax, memory_order minder, memory_scope scope); + #endif + ++#if defined(cl_ext_float_atomics) ++ ++#if defined(__opencl_c_ext_fp32_global_atomic_min_max) ++float __ovld atomic_fetch_min(volatile __global atomic_float *object, ++ float operand); ++float __ovld atomic_fetch_max(volatile __global atomic_float *object, ++ float operand); ++float __ovld atomic_fetch_min_explicit(volatile __global atomic_float *object, ++ float operand, memory_order order); ++float __ovld atomic_fetch_max_explicit(volatile __global atomic_float *object, ++ float operand, memory_order order); ++float __ovld atomic_fetch_min_explicit(volatile __global atomic_float *object, ++ float operand, memory_order order, ++ memory_scope scope); ++float __ovld atomic_fetch_max_explicit(volatile __global atomic_float *object, ++ float operand, memory_order order, ++ memory_scope scope); ++#endif ++#if defined(__opencl_c_ext_fp32_local_atomic_min_max) ++float __ovld atomic_fetch_min(volatile __local atomic_float *object, ++ float operand); ++float __ovld atomic_fetch_max(volatile __local atomic_float *object, ++ float operand); ++float __ovld atomic_fetch_min_explicit(volatile __local atomic_float *object, ++ float operand, memory_order order); ++float __ovld atomic_fetch_max_explicit(volatile __local atomic_float *object, ++ float operand, memory_order order); ++float __ovld atomic_fetch_min_explicit(volatile __local atomic_float *object, ++ float operand, memory_order order, ++ memory_scope scope); ++float __ovld atomic_fetch_max_explicit(volatile __local atomic_float *object, ++ float operand, memory_order order, ++ memory_scope scope); ++#endif ++#if defined(__opencl_c_ext_fp32_global_atomic_min_max) || \ ++ defined(__opencl_c_ext_fp32_local_atomic_min_max) ++float __ovld atomic_fetch_min(volatile atomic_float *object, float operand); ++float __ovld atomic_fetch_max(volatile atomic_float *object, float operand); ++float __ovld atomic_fetch_min_explicit(volatile atomic_float *object, ++ float operand, memory_order order); ++float __ovld atomic_fetch_max_explicit(volatile atomic_float *object, ++ float operand, memory_order order); ++float __ovld atomic_fetch_min_explicit(volatile atomic_float *object, ++ float operand, memory_order order, ++ memory_scope scope); ++float __ovld atomic_fetch_max_explicit(volatile atomic_float *object, ++ float operand, memory_order order, ++ memory_scope scope); ++#endif ++#if defined(__opencl_c_ext_fp64_global_atomic_min_max) ++double __ovld atomic_fetch_min(volatile __global atomic_double *object, ++ double operand); ++double __ovld atomic_fetch_max(volatile __global atomic_double *object, ++ double operand); ++double __ovld atomic_fetch_min_explicit(volatile __global atomic_double *object, ++ double operand, memory_order order); ++double __ovld atomic_fetch_max_explicit(volatile __global atomic_double *object, ++ double operand, memory_order order); ++double __ovld atomic_fetch_min_explicit(volatile __global atomic_double *object, ++ double operand, memory_order order, ++ memory_scope scope); ++double __ovld atomic_fetch_max_explicit(volatile __global atomic_double *object, ++ double operand, memory_order order, ++ memory_scope scope); ++#endif ++#if defined(__opencl_c_ext_fp64_local_atomic_min_max) ++double __ovld atomic_fetch_min(volatile __local atomic_double *object, ++ double operand); ++double __ovld atomic_fetch_max(volatile __local atomic_double *object, ++ double operand); ++double __ovld atomic_fetch_min_explicit(volatile __local atomic_double *object, ++ double operand, memory_order order); ++double __ovld atomic_fetch_max_explicit(volatile __local atomic_double *object, ++ double operand, memory_order order); ++double __ovld atomic_fetch_min_explicit(volatile __local atomic_double *object, ++ double operand, memory_order order, ++ memory_scope scope); ++double __ovld atomic_fetch_max_explicit(volatile __local atomic_double *object, ++ double operand, memory_order order, ++ memory_scope scope); ++#endif ++#if defined(__opencl_c_ext_fp64_global_atomic_min_max) || \ ++ defined(__opencl_c_ext_fp64_local_atomic_min_max) ++double __ovld atomic_fetch_min(volatile atomic_double *object, double operand); ++double __ovld atomic_fetch_max(volatile atomic_double *object, double operand); ++double __ovld atomic_fetch_min_explicit(volatile atomic_double *object, ++ double operand, memory_order order); ++double __ovld atomic_fetch_max_explicit(volatile atomic_double *object, ++ double operand, memory_order order); ++double __ovld atomic_fetch_min_explicit(volatile atomic_double *object, ++ double operand, memory_order order, ++ memory_scope scope); ++double __ovld atomic_fetch_max_explicit(volatile atomic_double *object, ++ double operand, memory_order order, ++ memory_scope scope); ++#endif ++ ++#if defined(__opencl_c_ext_fp32_global_atomic_add) ++float __ovld atomic_fetch_add(volatile __global atomic_float *object, ++ float operand); ++float __ovld atomic_fetch_sub(volatile __global atomic_float *object, ++ float operand); ++float __ovld atomic_fetch_add_explicit(volatile __global atomic_float *object, ++ float operand, memory_order order); ++float __ovld atomic_fetch_sub_explicit(volatile __global atomic_float *object, ++ float operand, memory_order order); ++float __ovld atomic_fetch_add_explicit(volatile __global atomic_float *object, ++ float operand, memory_order order, ++ memory_scope scope); ++float __ovld atomic_fetch_sub_explicit(volatile __global atomic_float *object, ++ float operand, memory_order order, ++ memory_scope scope); ++#endif ++#if defined(__opencl_c_ext_fp32_local_atomic_add) ++float __ovld atomic_fetch_add(volatile __local atomic_float *object, ++ float operand); ++float __ovld atomic_fetch_sub(volatile __local atomic_float *object, ++ float operand); ++float __ovld atomic_fetch_add_explicit(volatile __local atomic_float *object, ++ float operand, memory_order order); ++float __ovld atomic_fetch_sub_explicit(volatile __local atomic_float *object, ++ float operand, memory_order order); ++float __ovld atomic_fetch_add_explicit(volatile __local atomic_float *object, ++ float operand, memory_order order, ++ memory_scope scope); ++float __ovld atomic_fetch_sub_explicit(volatile __local atomic_float *object, ++ float operand, memory_order order, ++ memory_scope scope); ++#endif ++#if defined(__opencl_c_ext_fp32_global_atomic_add) || \ ++ defined(__opencl_c_ext_fp32_local_atomic_add) ++float __ovld atomic_fetch_add(volatile atomic_float *object, float operand); ++float __ovld atomic_fetch_sub(volatile atomic_float *object, float operand); ++float __ovld atomic_fetch_add_explicit(volatile atomic_float *object, ++ float operand, memory_order order); ++float __ovld atomic_fetch_sub_explicit(volatile atomic_float *object, ++ float operand, memory_order order); ++float __ovld atomic_fetch_add_explicit(volatile atomic_float *object, ++ float operand, memory_order order, ++ memory_scope scope); ++float __ovld atomic_fetch_sub_explicit(volatile atomic_float *object, ++ float operand, memory_order order, ++ memory_scope scope); ++#endif ++ ++#if defined(__opencl_c_ext_fp64_global_atomic_add) ++double __ovld atomic_fetch_add(volatile __global atomic_double *object, ++ double operand); ++double __ovld atomic_fetch_sub(volatile __global atomic_double *object, ++ double operand); ++double __ovld atomic_fetch_add_explicit(volatile __global atomic_double *object, ++ double operand, memory_order order); ++double __ovld atomic_fetch_sub_explicit(volatile __global atomic_double *object, ++ double operand, memory_order order); ++double __ovld atomic_fetch_add_explicit(volatile __global atomic_double *object, ++ double operand, memory_order order, ++ memory_scope scope); ++double __ovld atomic_fetch_sub_explicit(volatile __global atomic_double *object, ++ double operand, memory_order order, ++ memory_scope scope); ++#endif ++#if defined(__opencl_c_ext_fp64_local_atomic_add) ++double __ovld atomic_fetch_add(volatile __local atomic_double *object, ++ double operand); ++double __ovld atomic_fetch_sub(volatile __local atomic_double *object, ++ double operand); ++double __ovld atomic_fetch_add_explicit(volatile __local atomic_double *object, ++ double operand, memory_order order); ++double __ovld atomic_fetch_sub_explicit(volatile __local atomic_double *object, ++ double operand, memory_order order); ++double __ovld atomic_fetch_add_explicit(volatile __local atomic_double *object, ++ double operand, memory_order order, ++ memory_scope scope); ++double __ovld atomic_fetch_sub_explicit(volatile __local atomic_double *object, ++ double operand, memory_order order, ++ memory_scope scope); ++#endif ++#if defined(__opencl_c_ext_fp64_global_atomic_add) || \ ++ defined(__opencl_c_ext_fp64_local_atomic_add) ++double __ovld atomic_fetch_add(volatile atomic_double *object, double operand); ++double __ovld atomic_fetch_sub(volatile atomic_double *object, double operand); ++double __ovld atomic_fetch_add_explicit(volatile atomic_double *object, ++ double operand, memory_order order); ++double __ovld atomic_fetch_sub_explicit(volatile atomic_double *object, ++ double operand, memory_order order); ++double __ovld atomic_fetch_add_explicit(volatile atomic_double *object, ++ double operand, memory_order order, ++ memory_scope scope); ++double __ovld atomic_fetch_sub_explicit(volatile atomic_double *object, ++ double operand, memory_order order, ++ memory_scope scope); ++#endif ++ ++#endif // cl_ext_float_atomics ++ + // atomic_store() + + void __ovld atomic_store(volatile atomic_int *object, int desired); +diff --git a/clang/test/Headers/opencl-c-header.cl b/clang/test/Headers/opencl-c-header.cl +index 13a3b62481ec..2c02d14f25c3 100644 +--- a/clang/test/Headers/opencl-c-header.cl ++++ b/clang/test/Headers/opencl-c-header.cl +@@ -124,6 +124,36 @@ global atomic_int z = ATOMIC_VAR_INIT(99); + #if cl_khr_subgroup_clustered_reduce != 1 + #error "Incorrectly defined cl_khr_subgroup_clustered_reduce" + #endif ++#if __opencl_c_ext_fp16_global_atomic_load_store != 1 ++#error "Incorrectly defined __opencl_c_ext_fp16_global_atomic_load_store" ++#endif ++#if __opencl_c_ext_fp16_local_atomic_load_store != 1 ++#error "Incorrectly defined __opencl_c_ext_fp16_local_atomic_load_store" ++#endif ++#if __opencl_c_ext_fp16_global_atomic_add != 1 ++#error "Incorrectly defined __opencl_c_ext_fp16_global_atomic_add" ++#endif ++#if __opencl_c_ext_fp32_global_atomic_add != 1 ++#error "Incorrectly defined __opencl_c_ext_fp32_global_atomic_add" ++#endif ++#if __opencl_c_ext_fp16_local_atomic_add != 1 ++#error "Incorrectly defined __opencl_c_ext_fp16_local_atomic_add" ++#endif ++#if __opencl_c_ext_fp32_local_atomic_add != 1 ++#error "Incorrectly defined __opencl_c_ext_fp32_local_atomic_add" ++#endif ++#if __opencl_c_ext_fp16_global_atomic_min_max != 1 ++#error "Incorrectly defined __opencl_c_ext_fp16_global_atomic_min_max" ++#endif ++#if __opencl_c_ext_fp32_global_atomic_min_max != 1 ++#error "Incorrectly defined __opencl_c_ext_fp32_global_atomic_min_max" ++#endif ++#if __opencl_c_ext_fp16_local_atomic_min_max != 1 ++#error "Incorrectly defined __opencl_c_ext_fp16_local_atomic_min_max" ++#endif ++#if __opencl_c_ext_fp32_local_atomic_min_max != 1 ++#error "Incorrectly defined __opencl_c_ext_fp32_local_atomic_min_max" ++#endif + + #else + +@@ -148,6 +178,48 @@ global atomic_int z = ATOMIC_VAR_INIT(99); + #ifdef cl_khr_subgroup_clustered_reduce + #error "Incorrect cl_khr_subgroup_clustered_reduce define" + #endif ++#ifdef __opencl_c_ext_fp16_global_atomic_load_store ++#error "Incorrectly __opencl_c_ext_fp16_global_atomic_load_store defined" ++#endif ++#ifdef __opencl_c_ext_fp16_local_atomic_load_store ++#error "Incorrectly __opencl_c_ext_fp16_local_atomic_load_store defined" ++#endif ++#ifdef __opencl_c_ext_fp16_global_atomic_add ++#error "Incorrectly __opencl_c_ext_fp16_global_atomic_add defined" ++#endif ++#ifdef __opencl_c_ext_fp32_global_atomic_add ++#error "Incorrectly __opencl_c_ext_fp32_global_atomic_add defined" ++#endif ++#ifdef __opencl_c_ext_fp64_global_atomic_add ++#error "Incorrectly __opencl_c_ext_fp64_global_atomic_add defined" ++#endif ++#ifdef __opencl_c_ext_fp16_local_atomic_add ++#error "Incorrectly __opencl_c_ext_fp16_local_atomic_add defined" ++#endif ++#ifdef __opencl_c_ext_fp32_local_atomic_add ++#error "Incorrectly __opencl_c_ext_fp32_local_atomic_add defined" ++#endif ++#ifdef __opencl_c_ext_fp64_local_atomic_add ++#error "Incorrectly __opencl_c_ext_fp64_local_atomic_add defined" ++#endif ++#ifdef __opencl_c_ext_fp16_global_atomic_min_max ++#error "Incorrectly __opencl_c_ext_fp16_global_atomic_min_max defined" ++#endif ++#ifdef __opencl_c_ext_fp32_global_atomic_min_max ++#error "Incorrectly __opencl_c_ext_fp32_global_atomic_min_max defined" ++#endif ++#ifdef __opencl_c_ext_fp64_global_atomic_min_max ++#error "Incorrectly __opencl_c_ext_fp64_global_atomic_min_max defined" ++#endif ++#ifdef __opencl_c_ext_fp16_local_atomic_min_max ++#error "Incorrectly __opencl_c_ext_fp16_local_atomic_min_max defined" ++#endif ++#ifdef __opencl_c_ext_fp32_local_atomic_min_max ++#error "Incorrectly __opencl_c_ext_fp32_local_atomic_min_max defined" ++#endif ++#ifdef __opencl_c_ext_fp64_local_atomic_min_max ++#error "Incorrectly __opencl_c_ext_fp64_local_atomic_min_max defined" ++#endif + + #endif //(defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200) + +-- +2.17.1 + diff --git a/dynamic-layers/clang-layer/recipes-devtools/clang/llvm-project-source.bbappend b/dynamic-layers/clang-layer/recipes-devtools/clang/llvm-project-source.bbappend index 84192714..01af38c2 100644 --- a/dynamic-layers/clang-layer/recipes-devtools/clang/llvm-project-source.bbappend +++ b/dynamic-layers/clang-layer/recipes-devtools/clang/llvm-project-source.bbappend @@ -31,7 +31,9 @@ SRC_URI_LLVM11_PATCHES = " \ file://llvm11-0006-OpenCL-support-cl_ext_float_atomics.patch \ " SRC_URI_LLVM12_PATCHES = " \ - file://0001-Remove-__IMAGE_SUPPORT__-macro-for-SPIR.patch \ + file://llvm12-0001-Remove-__IMAGE_SUPPORT__-macro-for-SPIR-since-SPIR-d.patch \ + file://llvm12-0002-Avoid-calling-ParseCommandLineOptions-in-BackendUtil.patch \ + file://llvm12-0003-Support-cl_ext_float_atomics.patch \ " -- cgit v1.2.3-54-g00ecf