Date: Wednesday, December 16, 2020 @ 13:35:42
  Author: svenstaro
Revision: 776693

archrelease: copy trunk to community-x86_64

Added:
  pocl/repos/community-x86_64/PKGBUILD
    (from rev 776692, pocl/trunk/PKGBUILD)
  pocl/repos/community-x86_64/llvm11.patch
    (from rev 776692, pocl/trunk/llvm11.patch)
Deleted:
  pocl/repos/community-x86_64/PKGBUILD
  pocl/repos/community-x86_64/llvm11.patch

--------------+
 PKGBUILD     |   87 +--
 llvm11.patch | 1392 ++++++++++++++++++++++++++++-----------------------------
 2 files changed, 736 insertions(+), 743 deletions(-)

Deleted: PKGBUILD
===================================================================
--- PKGBUILD    2020-12-16 13:35:37 UTC (rev 776692)
+++ PKGBUILD    2020-12-16 13:35:42 UTC (rev 776693)
@@ -1,47 +0,0 @@
-# Maintainer: Sven-Hendrik Haase <svenst...@gmail.com>
-# Contributor: spider-mario <spiderma...@free.fr>
-# Contributor: Olaf Leidinger <ol...@mescharet.de>
-# Contributor: fabien Cellier <fabien.cell...@gmail.com>
-
-pkgname=pocl
-pkgver=1.5
-pkgrel=5
-pkgdesc="Portable OpenCL is an open-source implementation of OpenCL which can 
be easily adapted for new targets"
-arch=('x86_64')
-url="http://portablecl.org/";
-license=('GPL')
-source=("$pkgname-$pkgver.tar.gz::https://github.com/$pkgname/$pkgname/archive/v$pkgver.tar.gz";
-        llvm11.patch)
-depends=('clang' 'hwloc' 'opencl-icd-loader')
-makedepends=('llvm' 'cmake' 'opencl-headers' 'ocl-icd' 'ninja')
-sha512sums=('a9c2879b6f0c0d9a78035ba8ed7531b8fa795074864ee5bab265d7dafedac9637025f994719f00f8d9e25bf5068bd9b074d95b964e5d2c0eddb8d8837e6e5da3'
-            
'ef149678347c88ee3c1bfef62c0b35667b2f613cc08a90f237b6f9d1a5f3d616fe5d6513bbda36ead5969fc6d32cace7d02a3c4c6230ab5144db94a0af56db30')
-
-prepare() {
-  cd "$pkgname-$pkgver"
-
-  # Cherry-picked upstream commits with "LLVM ?11" in the commit message
-  patch -Np1 -i ../llvm11.patch
-}
-
-build() {
-  cd "$pkgname-$pkgver"
-  cmake \
-      -GNinja \
-      -Bbuild \
-      -DCMAKE_INSTALL_PREFIX=/usr \
-      -DCMAKE_INSTALL_LIBDIR=lib \
-      -DCMAKE_BUILD_TYPE=Release \
-      -DKERNELLIB_HOST_CPU_VARIANTS=distro
-  ninja -C build
-}
-
-check() {
-  cd "$pkgname-$pkgver"
-  ninja -C build check
-}
-
-package() {
-  cd "$pkgname-$pkgver"
-  DESTDIR="$pkgdir"/ ninja -C build install
-}

Copied: pocl/repos/community-x86_64/PKGBUILD (from rev 776692, 
pocl/trunk/PKGBUILD)
===================================================================
--- PKGBUILD                            (rev 0)
+++ PKGBUILD    2020-12-16 13:35:42 UTC (rev 776693)
@@ -0,0 +1,40 @@
+# Maintainer: Sven-Hendrik Haase <svenst...@gmail.com>
+# Contributor: spider-mario <spiderma...@free.fr>
+# Contributor: Olaf Leidinger <ol...@mescharet.de>
+# Contributor: fabien Cellier <fabien.cell...@gmail.com>
+
+pkgname=pocl
+pkgver=1.6
+pkgrel=1
+pkgdesc="Portable OpenCL is an open-source implementation of OpenCL which can 
be easily adapted for new targets"
+arch=('x86_64')
+url="http://portablecl.org/";
+license=('GPL')
+source=("$pkgname-$pkgver.tar.gz::https://github.com/$pkgname/$pkgname/archive/v$pkgver.tar.gz";
+        llvm11.patch)
+depends=('clang' 'hwloc' 'opencl-icd-loader')
+makedepends=('llvm' 'cmake' 'opencl-headers' 'ocl-icd' 'ninja')
+sha512sums=('ecd3a3867a62a2a555183741fa4586eeefae00514d66d15a79b9094ff0a0248b213f62ab23b3e61bdb1042e760cd34b07e546f97b304ac86c3f861a9161df1b1'
+            
'ef149678347c88ee3c1bfef62c0b35667b2f613cc08a90f237b6f9d1a5f3d616fe5d6513bbda36ead5969fc6d32cace7d02a3c4c6230ab5144db94a0af56db30')
+
+build() {
+  cd "$pkgname-$pkgver"
+  cmake \
+      -GNinja \
+      -Bbuild \
+      -DCMAKE_INSTALL_PREFIX=/usr \
+      -DCMAKE_INSTALL_LIBDIR=lib \
+      -DCMAKE_BUILD_TYPE=Release \
+      -DKERNELLIB_HOST_CPU_VARIANTS=distro
+  ninja -C build
+}
+
+check() {
+  cd "$pkgname-$pkgver"
+  ninja -C build check
+}
+
+package() {
+  cd "$pkgname-$pkgver"
+  DESTDIR="$pkgdir"/ ninja -C build install
+}

Deleted: llvm11.patch
===================================================================
--- llvm11.patch        2020-12-16 13:35:37 UTC (rev 776692)
+++ llvm11.patch        2020-12-16 13:35:42 UTC (rev 776693)
@@ -1,696 +0,0 @@
-From 749a80b2c832771ef3eb6d9af39807dbad97d218 Mon Sep 17 00:00:00 2001
-From: KOLANICH <kola...@mail.ru>
-Date: Mon, 3 Feb 2020 11:55:10 +0300
-Subject: [PATCH 1/6] LLVM11 support
-
-(cherry picked from commit 1e31e34cd1f6f9f045ca72a8a26caa8e34a43c4f)
----
- cmake/LLVM.cmake                    |  6 +++++-
- config.h.in.cmake                   |  4 ++++
- include/CMakeLists.txt              |  2 +-
- include/_kernel.h                   | 24 ++++++------------------
- include/_libclang_versions_checks.h | 24 ++++++++++++++++++++++++
- include/pocl.h                      | 22 ++--------------------
- lib/CL/pocl_llvm_wg.cc              |  4 ++--
- lib/kernel/CMakeLists.txt           |  1 +
- 8 files changed, 45 insertions(+), 42 deletions(-)
- create mode 100644 include/_libclang_versions_checks.h
-
-diff --git a/cmake/LLVM.cmake b/cmake/LLVM.cmake
-index 33c45750..b41e75a9 100644
---- a/cmake/LLVM.cmake
-+++ b/cmake/LLVM.cmake
-@@ -37,6 +37,7 @@ else()
-   # search for any version
-   find_program(LLVM_CONFIG
-     NAMES
-+      "llvm-config-mp-11.0" "llvm-config-11" "llvm-config110"
-       "llvm-config-mp-10.0" "llvm-config-10" "llvm-config100"
-       "llvm-config-mp-9.0" "llvm-config-9" "llvm-config90"
-       "llvm-config-mp-8.0" "llvm-config-8" "llvm-config80"
-@@ -180,8 +181,11 @@ elseif(LLVM_VERSION MATCHES "^9[.]")
- elseif(LLVM_VERSION MATCHES "^10[.]")
-   set(LLVM_MAJOR 10)
-   set(LLVM_10_0 1)
-+elseif(LLVM_VERSION MATCHES "^11[.]")
-+  set(LLVM_MAJOR 11)
-+  set(LLVM_11_0 1)
- else()
--  message(FATAL_ERROR "LLVM version between 6.0 and 10.0 required, found: 
${LLVM_VERSION}")
-+  message(FATAL_ERROR "LLVM version between 6.0 and 11.0 required, found: 
${LLVM_VERSION}")
- endif()
- 
- #############################################################
-diff --git a/config.h.in.cmake b/config.h.in.cmake
-index 42c63f77..7c6c0eb4 100644
---- a/config.h.in.cmake
-+++ b/config.h.in.cmake
-@@ -152,6 +152,10 @@
- 
- #cmakedefine LLVM_10_0
- 
-+#cmakedefine LLVM_11_0
-+
-+#cmakedefine LLVM_MAJOR @LLVM_VERSION_MAJOR@
-+
- #cmakedefine LLVM_BUILD_MODE_DEBUG
- 
- #ifndef LLVM_VERSION
-diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt
-index 321df9d5..31883269 100644
---- a/include/CMakeLists.txt
-+++ b/include/CMakeLists.txt
-@@ -27,7 +27,7 @@ add_subdirectory("CL")
- 
- set(PRIVATE_HEADERS _enable_all_exts.h _builtin_renames.h
-                     _kernel.h _clang_opencl.h
--                    _kernel_c.h _kernel_constants.h
-+                    _kernel_c.h _kernel_constants.h 
_libclang_versions_checks.h
-                     pocl_types.h pocl_device.h pocl.h pocl_spir.h
-                     pocl_image_types.h)
- 
-diff --git a/include/_kernel.h b/include/_kernel.h
-index 427794e3..90154648 100644
---- a/include/_kernel.h
-+++ b/include/_kernel.h
-@@ -143,32 +143,20 @@
- # undef LLVM_10_0
- # define LLVM_10_0
- 
-+#elif (__clang_major__ == 11)
-+
-+# undef LLVM_11_0
-+# define LLVM_11_0
- #else
- 
- #error Unsupported Clang/LLVM version.
- 
- #endif
- 
--#ifndef LLVM_10_0
--#define LLVM_OLDER_THAN_10_0 1
--
--#ifndef LLVM_9_0
--#define LLVM_OLDER_THAN_9_0 1
--
--#ifndef LLVM_8_0
--#define LLVM_OLDER_THAN_8_0 1
-+#define CLANG_MAJOR __clang_major__
-+#include "_libclang_versions_checks.h"
- 
--#ifndef LLVM_7_0
--#define LLVM_OLDER_THAN_7_0 1
- 
--#ifndef LLVM_6_0
--#define LLVM_OLDER_THAN_6_0 1
--
--#endif
--#endif
--#endif
--#endif
--#endif
- 
- /****************************************************************************/
- 
-diff --git a/include/_libclang_versions_checks.h 
b/include/_libclang_versions_checks.h
-new file mode 100644
-index 00000000..1ba0ce4d
---- /dev/null
-+++ b/include/_libclang_versions_checks.h
-@@ -0,0 +1,24 @@
-+
-+#if CLANG_MAJOR < 11
-+#define LLVM_OLDER_THAN_11_0 1
-+#endif
-+
-+#if CLANG_MAJOR < 10
-+#define LLVM_OLDER_THAN_10_0 1
-+#endif
-+
-+#if CLANG_MAJOR < 9
-+#define LLVM_OLDER_THAN_9_0 1
-+#endif
-+
-+#if CLANG_MAJOR < 8
-+#define LLVM_OLDER_THAN_8_0 1
-+#endif
-+
-+#if CLANG_MAJOR < 7
-+#define LLVM_OLDER_THAN_7_0 1
-+#endif
-+
-+#if CLANG_MAJOR < 6
-+#define LLVM_OLDER_THAN_6_0 1
-+#endif
-diff --git a/include/pocl.h b/include/pocl.h
-index 1fad38cc..4c175c07 100644
---- a/include/pocl.h
-+++ b/include/pocl.h
-@@ -369,25 +369,7 @@ struct _cl_command_node
-   cl_int ready;
- };
- 
--#ifndef LLVM_10_0
--#define LLVM_OLDER_THAN_10_0 1
--
--#ifndef LLVM_9_0
--#define LLVM_OLDER_THAN_9_0 1
--
--#ifndef LLVM_8_0
--#define LLVM_OLDER_THAN_8_0 1
--
--#ifndef LLVM_7_0
--#define LLVM_OLDER_THAN_7_0 1
--
--#ifndef LLVM_6_0
--#define LLVM_OLDER_THAN_6_0 1
--
--#endif
--#endif
--#endif
--#endif
--#endif
-+#define CLANG_MAJOR LLVM_MAJOR
-+#include "_libclang_versions_checks.h"
- 
- #endif /* POCL_H */
-diff --git a/lib/CL/pocl_llvm_wg.cc b/lib/CL/pocl_llvm_wg.cc
-index b8e4ac5f..561a80ad 100644
---- a/lib/CL/pocl_llvm_wg.cc
-+++ b/lib/CL/pocl_llvm_wg.cc
-@@ -625,8 +625,8 @@ int pocl_llvm_codegen(cl_device_id Device, void *Modp, 
char **Output,
- #ifdef DUMP_LLVM_PASS_TIMINGS
-     llvm::reportAndResetTimings();
- #endif
--    std::string O = SOS.str(); // flush
--    const char *Cstr = O.c_str();
-+    auto O = SOS.str(); // flush
-+    const char *Cstr = O.data();
-     size_t S = O.size();
-     *Output = (char *)malloc(S);
-     *OutputSize = S;
-diff --git a/lib/kernel/CMakeLists.txt b/lib/kernel/CMakeLists.txt
-index e2cfd71e..1f0c9cff 100644
---- a/lib/kernel/CMakeLists.txt
-+++ b/lib/kernel/CMakeLists.txt
-@@ -229,6 +229,7 @@ add_custom_command( OUTPUT 
"${CMAKE_BINARY_DIR}/kernellib_hash.h"
-   DEPENDS ${KERNEL_BC_LIST}
-       "${CMAKE_SOURCE_DIR}/include/_kernel.h"
-       "${CMAKE_SOURCE_DIR}/include/_kernel_c.h"
-+      "${CMAKE_SOURCE_DIR}/include/_libclang_versions_checks.h"
-       "${CMAKE_SOURCE_DIR}/include/pocl_types.h"
-   COMMENT "Generating SHA1 of all kernel libs..."
-   VERBATIM)
-
-From b1906c650da86bd1045472fe99e082f354592b11 Mon Sep 17 00:00:00 2001
-From: KOLANICH <kola...@mail.ru>
-Date: Mon, 22 Jun 2020 15:53:45 +0300
-Subject: [PATCH 2/6] Fixing llvm11 support due to recent changes:
- 
https://github.com/llvm/llvm-project/commit/4f04db4b5439f390c48408f9b94875810e88ffc6
- 
https://github.com/llvm/llvm-project/commit/a58b62b4a2b96c31b49338b262b609db746449e8
- 
https://github.com/llvm/llvm-project/commit/4aae4e3f48b9156755c4cfc7ad63fe2a7029d9d7
- .
-
-(cherry picked from commit dae742fae9978c524ec849a90d0b40a9682fb172)
----
- lib/llvmopencl/HandleSamplerInitialization.cc |  4 +++
- lib/llvmopencl/HandleSamplerInitialization.h  |  1 -
- lib/llvmopencl/Workgroup.cc                   | 35 +++++++++++++++++--
- lib/llvmopencl/WorkitemLoops.cc               |  4 +++
- 4 files changed, 41 insertions(+), 3 deletions(-)
-
-diff --git a/lib/llvmopencl/HandleSamplerInitialization.cc 
b/lib/llvmopencl/HandleSamplerInitialization.cc
-index 4cbc5617..5d65c48f 100644
---- a/lib/llvmopencl/HandleSamplerInitialization.cc
-+++ b/lib/llvmopencl/HandleSamplerInitialization.cc
-@@ -79,7 +79,11 @@ HandleSamplerInitialization::runOnFunction(Function &F) {
- 
-     // get the type of the return value of __translate_sampler
-     // this may not always be opencl.sampler_t, it could be a remapped type.
-+#ifdef LLVM_OLDER_THAN_11_0
-     Type *type = C->getCalledValue()->getType();
-+#else
-+    Type *type = C->getCalledOperand()->getType();
-+#endif
-     PointerType *pt = dyn_cast<PointerType>(type);
-     FunctionType *ft = dyn_cast<FunctionType>(pt->getPointerElementType());
-     Type *rettype = ft->getReturnType();
-diff --git a/lib/llvmopencl/HandleSamplerInitialization.h 
b/lib/llvmopencl/HandleSamplerInitialization.h
-index e8274e50..dc7539e2 100644
---- a/lib/llvmopencl/HandleSamplerInitialization.h
-+++ b/lib/llvmopencl/HandleSamplerInitialization.h
-@@ -27,7 +27,6 @@
- IGNORE_COMPILER_WARNING("-Wunused-parameter")
- 
- #include <llvm/IR/Function.h>
--#include <llvm/PassAnalysisSupport.h>
- #include <llvm/Pass.h>
- 
- POP_COMPILER_DIAGS
-diff --git a/lib/llvmopencl/Workgroup.cc b/lib/llvmopencl/Workgroup.cc
-index 357049a1..0ae2f34c 100644
---- a/lib/llvmopencl/Workgroup.cc
-+++ b/lib/llvmopencl/Workgroup.cc
-@@ -35,7 +35,9 @@ IGNORE_COMPILER_WARNING("-Wunused-parameter")
- 
- #include <llvm/Analysis/ConstantFolding.h>
- #include <llvm/IR/BasicBlock.h>
-+#ifdef LLVM_OLDER_THAN_11_0
- #include <llvm/IR/CallSite.h>
-+#endif
- #include <llvm/IR/Constants.h>
- #include <llvm/IR/DerivedTypes.h>
- #include <llvm/IR/IRBuilder.h>
-@@ -517,10 +519,15 @@ static void replacePrintfCalls(Value *pb, Value *pbp, 
Value *pbc, bool isKernel,
-         for (unsigned i = 0; i < j; ++i)
-           ops.push_back(CallInstr->getOperand(i));
- 
--        CallSite CS(CallInstr);
-         CallInst *NewCI = CallInst::Create(poclPrintf, ops);
-         NewCI->setCallingConv(poclPrintf->getCallingConv());
-+#ifdef LLVM_OLDER_THAN_11_0
-+        CallSite CS(CallInstr);
-         NewCI->setTailCall(CS.isTailCall());
-+#else
-+        auto *CB = dyn_cast<CallBase>(CallInstr);
-+        NewCI->setTailCall(CB->isTailCall());
-+#endif
- 
-         replaceCIMap.insert(
-             std::pair<CallInst *, CallInst *>(CallInstr, NewCI));
-@@ -719,7 +726,11 @@ Workgroup::createWrapper(Function *F, FunctionMapping 
&printfCache) {
- 
-   // needed for printf
-   InlineFunctionInfo IFI;
-+#ifdef LLVM_OLDER_THAN_11_0
-   InlineFunction(c, IFI);
-+#else
-+  InlineFunction(*c, IFI);
-+#endif
- 
-   if (currentPoclDevice->device_side_printf) {
-     Function *poclPrintf = M->getFunction("__pocl_printf");
-@@ -989,7 +1000,11 @@ Workgroup::createDefaultWorkgroupLauncher(llvm::Function 
*F) {
-             new llvm::AllocaInst(ArgElementType, ParamType->getAddressSpace(),
-                                  ConstantInt::get(IntegerType::get(*C, 32), 
1),
- #ifndef LLVM_OLDER_THAN_10_0
-+#ifndef LLVM_OLDER_THAN_11_0
-+                                 llvm::Align(
-+#else
-                                  llvm::MaybeAlign(
-+#endif
- #endif
-                                      MAX_EXTENDED_ALIGNMENT
- #ifndef LLVM_OLDER_THAN_10_0
-@@ -1012,7 +1027,11 @@ 
Workgroup::createDefaultWorkgroupLauncher(llvm::Function *F) {
-         Arg = new llvm::AllocaInst(ArgElementType, 
ParamType->getAddressSpace(),
-                                    ElementCount,
- #ifndef LLVM_OLDER_THAN_10_0
-+#ifndef LLVM_OLDER_THAN_11_0
-+                                   llvm::Align(
-+#else
-                                    llvm::MaybeAlign(
-+#endif
- #endif
-                                        MAX_EXTENDED_ALIGNMENT
- #ifndef LLVM_OLDER_THAN_10_0
-@@ -1213,7 +1232,11 @@ Workgroup::createArgBufferWorkgroupLauncher(Function 
*Func,
-             unwrap(ArgElementType), LLVMGetPointerAddressSpace(ParamType),
-             unwrap(LLVMConstInt(Int32Type, 1, 0)),
- #ifndef LLVM_OLDER_THAN_10_0
-+#ifndef LLVM_OLDER_THAN_11_0
-+            llvm::Align(
-+#else
-             llvm::MaybeAlign(
-+#endif
- #endif
-                 MAX_EXTENDED_ALIGNMENT
- #ifndef LLVM_OLDER_THAN_10_0
-@@ -1248,7 +1271,11 @@ Workgroup::createArgBufferWorkgroupLauncher(Function 
*Func,
-             unwrap(LLVMGetElementType(ParamType)),
-             LLVMGetPointerAddressSpace(ParamType), unwrap(ElementCount),
- #ifndef LLVM_OLDER_THAN_10_0
-+#ifndef LLVM_OLDER_THAN_11_0
-+            llvm::Align(
-+#else
-             llvm::MaybeAlign(
-+#endif
- #endif
-                 MAX_EXTENDED_ALIGNMENT
- #ifndef LLVM_OLDER_THAN_10_0
-@@ -1362,7 +1389,11 @@ Workgroup::createGridLauncher(Function *KernFunc, 
Function *WGFunc,
-   LLVMBuildRetVoid(Builder);
- 
-   InlineFunctionInfo IFI;
--  InlineFunction(dyn_cast<CallInst>(llvm::unwrap(Call)), IFI);
-+#ifndef LLVM_OLDER_THAN_11_0
-+      InlineFunction(*dyn_cast<CallInst>(llvm::unwrap(Call)), IFI);
-+#else
-+      InlineFunction(dyn_cast<CallInst>(llvm::unwrap(Call)), IFI);
-+#endif
- }
- 
- /**
-diff --git a/lib/llvmopencl/WorkitemLoops.cc b/lib/llvmopencl/WorkitemLoops.cc
-index 69daa3fa..64294111 100644
---- a/lib/llvmopencl/WorkitemLoops.cc
-+++ b/lib/llvmopencl/WorkitemLoops.cc
-@@ -990,7 +990,11 @@ WorkitemLoops::GetContextArray(llvm::Instruction 
*instruction,
-      size. */
-     Alloca->setAlignment(
- #ifndef LLVM_OLDER_THAN_10_0
-+#ifndef LLVM_OLDER_THAN_11_0
-+        llvm::Align(
-+#else
-         llvm::MaybeAlign(
-+#endif
- #endif
-             CONTEXT_ARRAY_ALIGN
- #ifndef LLVM_OLDER_THAN_10_0
-
-From 39912829f8d36b2cfc6df996ee177bf59be47f88 Mon Sep 17 00:00:00 2001
-From: Michal Babej <michal.ba...@tuni.fi>
-Date: Wed, 26 Aug 2020 01:28:43 +0300
-Subject: [PATCH 3/6] LLVM 11 fixes
-
-(cherry picked from commit 65b84f3fd4cd39c19f9cb87c183d9b434185b879)
----
- lib/CL/pocl_build.c            | 10 ++++++++++
- lib/CL/pocl_llvm_build.cc      |  4 ++++
- lib/kernel/host/CMakeLists.txt |  6 ++++++
- 3 files changed, 20 insertions(+)
-
-diff --git a/lib/CL/pocl_build.c b/lib/CL/pocl_build.c
-index ca0258ad..a85a2b64 100644
---- a/lib/CL/pocl_build.c
-+++ b/lib/CL/pocl_build.c
-@@ -263,10 +263,20 @@ process_options (const char *options, char 
*modded_options, char *link_options,
-                   *requires_correctly_rounded_sqrt_div = 1;
-                 }
-             }
-+
-           if (strstr (cl_parameters, token))
-             {
-               /* the LLVM API call pushes the parameters directly to the
-                  frontend without using -Xclang */
-+
-+#ifndef LLVM_OLDER_THAN_11_0
-+            // LLVM 11 has removed "-cl-denorms-are-zero" option
-+            // https://reviews.llvm.org/D69878
-+            if (strncmp(token, "-cl-denorms-are-zero", 20) == 0) {
-+                token = "-fdenormal-fp-math=positive-zero";
-+            }
-+#endif
-+
-             }
-           else if (strstr (cl_parameters_not_yet_supported_by_clang, token))
-             {
-diff --git a/lib/CL/pocl_llvm_build.cc b/lib/CL/pocl_llvm_build.cc
-index 6b5c8168..ed13901e 100644
---- a/lib/CL/pocl_llvm_build.cc
-+++ b/lib/CL/pocl_llvm_build.cc
-@@ -52,6 +52,10 @@ IGNORE_COMPILER_WARNING("-Wstrict-aliasing")
- #include "llvm/IR/Function.h"
- #include "llvm/IR/Module.h"
- 
-+#ifndef LLVM_OLDER_THAN_11_0
-+#include "llvm/Support/Host.h"
-+#endif
-+
- #ifdef ENABLE_RELOCATION
- 
- #if defined(__APPLE__)
-diff --git a/lib/kernel/host/CMakeLists.txt b/lib/kernel/host/CMakeLists.txt
-index c9e0f6dd..6d503116 100644
---- a/lib/kernel/host/CMakeLists.txt
-+++ b/lib/kernel/host/CMakeLists.txt
-@@ -300,6 +300,12 @@ set(KERNEL_CL_FLAGS
-       "-D__OPENCL_C_VERSION__=${HOST_DEVICE_CL_VERSION}"
-       ${KERNEL_CL_FLAGS})
- 
-+# https://bugzilla.mozilla.org/show_bug.cgi?id=1657502
-+# this *likely* shouldn't be a problem for PoCL, but needs testing
-+if(LLVM_VERSION_MAJOR GREATER 10)
-+  list(APPEND KERNEL_CL_FLAGS "-Wno-psabi")
-+endif()
-+
- separate_arguments(HOST_CLANG_FLAGS)
- separate_arguments(HOST_LLC_FLAGS)
- set(DEVICE_C_FLAGS "-DPOCL_DEVICE_ADDRESS_BITS=${HOST_DEVICE_ADDRESS_BITS}")
-
-From 980f588231de49072351c29bd5e3701eb3800504 Mon Sep 17 00:00:00 2001
-From: Michal Babej <michal.ba...@tuni.fi>
-Date: Mon, 14 Sep 2020 11:23:30 +0300
-Subject: [PATCH 4/6] CUDA: LLVM 11 support
-
-(cherry picked from commit b1229d22f004de98dec410c6bb80c4624ab304e6)
----
- lib/CL/devices/cuda/pocl-ptx-gen.cc | 59 +++++++++++++++++++++++++++--
- 1 file changed, 56 insertions(+), 3 deletions(-)
-
-diff --git a/lib/CL/devices/cuda/pocl-ptx-gen.cc 
b/lib/CL/devices/cuda/pocl-ptx-gen.cc
-index 00f9a46b..c633d83b 100644
---- a/lib/CL/devices/cuda/pocl-ptx-gen.cc
-+++ b/lib/CL/devices/cuda/pocl-ptx-gen.cc
-@@ -41,6 +41,9 @@
- #include "llvm/Support/FileSystem.h"
- #include "llvm/Support/TargetRegistry.h"
- #include "llvm/Support/TargetSelect.h"
-+#ifndef LLVM_OLDER_THAN_11_0
-+#include "llvm/Support/Alignment.h"
-+#endif
- #include "llvm/Target/TargetMachine.h"
- #include "llvm/Target/TargetOptions.h"
- #include "llvm/Transforms/IPO.h"
-@@ -107,12 +110,18 @@ int pocl_ptx_gen(const char *BitcodeFilename, const char 
*PTXFilename,
-     }
-   }
- 
-+#ifdef LLVM_OLDER_THAN_11_0
-   llvm::StringRef Triple =
-       (sizeof(void *) == 8) ? "nvptx64-nvidia-cuda" : "nvptx-nvidia-cuda";
-+#else
-+  std::string Triple =
-+      (sizeof(void *) == 8) ? "nvptx64-nvidia-cuda" : "nvptx-nvidia-cuda";
-+#endif
- 
-   // Get NVPTX target.
-   const llvm::Target *Target =
-       llvm::TargetRegistry::lookupTarget(Triple, Error);
-+
-   if (!Target) {
-     POCL_MSG_ERR("[CUDA] ptx-gen: failed to get target\n");
-     POCL_MSG_ERR("%s\n", Error.c_str());
-@@ -147,8 +156,13 @@ int pocl_ptx_gen(const char *BitcodeFilename, const char 
*PTXFilename,
-   // Run passes.
-   Passes.run(**Module);
- 
-+#ifdef LLVM_OLDER_THAN_11_0
-   std::string PTX = PTXStream.str();
-   return pocl_write_file(PTXFilename, PTX.c_str(), PTX.size(), 0, 0);
-+#else
-+  llvm::StringRef PTX = PTXStream.str();
-+  return pocl_write_file(PTXFilename, PTX.data(), PTX.size(), 0, 0);
-+#endif
- }
- 
- // Add the metadata needed to mark a function as a kernel in PTX.
-@@ -218,12 +232,25 @@ void fixPrintF(llvm::Module *Module) {
-                                         OldPrintF->getBasicBlockList());
- 
-   // Create i32 to hold current argument index.
-+#ifdef LLVM_OLDER_THAN_11_0
-   llvm::AllocaInst *ArgIndexPtr =
-       new llvm::AllocaInst(I32, 0, llvm::ConstantInt::get(I32, 1));
-   ArgIndexPtr->insertBefore(&*NewPrintF->begin()->begin());
-+#else
-+  llvm::AllocaInst *ArgIndexPtr =
-+      new llvm::AllocaInst(I32, 0, llvm::ConstantInt::get(I32, 1), 
llvm::Align(4));
-+  ArgIndexPtr->insertBefore(&*NewPrintF->begin()->begin());
-+#endif
-+
-+#ifdef LLVM_OLDER_THAN_11_0
-   llvm::StoreInst *ArgIndexInit =
-       new llvm::StoreInst(llvm::ConstantInt::get(I32, 0), ArgIndexPtr);
-   ArgIndexInit->insertAfter(ArgIndexPtr);
-+#else
-+  llvm::StoreInst *ArgIndexInit =
-+      new llvm::StoreInst(llvm::ConstantInt::get(I32, 0), ArgIndexPtr, false, 
llvm::Align(4));
-+  ArgIndexInit->insertAfter(ArgIndexPtr);
-+#endif
- 
-   // Replace calls to _cl_va_arg with reads from new i64 array argument.
-   llvm::Function *VaArgFunc = Module->getFunction("__cl_va_arg");
-@@ -239,9 +266,13 @@ void fixPrintF(llvm::Module *Module) {
-         continue;
- 
-       // Get current argument index.
-+#ifdef LLVM_OLDER_THAN_11_0
-       llvm::LoadInst *ArgIndex = new llvm::LoadInst(ArgIndexPtr);
-       ArgIndex->insertBefore(Call);
--
-+#else
-+      llvm::LoadInst *ArgIndex = new llvm::LoadInst(I32, ArgIndexPtr, 
"poclCudaLoad", false, llvm::Align(4));
-+      ArgIndex->insertBefore(Call);
-+#endif
-       // Get pointer to argument data.
-       llvm::Value *ArgOut = Call->getArgOperand(1);
-       llvm::GetElementPtrInst *ArgIn =
-@@ -254,18 +285,29 @@ void fixPrintF(llvm::Module *Module) {
-       ArgOut = ArgOutBC;
- 
-       // Load argument.
-+#ifdef LLVM_OLDER_THAN_11_0
-       llvm::LoadInst *ArgValue = new llvm::LoadInst(ArgIn);
-       ArgValue->insertAfter(ArgIn);
-       llvm::StoreInst *ArgStore = new llvm::StoreInst(ArgValue, ArgOut);
-       ArgStore->insertAfter(ArgOutBC);
--
-+#else
-+      llvm::LoadInst *ArgValue = new llvm::LoadInst(I64, ArgIn, 
"poclCudaArgLoad", false, llvm::Align(8));
-+      ArgValue->insertAfter(ArgIn);
-+      llvm::StoreInst *ArgStore = new llvm::StoreInst(ArgValue, ArgOut, 
false, llvm::Align(8));
-+      ArgStore->insertAfter(ArgOutBC);
-+#endif
-       // Increment argument index.
-       llvm::BinaryOperator *Inc = llvm::BinaryOperator::Create(
-           llvm::BinaryOperator::Add, ArgIndex, llvm::ConstantInt::get(I32, 
1));
-       Inc->insertAfter(ArgIndex);
-+
-+#ifdef LLVM_OLDER_THAN_11_0
-       llvm::StoreInst *StoreInc = new llvm::StoreInst(Inc, ArgIndexPtr);
-       StoreInc->insertAfter(Inc);
--
-+#else
-+      llvm::StoreInst *StoreInc = new llvm::StoreInst(Inc, ArgIndexPtr, 
false, llvm::Align(4));
-+      StoreInc->insertAfter(Inc);
-+#endif
-       // Remove call to _cl_va_arg.
-       Call->eraseFromParent();
-     }
-@@ -288,9 +330,15 @@ void fixPrintF(llvm::Module *Module) {
- 
-     // Allocate array for arguments.
-     // TODO: Deal with vector arguments.
-+#ifdef LLVM_OLDER_THAN_11_0
-     llvm::AllocaInst *Args =
-         new llvm::AllocaInst(I64, 0, llvm::ConstantInt::get(I32, NumArgs));
-     Args->insertBefore(Call);
-+#else
-+    llvm::AllocaInst *Args =
-+        new llvm::AllocaInst(I64, 0, llvm::ConstantInt::get(I32, NumArgs), 
llvm::Align(8));
-+    Args->insertBefore(Call);
-+#endif
- 
-     // Loop over arguments (skipping format).
-     for (unsigned A = 0; A < NumArgs; A++) {
-@@ -322,8 +370,13 @@ void fixPrintF(llvm::Module *Module) {
-       }
- 
-       // Store argument to i64 array.
-+#ifdef LLVM_OLDER_THAN_11_0
-       llvm::StoreInst *Store = new llvm::StoreInst(Arg, ArgPtr);
-       Store->insertBefore(Call);
-+#else
-+      llvm::StoreInst *Store = new llvm::StoreInst(Arg, ArgPtr, false, 
llvm::Align(8));
-+      Store->insertBefore(Call);
-+#endif
-     }
- 
-     // Fix address space of undef format values.
-
-From 112861d721bb07147699ce9d481c47be38d05266 Mon Sep 17 00:00:00 2001
-From: Michal Babej <michal.ba...@tuni.fi>
-Date: Sat, 19 Sep 2020 10:49:42 +0300
-Subject: [PATCH 5/6] LLVM 11: "-dwarf-column-info" option has been turned into
- an opt-out
-
-(cherry picked from commit ec70212530db80ac798671042e523bc51e8c9598)
----
- lib/CL/pocl_build.c | 5 +++++
- 1 file changed, 5 insertions(+)
-
-diff --git a/lib/CL/pocl_build.c b/lib/CL/pocl_build.c
-index a85a2b64..0e4061ce 100644
---- a/lib/CL/pocl_build.c
-+++ b/lib/CL/pocl_build.c
-@@ -295,8 +295,13 @@ process_options (const char *options, char 
*modded_options, char *link_options,
-         }
-       else if (strncmp (token, "-g", 2) == 0)
-         {
-+#ifdef LLVM_OLDER_THAN_11_0
-           token = "-dwarf-column-info -debug-info-kind=limited " \
-           "-dwarf-version=4 -debugger-tuning=gdb";
-+#else
-+          token = "-debug-info-kind=limited " \
-+          "-dwarf-version=4 -debugger-tuning=gdb";
-+#endif
-         }
-       else if (strncmp (token, "-D", 2) == 0 || strncmp (token, "-I", 2) == 0)
-         {
-
-From 8e91f2aaba823fa1e3d059c9dc21a8f2a8e56dca Mon Sep 17 00:00:00 2001
-From: Michal Babej <michal.ba...@tuni.fi>
-Date: Wed, 23 Sep 2020 22:06:35 +0300
-Subject: [PATCH 6/6] AMD SDK 3.0: fix SobelFilter
-
-with C99 and OpenCL, if conversion from float to int
-without saturation is called with argument outside integer
-range, behaviour is unspecified.
-
-SobelFilter uses convert_uchar4(float4) in OpenCL and simple
-typecast in reference C code, both of which resulted in
-code truncating floats to uchar range. Until LLVM 11, which
-now generates x86 instructions which cause saturation.
-
-It seems it's not possible to specify non-saturating conversion
-in OpenCL, so this patch changes both the kernel code and the
-reference C code to convert with saturation.
-
-(cherry picked from commit de7f4088e493775f68e11fd8c694d52290438401)
----
- examples/AMDSDK3.0/amdsdk3_0.patch | 31 +++++++++++++++++++++++++-----
- 1 file changed, 26 insertions(+), 5 deletions(-)
-
-diff --git a/examples/AMDSDK3.0/amdsdk3_0.patch 
b/examples/AMDSDK3.0/amdsdk3_0.patch
-index 2419fc54..5f2b57fe 100644
---- a/examples/AMDSDK3.0/amdsdk3_0.patch
-+++ b/examples/AMDSDK3.0/amdsdk3_0.patch
-@@ -89,10 +89,31 @@
-  
-  
-  __kernel 
--@@ -162,4 +162,4 @@
--      
-+--- a/AMD-APP-SDK-3.0/samples/opencl/cl/1.x/SobelFilter/SobelFilter.cpp       
2020-09-23 14:19:55.137508386 +0300
-++++ b/AMD-APP-SDK-3.0/samples/opencl/cl/1.x/SobelFilter/SobelFilter.cpp       
2020-09-23 14:22:33.230012800 +0300
-+@@ -550,8 +550,9 @@
-+             float gx2 = pow((float)gx, 2);
-+             float gy2 = pow((float)gy, 2);
-+ 
-+-
-+-            *(verificationOutput + i) = (cl_uchar)(sqrt(gx2 + gy2) / 2.0);
-++            float tmp = sqrt(gx2 + gy2) / 2.0;
-++            if (tmp > 255.0f) tmp = 255.0f;
-++            *(verificationOutput + i) = (cl_uchar)(tmp);
-+         }
-+ 
-+         // if reached at the end of its row then incr k
-+--- 
a/AMD-APP-SDK-3.0/samples/opencl/cl/1.x/SobelFilter/SobelFilter_Kernels.cl      
  2015-10-28 05:15:19.000000000 +0200
-++++ 
b/AMD-APP-SDK-3.0/samples/opencl/cl/1.x/SobelFilter/SobelFilter_Kernels.cl      
  2020-09-23 14:20:31.365623958 +0300
-+@@ -56,10 +56,8 @@
-+              Gy =   i00 - i20  + (float4)(2)*i01 - (float4)(2)*i21 + i02  -  
i22;
-+ 
-+              /* taking root of sums of squares of Gx and Gy */
-+-             outputImage[c] = convert_uchar4(hypot(Gx, Gy)/(float4)(2));
-+-
-++             outputImage[c] = convert_uchar4_sat(hypot(Gx, Gy)/(float4)(2));
-+      }
-+-                     
-+ }
-  
-       
---     
--\ No newline at end of file
--+     
-

Copied: pocl/repos/community-x86_64/llvm11.patch (from rev 776692, 
pocl/trunk/llvm11.patch)
===================================================================
--- llvm11.patch                                (rev 0)
+++ llvm11.patch        2020-12-16 13:35:42 UTC (rev 776693)
@@ -0,0 +1,696 @@
+From 749a80b2c832771ef3eb6d9af39807dbad97d218 Mon Sep 17 00:00:00 2001
+From: KOLANICH <kola...@mail.ru>
+Date: Mon, 3 Feb 2020 11:55:10 +0300
+Subject: [PATCH 1/6] LLVM11 support
+
+(cherry picked from commit 1e31e34cd1f6f9f045ca72a8a26caa8e34a43c4f)
+---
+ cmake/LLVM.cmake                    |  6 +++++-
+ config.h.in.cmake                   |  4 ++++
+ include/CMakeLists.txt              |  2 +-
+ include/_kernel.h                   | 24 ++++++------------------
+ include/_libclang_versions_checks.h | 24 ++++++++++++++++++++++++
+ include/pocl.h                      | 22 ++--------------------
+ lib/CL/pocl_llvm_wg.cc              |  4 ++--
+ lib/kernel/CMakeLists.txt           |  1 +
+ 8 files changed, 45 insertions(+), 42 deletions(-)
+ create mode 100644 include/_libclang_versions_checks.h
+
+diff --git a/cmake/LLVM.cmake b/cmake/LLVM.cmake
+index 33c45750..b41e75a9 100644
+--- a/cmake/LLVM.cmake
++++ b/cmake/LLVM.cmake
+@@ -37,6 +37,7 @@ else()
+   # search for any version
+   find_program(LLVM_CONFIG
+     NAMES
++      "llvm-config-mp-11.0" "llvm-config-11" "llvm-config110"
+       "llvm-config-mp-10.0" "llvm-config-10" "llvm-config100"
+       "llvm-config-mp-9.0" "llvm-config-9" "llvm-config90"
+       "llvm-config-mp-8.0" "llvm-config-8" "llvm-config80"
+@@ -180,8 +181,11 @@ elseif(LLVM_VERSION MATCHES "^9[.]")
+ elseif(LLVM_VERSION MATCHES "^10[.]")
+   set(LLVM_MAJOR 10)
+   set(LLVM_10_0 1)
++elseif(LLVM_VERSION MATCHES "^11[.]")
++  set(LLVM_MAJOR 11)
++  set(LLVM_11_0 1)
+ else()
+-  message(FATAL_ERROR "LLVM version between 6.0 and 10.0 required, found: 
${LLVM_VERSION}")
++  message(FATAL_ERROR "LLVM version between 6.0 and 11.0 required, found: 
${LLVM_VERSION}")
+ endif()
+ 
+ #############################################################
+diff --git a/config.h.in.cmake b/config.h.in.cmake
+index 42c63f77..7c6c0eb4 100644
+--- a/config.h.in.cmake
++++ b/config.h.in.cmake
+@@ -152,6 +152,10 @@
+ 
+ #cmakedefine LLVM_10_0
+ 
++#cmakedefine LLVM_11_0
++
++#cmakedefine LLVM_MAJOR @LLVM_VERSION_MAJOR@
++
+ #cmakedefine LLVM_BUILD_MODE_DEBUG
+ 
+ #ifndef LLVM_VERSION
+diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt
+index 321df9d5..31883269 100644
+--- a/include/CMakeLists.txt
++++ b/include/CMakeLists.txt
+@@ -27,7 +27,7 @@ add_subdirectory("CL")
+ 
+ set(PRIVATE_HEADERS _enable_all_exts.h _builtin_renames.h
+                     _kernel.h _clang_opencl.h
+-                    _kernel_c.h _kernel_constants.h
++                    _kernel_c.h _kernel_constants.h 
_libclang_versions_checks.h
+                     pocl_types.h pocl_device.h pocl.h pocl_spir.h
+                     pocl_image_types.h)
+ 
+diff --git a/include/_kernel.h b/include/_kernel.h
+index 427794e3..90154648 100644
+--- a/include/_kernel.h
++++ b/include/_kernel.h
+@@ -143,32 +143,20 @@
+ # undef LLVM_10_0
+ # define LLVM_10_0
+ 
++#elif (__clang_major__ == 11)
++
++# undef LLVM_11_0
++# define LLVM_11_0
+ #else
+ 
+ #error Unsupported Clang/LLVM version.
+ 
+ #endif
+ 
+-#ifndef LLVM_10_0
+-#define LLVM_OLDER_THAN_10_0 1
+-
+-#ifndef LLVM_9_0
+-#define LLVM_OLDER_THAN_9_0 1
+-
+-#ifndef LLVM_8_0
+-#define LLVM_OLDER_THAN_8_0 1
++#define CLANG_MAJOR __clang_major__
++#include "_libclang_versions_checks.h"
+ 
+-#ifndef LLVM_7_0
+-#define LLVM_OLDER_THAN_7_0 1
+ 
+-#ifndef LLVM_6_0
+-#define LLVM_OLDER_THAN_6_0 1
+-
+-#endif
+-#endif
+-#endif
+-#endif
+-#endif
+ 
+ /****************************************************************************/
+ 
+diff --git a/include/_libclang_versions_checks.h 
b/include/_libclang_versions_checks.h
+new file mode 100644
+index 00000000..1ba0ce4d
+--- /dev/null
++++ b/include/_libclang_versions_checks.h
+@@ -0,0 +1,24 @@
++
++#if CLANG_MAJOR < 11
++#define LLVM_OLDER_THAN_11_0 1
++#endif
++
++#if CLANG_MAJOR < 10
++#define LLVM_OLDER_THAN_10_0 1
++#endif
++
++#if CLANG_MAJOR < 9
++#define LLVM_OLDER_THAN_9_0 1
++#endif
++
++#if CLANG_MAJOR < 8
++#define LLVM_OLDER_THAN_8_0 1
++#endif
++
++#if CLANG_MAJOR < 7
++#define LLVM_OLDER_THAN_7_0 1
++#endif
++
++#if CLANG_MAJOR < 6
++#define LLVM_OLDER_THAN_6_0 1
++#endif
+diff --git a/include/pocl.h b/include/pocl.h
+index 1fad38cc..4c175c07 100644
+--- a/include/pocl.h
++++ b/include/pocl.h
+@@ -369,25 +369,7 @@ struct _cl_command_node
+   cl_int ready;
+ };
+ 
+-#ifndef LLVM_10_0
+-#define LLVM_OLDER_THAN_10_0 1
+-
+-#ifndef LLVM_9_0
+-#define LLVM_OLDER_THAN_9_0 1
+-
+-#ifndef LLVM_8_0
+-#define LLVM_OLDER_THAN_8_0 1
+-
+-#ifndef LLVM_7_0
+-#define LLVM_OLDER_THAN_7_0 1
+-
+-#ifndef LLVM_6_0
+-#define LLVM_OLDER_THAN_6_0 1
+-
+-#endif
+-#endif
+-#endif
+-#endif
+-#endif
++#define CLANG_MAJOR LLVM_MAJOR
++#include "_libclang_versions_checks.h"
+ 
+ #endif /* POCL_H */
+diff --git a/lib/CL/pocl_llvm_wg.cc b/lib/CL/pocl_llvm_wg.cc
+index b8e4ac5f..561a80ad 100644
+--- a/lib/CL/pocl_llvm_wg.cc
++++ b/lib/CL/pocl_llvm_wg.cc
+@@ -625,8 +625,8 @@ int pocl_llvm_codegen(cl_device_id Device, void *Modp, 
char **Output,
+ #ifdef DUMP_LLVM_PASS_TIMINGS
+     llvm::reportAndResetTimings();
+ #endif
+-    std::string O = SOS.str(); // flush
+-    const char *Cstr = O.c_str();
++    auto O = SOS.str(); // flush
++    const char *Cstr = O.data();
+     size_t S = O.size();
+     *Output = (char *)malloc(S);
+     *OutputSize = S;
+diff --git a/lib/kernel/CMakeLists.txt b/lib/kernel/CMakeLists.txt
+index e2cfd71e..1f0c9cff 100644
+--- a/lib/kernel/CMakeLists.txt
++++ b/lib/kernel/CMakeLists.txt
+@@ -229,6 +229,7 @@ add_custom_command( OUTPUT 
"${CMAKE_BINARY_DIR}/kernellib_hash.h"
+   DEPENDS ${KERNEL_BC_LIST}
+       "${CMAKE_SOURCE_DIR}/include/_kernel.h"
+       "${CMAKE_SOURCE_DIR}/include/_kernel_c.h"
++      "${CMAKE_SOURCE_DIR}/include/_libclang_versions_checks.h"
+       "${CMAKE_SOURCE_DIR}/include/pocl_types.h"
+   COMMENT "Generating SHA1 of all kernel libs..."
+   VERBATIM)
+
+From b1906c650da86bd1045472fe99e082f354592b11 Mon Sep 17 00:00:00 2001
+From: KOLANICH <kola...@mail.ru>
+Date: Mon, 22 Jun 2020 15:53:45 +0300
+Subject: [PATCH 2/6] Fixing llvm11 support due to recent changes:
+ 
https://github.com/llvm/llvm-project/commit/4f04db4b5439f390c48408f9b94875810e88ffc6
+ 
https://github.com/llvm/llvm-project/commit/a58b62b4a2b96c31b49338b262b609db746449e8
+ 
https://github.com/llvm/llvm-project/commit/4aae4e3f48b9156755c4cfc7ad63fe2a7029d9d7
+ .
+
+(cherry picked from commit dae742fae9978c524ec849a90d0b40a9682fb172)
+---
+ lib/llvmopencl/HandleSamplerInitialization.cc |  4 +++
+ lib/llvmopencl/HandleSamplerInitialization.h  |  1 -
+ lib/llvmopencl/Workgroup.cc                   | 35 +++++++++++++++++--
+ lib/llvmopencl/WorkitemLoops.cc               |  4 +++
+ 4 files changed, 41 insertions(+), 3 deletions(-)
+
+diff --git a/lib/llvmopencl/HandleSamplerInitialization.cc 
b/lib/llvmopencl/HandleSamplerInitialization.cc
+index 4cbc5617..5d65c48f 100644
+--- a/lib/llvmopencl/HandleSamplerInitialization.cc
++++ b/lib/llvmopencl/HandleSamplerInitialization.cc
+@@ -79,7 +79,11 @@ HandleSamplerInitialization::runOnFunction(Function &F) {
+ 
+     // get the type of the return value of __translate_sampler
+     // this may not always be opencl.sampler_t, it could be a remapped type.
++#ifdef LLVM_OLDER_THAN_11_0
+     Type *type = C->getCalledValue()->getType();
++#else
++    Type *type = C->getCalledOperand()->getType();
++#endif
+     PointerType *pt = dyn_cast<PointerType>(type);
+     FunctionType *ft = dyn_cast<FunctionType>(pt->getPointerElementType());
+     Type *rettype = ft->getReturnType();
+diff --git a/lib/llvmopencl/HandleSamplerInitialization.h 
b/lib/llvmopencl/HandleSamplerInitialization.h
+index e8274e50..dc7539e2 100644
+--- a/lib/llvmopencl/HandleSamplerInitialization.h
++++ b/lib/llvmopencl/HandleSamplerInitialization.h
+@@ -27,7 +27,6 @@
+ IGNORE_COMPILER_WARNING("-Wunused-parameter")
+ 
+ #include <llvm/IR/Function.h>
+-#include <llvm/PassAnalysisSupport.h>
+ #include <llvm/Pass.h>
+ 
+ POP_COMPILER_DIAGS
+diff --git a/lib/llvmopencl/Workgroup.cc b/lib/llvmopencl/Workgroup.cc
+index 357049a1..0ae2f34c 100644
+--- a/lib/llvmopencl/Workgroup.cc
++++ b/lib/llvmopencl/Workgroup.cc
+@@ -35,7 +35,9 @@ IGNORE_COMPILER_WARNING("-Wunused-parameter")
+ 
+ #include <llvm/Analysis/ConstantFolding.h>
+ #include <llvm/IR/BasicBlock.h>
++#ifdef LLVM_OLDER_THAN_11_0
+ #include <llvm/IR/CallSite.h>
++#endif
+ #include <llvm/IR/Constants.h>
+ #include <llvm/IR/DerivedTypes.h>
+ #include <llvm/IR/IRBuilder.h>
+@@ -517,10 +519,15 @@ static void replacePrintfCalls(Value *pb, Value *pbp, 
Value *pbc, bool isKernel,
+         for (unsigned i = 0; i < j; ++i)
+           ops.push_back(CallInstr->getOperand(i));
+ 
+-        CallSite CS(CallInstr);
+         CallInst *NewCI = CallInst::Create(poclPrintf, ops);
+         NewCI->setCallingConv(poclPrintf->getCallingConv());
++#ifdef LLVM_OLDER_THAN_11_0
++        CallSite CS(CallInstr);
+         NewCI->setTailCall(CS.isTailCall());
++#else
++        auto *CB = dyn_cast<CallBase>(CallInstr);
++        NewCI->setTailCall(CB->isTailCall());
++#endif
+ 
+         replaceCIMap.insert(
+             std::pair<CallInst *, CallInst *>(CallInstr, NewCI));
+@@ -719,7 +726,11 @@ Workgroup::createWrapper(Function *F, FunctionMapping 
&printfCache) {
+ 
+   // needed for printf
+   InlineFunctionInfo IFI;
++#ifdef LLVM_OLDER_THAN_11_0
+   InlineFunction(c, IFI);
++#else
++  InlineFunction(*c, IFI);
++#endif
+ 
+   if (currentPoclDevice->device_side_printf) {
+     Function *poclPrintf = M->getFunction("__pocl_printf");
+@@ -989,7 +1000,11 @@ Workgroup::createDefaultWorkgroupLauncher(llvm::Function 
*F) {
+             new llvm::AllocaInst(ArgElementType, ParamType->getAddressSpace(),
+                                  ConstantInt::get(IntegerType::get(*C, 32), 
1),
+ #ifndef LLVM_OLDER_THAN_10_0
++#ifndef LLVM_OLDER_THAN_11_0
++                                 llvm::Align(
++#else
+                                  llvm::MaybeAlign(
++#endif
+ #endif
+                                      MAX_EXTENDED_ALIGNMENT
+ #ifndef LLVM_OLDER_THAN_10_0
+@@ -1012,7 +1027,11 @@ 
Workgroup::createDefaultWorkgroupLauncher(llvm::Function *F) {
+         Arg = new llvm::AllocaInst(ArgElementType, 
ParamType->getAddressSpace(),
+                                    ElementCount,
+ #ifndef LLVM_OLDER_THAN_10_0
++#ifndef LLVM_OLDER_THAN_11_0
++                                   llvm::Align(
++#else
+                                    llvm::MaybeAlign(
++#endif
+ #endif
+                                        MAX_EXTENDED_ALIGNMENT
+ #ifndef LLVM_OLDER_THAN_10_0
+@@ -1213,7 +1232,11 @@ Workgroup::createArgBufferWorkgroupLauncher(Function 
*Func,
+             unwrap(ArgElementType), LLVMGetPointerAddressSpace(ParamType),
+             unwrap(LLVMConstInt(Int32Type, 1, 0)),
+ #ifndef LLVM_OLDER_THAN_10_0
++#ifndef LLVM_OLDER_THAN_11_0
++            llvm::Align(
++#else
+             llvm::MaybeAlign(
++#endif
+ #endif
+                 MAX_EXTENDED_ALIGNMENT
+ #ifndef LLVM_OLDER_THAN_10_0
+@@ -1248,7 +1271,11 @@ Workgroup::createArgBufferWorkgroupLauncher(Function 
*Func,
+             unwrap(LLVMGetElementType(ParamType)),
+             LLVMGetPointerAddressSpace(ParamType), unwrap(ElementCount),
+ #ifndef LLVM_OLDER_THAN_10_0
++#ifndef LLVM_OLDER_THAN_11_0
++            llvm::Align(
++#else
+             llvm::MaybeAlign(
++#endif
+ #endif
+                 MAX_EXTENDED_ALIGNMENT
+ #ifndef LLVM_OLDER_THAN_10_0
+@@ -1362,7 +1389,11 @@ Workgroup::createGridLauncher(Function *KernFunc, 
Function *WGFunc,
+   LLVMBuildRetVoid(Builder);
+ 
+   InlineFunctionInfo IFI;
+-  InlineFunction(dyn_cast<CallInst>(llvm::unwrap(Call)), IFI);
++#ifndef LLVM_OLDER_THAN_11_0
++      InlineFunction(*dyn_cast<CallInst>(llvm::unwrap(Call)), IFI);
++#else
++      InlineFunction(dyn_cast<CallInst>(llvm::unwrap(Call)), IFI);
++#endif
+ }
+ 
+ /**
+diff --git a/lib/llvmopencl/WorkitemLoops.cc b/lib/llvmopencl/WorkitemLoops.cc
+index 69daa3fa..64294111 100644
+--- a/lib/llvmopencl/WorkitemLoops.cc
++++ b/lib/llvmopencl/WorkitemLoops.cc
+@@ -990,7 +990,11 @@ WorkitemLoops::GetContextArray(llvm::Instruction 
*instruction,
+      size. */
+     Alloca->setAlignment(
+ #ifndef LLVM_OLDER_THAN_10_0
++#ifndef LLVM_OLDER_THAN_11_0
++        llvm::Align(
++#else
+         llvm::MaybeAlign(
++#endif
+ #endif
+             CONTEXT_ARRAY_ALIGN
+ #ifndef LLVM_OLDER_THAN_10_0
+
+From 39912829f8d36b2cfc6df996ee177bf59be47f88 Mon Sep 17 00:00:00 2001
+From: Michal Babej <michal.ba...@tuni.fi>
+Date: Wed, 26 Aug 2020 01:28:43 +0300
+Subject: [PATCH 3/6] LLVM 11 fixes
+
+(cherry picked from commit 65b84f3fd4cd39c19f9cb87c183d9b434185b879)
+---
+ lib/CL/pocl_build.c            | 10 ++++++++++
+ lib/CL/pocl_llvm_build.cc      |  4 ++++
+ lib/kernel/host/CMakeLists.txt |  6 ++++++
+ 3 files changed, 20 insertions(+)
+
+diff --git a/lib/CL/pocl_build.c b/lib/CL/pocl_build.c
+index ca0258ad..a85a2b64 100644
+--- a/lib/CL/pocl_build.c
++++ b/lib/CL/pocl_build.c
+@@ -263,10 +263,20 @@ process_options (const char *options, char 
*modded_options, char *link_options,
+                   *requires_correctly_rounded_sqrt_div = 1;
+                 }
+             }
++
+           if (strstr (cl_parameters, token))
+             {
+               /* the LLVM API call pushes the parameters directly to the
+                  frontend without using -Xclang */
++
++#ifndef LLVM_OLDER_THAN_11_0
++            // LLVM 11 has removed "-cl-denorms-are-zero" option
++            // https://reviews.llvm.org/D69878
++            if (strncmp(token, "-cl-denorms-are-zero", 20) == 0) {
++                token = "-fdenormal-fp-math=positive-zero";
++            }
++#endif
++
+             }
+           else if (strstr (cl_parameters_not_yet_supported_by_clang, token))
+             {
+diff --git a/lib/CL/pocl_llvm_build.cc b/lib/CL/pocl_llvm_build.cc
+index 6b5c8168..ed13901e 100644
+--- a/lib/CL/pocl_llvm_build.cc
++++ b/lib/CL/pocl_llvm_build.cc
+@@ -52,6 +52,10 @@ IGNORE_COMPILER_WARNING("-Wstrict-aliasing")
+ #include "llvm/IR/Function.h"
+ #include "llvm/IR/Module.h"
+ 
++#ifndef LLVM_OLDER_THAN_11_0
++#include "llvm/Support/Host.h"
++#endif
++
+ #ifdef ENABLE_RELOCATION
+ 
+ #if defined(__APPLE__)
+diff --git a/lib/kernel/host/CMakeLists.txt b/lib/kernel/host/CMakeLists.txt
+index c9e0f6dd..6d503116 100644
+--- a/lib/kernel/host/CMakeLists.txt
++++ b/lib/kernel/host/CMakeLists.txt
+@@ -300,6 +300,12 @@ set(KERNEL_CL_FLAGS
+       "-D__OPENCL_C_VERSION__=${HOST_DEVICE_CL_VERSION}"
+       ${KERNEL_CL_FLAGS})
+ 
++# https://bugzilla.mozilla.org/show_bug.cgi?id=1657502
++# this *likely* shouldn't be a problem for PoCL, but needs testing
++if(LLVM_VERSION_MAJOR GREATER 10)
++  list(APPEND KERNEL_CL_FLAGS "-Wno-psabi")
++endif()
++
+ separate_arguments(HOST_CLANG_FLAGS)
+ separate_arguments(HOST_LLC_FLAGS)
+ set(DEVICE_C_FLAGS "-DPOCL_DEVICE_ADDRESS_BITS=${HOST_DEVICE_ADDRESS_BITS}")
+
+From 980f588231de49072351c29bd5e3701eb3800504 Mon Sep 17 00:00:00 2001
+From: Michal Babej <michal.ba...@tuni.fi>
+Date: Mon, 14 Sep 2020 11:23:30 +0300
+Subject: [PATCH 4/6] CUDA: LLVM 11 support
+
+(cherry picked from commit b1229d22f004de98dec410c6bb80c4624ab304e6)
+---
+ lib/CL/devices/cuda/pocl-ptx-gen.cc | 59 +++++++++++++++++++++++++++--
+ 1 file changed, 56 insertions(+), 3 deletions(-)
+
+diff --git a/lib/CL/devices/cuda/pocl-ptx-gen.cc 
b/lib/CL/devices/cuda/pocl-ptx-gen.cc
+index 00f9a46b..c633d83b 100644
+--- a/lib/CL/devices/cuda/pocl-ptx-gen.cc
++++ b/lib/CL/devices/cuda/pocl-ptx-gen.cc
+@@ -41,6 +41,9 @@
+ #include "llvm/Support/FileSystem.h"
+ #include "llvm/Support/TargetRegistry.h"
+ #include "llvm/Support/TargetSelect.h"
++#ifndef LLVM_OLDER_THAN_11_0
++#include "llvm/Support/Alignment.h"
++#endif
+ #include "llvm/Target/TargetMachine.h"
+ #include "llvm/Target/TargetOptions.h"
+ #include "llvm/Transforms/IPO.h"
+@@ -107,12 +110,18 @@ int pocl_ptx_gen(const char *BitcodeFilename, const char 
*PTXFilename,
+     }
+   }
+ 
++#ifdef LLVM_OLDER_THAN_11_0
+   llvm::StringRef Triple =
+       (sizeof(void *) == 8) ? "nvptx64-nvidia-cuda" : "nvptx-nvidia-cuda";
++#else
++  std::string Triple =
++      (sizeof(void *) == 8) ? "nvptx64-nvidia-cuda" : "nvptx-nvidia-cuda";
++#endif
+ 
+   // Get NVPTX target.
+   const llvm::Target *Target =
+       llvm::TargetRegistry::lookupTarget(Triple, Error);
++
+   if (!Target) {
+     POCL_MSG_ERR("[CUDA] ptx-gen: failed to get target\n");
+     POCL_MSG_ERR("%s\n", Error.c_str());
+@@ -147,8 +156,13 @@ int pocl_ptx_gen(const char *BitcodeFilename, const char 
*PTXFilename,
+   // Run passes.
+   Passes.run(**Module);
+ 
++#ifdef LLVM_OLDER_THAN_11_0
+   std::string PTX = PTXStream.str();
+   return pocl_write_file(PTXFilename, PTX.c_str(), PTX.size(), 0, 0);
++#else
++  llvm::StringRef PTX = PTXStream.str();
++  return pocl_write_file(PTXFilename, PTX.data(), PTX.size(), 0, 0);
++#endif
+ }
+ 
+ // Add the metadata needed to mark a function as a kernel in PTX.
+@@ -218,12 +232,25 @@ void fixPrintF(llvm::Module *Module) {
+                                         OldPrintF->getBasicBlockList());
+ 
+   // Create i32 to hold current argument index.
++#ifdef LLVM_OLDER_THAN_11_0
+   llvm::AllocaInst *ArgIndexPtr =
+       new llvm::AllocaInst(I32, 0, llvm::ConstantInt::get(I32, 1));
+   ArgIndexPtr->insertBefore(&*NewPrintF->begin()->begin());
++#else
++  llvm::AllocaInst *ArgIndexPtr =
++      new llvm::AllocaInst(I32, 0, llvm::ConstantInt::get(I32, 1), 
llvm::Align(4));
++  ArgIndexPtr->insertBefore(&*NewPrintF->begin()->begin());
++#endif
++
++#ifdef LLVM_OLDER_THAN_11_0
+   llvm::StoreInst *ArgIndexInit =
+       new llvm::StoreInst(llvm::ConstantInt::get(I32, 0), ArgIndexPtr);
+   ArgIndexInit->insertAfter(ArgIndexPtr);
++#else
++  llvm::StoreInst *ArgIndexInit =
++      new llvm::StoreInst(llvm::ConstantInt::get(I32, 0), ArgIndexPtr, false, 
llvm::Align(4));
++  ArgIndexInit->insertAfter(ArgIndexPtr);
++#endif
+ 
+   // Replace calls to _cl_va_arg with reads from new i64 array argument.
+   llvm::Function *VaArgFunc = Module->getFunction("__cl_va_arg");
+@@ -239,9 +266,13 @@ void fixPrintF(llvm::Module *Module) {
+         continue;
+ 
+       // Get current argument index.
++#ifdef LLVM_OLDER_THAN_11_0
+       llvm::LoadInst *ArgIndex = new llvm::LoadInst(ArgIndexPtr);
+       ArgIndex->insertBefore(Call);
+-
++#else
++      llvm::LoadInst *ArgIndex = new llvm::LoadInst(I32, ArgIndexPtr, 
"poclCudaLoad", false, llvm::Align(4));
++      ArgIndex->insertBefore(Call);
++#endif
+       // Get pointer to argument data.
+       llvm::Value *ArgOut = Call->getArgOperand(1);
+       llvm::GetElementPtrInst *ArgIn =
+@@ -254,18 +285,29 @@ void fixPrintF(llvm::Module *Module) {
+       ArgOut = ArgOutBC;
+ 
+       // Load argument.
++#ifdef LLVM_OLDER_THAN_11_0
+       llvm::LoadInst *ArgValue = new llvm::LoadInst(ArgIn);
+       ArgValue->insertAfter(ArgIn);
+       llvm::StoreInst *ArgStore = new llvm::StoreInst(ArgValue, ArgOut);
+       ArgStore->insertAfter(ArgOutBC);
+-
++#else
++      llvm::LoadInst *ArgValue = new llvm::LoadInst(I64, ArgIn, 
"poclCudaArgLoad", false, llvm::Align(8));
++      ArgValue->insertAfter(ArgIn);
++      llvm::StoreInst *ArgStore = new llvm::StoreInst(ArgValue, ArgOut, 
false, llvm::Align(8));
++      ArgStore->insertAfter(ArgOutBC);
++#endif
+       // Increment argument index.
+       llvm::BinaryOperator *Inc = llvm::BinaryOperator::Create(
+           llvm::BinaryOperator::Add, ArgIndex, llvm::ConstantInt::get(I32, 
1));
+       Inc->insertAfter(ArgIndex);
++
++#ifdef LLVM_OLDER_THAN_11_0
+       llvm::StoreInst *StoreInc = new llvm::StoreInst(Inc, ArgIndexPtr);
+       StoreInc->insertAfter(Inc);
+-
++#else
++      llvm::StoreInst *StoreInc = new llvm::StoreInst(Inc, ArgIndexPtr, 
false, llvm::Align(4));
++      StoreInc->insertAfter(Inc);
++#endif
+       // Remove call to _cl_va_arg.
+       Call->eraseFromParent();
+     }
+@@ -288,9 +330,15 @@ void fixPrintF(llvm::Module *Module) {
+ 
+     // Allocate array for arguments.
+     // TODO: Deal with vector arguments.
++#ifdef LLVM_OLDER_THAN_11_0
+     llvm::AllocaInst *Args =
+         new llvm::AllocaInst(I64, 0, llvm::ConstantInt::get(I32, NumArgs));
+     Args->insertBefore(Call);
++#else
++    llvm::AllocaInst *Args =
++        new llvm::AllocaInst(I64, 0, llvm::ConstantInt::get(I32, NumArgs), 
llvm::Align(8));
++    Args->insertBefore(Call);
++#endif
+ 
+     // Loop over arguments (skipping format).
+     for (unsigned A = 0; A < NumArgs; A++) {
+@@ -322,8 +370,13 @@ void fixPrintF(llvm::Module *Module) {
+       }
+ 
+       // Store argument to i64 array.
++#ifdef LLVM_OLDER_THAN_11_0
+       llvm::StoreInst *Store = new llvm::StoreInst(Arg, ArgPtr);
+       Store->insertBefore(Call);
++#else
++      llvm::StoreInst *Store = new llvm::StoreInst(Arg, ArgPtr, false, 
llvm::Align(8));
++      Store->insertBefore(Call);
++#endif
+     }
+ 
+     // Fix address space of undef format values.
+
+From 112861d721bb07147699ce9d481c47be38d05266 Mon Sep 17 00:00:00 2001
+From: Michal Babej <michal.ba...@tuni.fi>
+Date: Sat, 19 Sep 2020 10:49:42 +0300
+Subject: [PATCH 5/6] LLVM 11: "-dwarf-column-info" option has been turned into
+ an opt-out
+
+(cherry picked from commit ec70212530db80ac798671042e523bc51e8c9598)
+---
+ lib/CL/pocl_build.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/lib/CL/pocl_build.c b/lib/CL/pocl_build.c
+index a85a2b64..0e4061ce 100644
+--- a/lib/CL/pocl_build.c
++++ b/lib/CL/pocl_build.c
+@@ -295,8 +295,13 @@ process_options (const char *options, char 
*modded_options, char *link_options,
+         }
+       else if (strncmp (token, "-g", 2) == 0)
+         {
++#ifdef LLVM_OLDER_THAN_11_0
+           token = "-dwarf-column-info -debug-info-kind=limited " \
+           "-dwarf-version=4 -debugger-tuning=gdb";
++#else
++          token = "-debug-info-kind=limited " \
++          "-dwarf-version=4 -debugger-tuning=gdb";
++#endif
+         }
+       else if (strncmp (token, "-D", 2) == 0 || strncmp (token, "-I", 2) == 0)
+         {
+
+From 8e91f2aaba823fa1e3d059c9dc21a8f2a8e56dca Mon Sep 17 00:00:00 2001
+From: Michal Babej <michal.ba...@tuni.fi>
+Date: Wed, 23 Sep 2020 22:06:35 +0300
+Subject: [PATCH 6/6] AMD SDK 3.0: fix SobelFilter
+
+with C99 and OpenCL, if conversion from float to int
+without saturation is called with argument outside integer
+range, behaviour is unspecified.
+
+SobelFilter uses convert_uchar4(float4) in OpenCL and simple
+typecast in reference C code, both of which resulted in
+code truncating floats to uchar range. Until LLVM 11, which
+now generates x86 instructions which cause saturation.
+
+It seems it's not possible to specify non-saturating conversion
+in OpenCL, so this patch changes both the kernel code and the
+reference C code to convert with saturation.
+
+(cherry picked from commit de7f4088e493775f68e11fd8c694d52290438401)
+---
+ examples/AMDSDK3.0/amdsdk3_0.patch | 31 +++++++++++++++++++++++++-----
+ 1 file changed, 26 insertions(+), 5 deletions(-)
+
+diff --git a/examples/AMDSDK3.0/amdsdk3_0.patch 
b/examples/AMDSDK3.0/amdsdk3_0.patch
+index 2419fc54..5f2b57fe 100644
+--- a/examples/AMDSDK3.0/amdsdk3_0.patch
++++ b/examples/AMDSDK3.0/amdsdk3_0.patch
+@@ -89,10 +89,31 @@
+  
+  
+  __kernel 
+-@@ -162,4 +162,4 @@
+-      
++--- a/AMD-APP-SDK-3.0/samples/opencl/cl/1.x/SobelFilter/SobelFilter.cpp       
2020-09-23 14:19:55.137508386 +0300
+++++ b/AMD-APP-SDK-3.0/samples/opencl/cl/1.x/SobelFilter/SobelFilter.cpp       
2020-09-23 14:22:33.230012800 +0300
++@@ -550,8 +550,9 @@
++             float gx2 = pow((float)gx, 2);
++             float gy2 = pow((float)gy, 2);
++ 
++-
++-            *(verificationOutput + i) = (cl_uchar)(sqrt(gx2 + gy2) / 2.0);
+++            float tmp = sqrt(gx2 + gy2) / 2.0;
+++            if (tmp > 255.0f) tmp = 255.0f;
+++            *(verificationOutput + i) = (cl_uchar)(tmp);
++         }
++ 
++         // if reached at the end of its row then incr k
++--- 
a/AMD-APP-SDK-3.0/samples/opencl/cl/1.x/SobelFilter/SobelFilter_Kernels.cl      
  2015-10-28 05:15:19.000000000 +0200
+++++ 
b/AMD-APP-SDK-3.0/samples/opencl/cl/1.x/SobelFilter/SobelFilter_Kernels.cl      
  2020-09-23 14:20:31.365623958 +0300
++@@ -56,10 +56,8 @@
++              Gy =   i00 - i20  + (float4)(2)*i01 - (float4)(2)*i21 + i02  -  
i22;
++ 
++              /* taking root of sums of squares of Gx and Gy */
++-             outputImage[c] = convert_uchar4(hypot(Gx, Gy)/(float4)(2));
++-
+++             outputImage[c] = convert_uchar4_sat(hypot(Gx, Gy)/(float4)(2));
++      }
++-                     
++ }
+  
+       
+--     
+-\ No newline at end of file
+-+     
+

Reply via email to