#16 Rebuild for LLVM11
Closed 3 years ago by tstellar. Opened 3 years ago by tstellar.
rpms/ tstellar/pocl llvm11  into  master

@@ -0,0 +1,25 @@ 

+ From 76179ea2fae3efa996bd850e09b5f3ba73ff5144 Mon Sep 17 00:00:00 2001

+ From: Tom Stellard <tstellar@redhat.com>

+ Date: Tue, 11 Aug 2020 14:23:42 +0000

+ Subject: [PATCH] Add missing include

+ 

+ ---

+  lib/CL/pocl_llvm_build.cc | 2 ++

+  1 file changed, 2 insertions(+)

+ 

+ diff --git a/lib/CL/pocl_llvm_build.cc b/lib/CL/pocl_llvm_build.cc

+ index 5db8d7cb..197171f4 100644

+ --- a/lib/CL/pocl_llvm_build.cc

+ +++ b/lib/CL/pocl_llvm_build.cc

+ @@ -40,6 +40,8 @@ IGNORE_COMPILER_WARNING("-Wstrict-aliasing")

+  #include <clang/Frontend/TextDiagnosticPrinter.h>

+  #include "clang/Lex/PreprocessorOptions.h"

+  

+ +#include <llvm/Support/Host.h>

+ +

+  #ifdef LLVM_OLDER_THAN_10_0

+  #include "llvm/ADT/ArrayRef.h"

+  #endif

+ -- 

+ 2.26.2

+ 

@@ -0,0 +1,167 @@ 

+ From dae742fae9978c524ec849a90d0b40a9682fb172 Mon Sep 17 00:00:00 2001

+ From: KOLANICH <kolan_n@mail.ru>

+ Date: Mon, 22 Jun 2020 15:53:45 +0300

+ Subject: [PATCH] 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

+  .

+ 

+ ---

+  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

+ -- 

+ 2.26.2

+ 

@@ -0,0 +1,205 @@ 

+ From 3fa73c66ca2582dc45024e5c3a4bd5a170570ee5 Mon Sep 17 00:00:00 2001

+ From: KOLANICH <kolan_n@mail.ru>

+ Date: Mon, 3 Feb 2020 11:55:10 +0300

+ Subject: [PATCH] LLVM11 support

+ 

+ ---

+  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)

+ -- 

+ 2.26.2

+ 

file modified
+7 -1
@@ -4,7 +4,7 @@ 

  Name:           pocl

  %global ver 1.5

  Version:        %{lua:ver = string.gsub(rpm.expand("%{ver}"), "-", "~"); print(string.lower(ver))}

- Release:        6%{?dist}

+ Release:        7%{?dist}

  Summary:        Portable Computing Language - an OpenCL implementation

  # The whole code is under MIT

  # except include/utlist.h which is under BSD (and unbundled) and
@@ -13,6 +13,9 @@ 

  URL:            http://portablecl.org/

  Source0:        https://github.com/pocl/pocl/archive/v%{version}/%{name}-%{version}.tar.gz

  Patch0:         0001-Fix-build-failure.patch

+ Patch1:         0001-LLVM11-support.patch

+ Patch2:         0001-Fixing-llvm11-support-due-to-recent-changes.patch

+ Patch3:         0001-Add-missing-include.patch

  

  BuildRequires:  cmake

  BuildRequires:  clang clang-devel
@@ -120,6 +123,9 @@ 

  %{_libdir}/pkgconfig/%{name}.pc

  

  %changelog

+ * Tue Aug 11 2020 Tom Stellard <tstellar@redhat.com> - 1.5-7

+ - Rebuild for LLVM11

+ 

  * Tue Aug 04 2020 Peter Robinson <pbrobinson@fedoraproject.org> - 1.5-6

  - Update for cmake change, build for all arches