ispc: fix build with LLVM 15

Backport patches to fix build with LLVM 15 which is now the default
version in meta-clang master.

Signed-off-by: Anuj Mittal <anuj.mittal@intel.com>
This commit is contained in:
Anuj Mittal 2022-09-15 21:53:09 +08:00
parent 3b6b2b8825
commit ad81baa4f5
3 changed files with 98 additions and 0 deletions

View File

@ -0,0 +1,33 @@
From 6a1b2ffae0cc12467838bc671e3b089924de90a6 Mon Sep 17 00:00:00 2001
From: Dmitry Babokin <dmitry.y.babokin@intel.com>
Date: Thu, 5 May 2022 16:34:34 -0700
Subject: [PATCH] Bump ISPC version v1.19.0dev
Upstream-Status: Backport
Include only the LLVM specific bits and not the ispc version bump.
Signed-off-by: Anuj Mittal <anuj.mittal@intel.com>
---
diff --git a/src/ispc_version.h b/src/ispc_version.h
index 0e28dfcfa..2b9d9b0cc 100644
--- a/src/ispc_version.h
+++ b/src/ispc_version.h
@@ -51,7 +51,7 @@
#define ISPC_LLVM_15_0 150000
#define OLDEST_SUPPORTED_LLVM ISPC_LLVM_10_0
-#define LATEST_SUPPORTED_LLVM ISPC_LLVM_14_0
+#define LATEST_SUPPORTED_LLVM ISPC_LLVM_15_0
#ifdef __ispc__xstr
#undef __ispc__xstr
@@ -63,7 +63,7 @@
__ispc__xstr(LLVM_VERSION_MAJOR) "." __ispc__xstr(LLVM_VERSION_MINOR) "." __ispc__xstr(LLVM_VERSION_PATCH)
#if ISPC_LLVM_VERSION < OLDEST_SUPPORTED_LLVM || ISPC_LLVM_VERSION > LATEST_SUPPORTED_LLVM
-#error "Only LLVM 11.0 - 14.0 are supported"
+#error "Only LLVM 11.0 - 14.0 and 15.0 development branch are supported"
#endif
#define ISPC_VERSION_STRING \

View File

@ -0,0 +1,63 @@
From ec35a6f8e60ba77e59a6f2bfec27011e0ab34dda Mon Sep 17 00:00:00 2001
From: Arina Neshlyaeva <arina.neshlyaeva@intel.com>
Date: Tue, 23 Aug 2022 15:21:50 -0700
Subject: [PATCH] Adjust opt passes for LLVM 15
Upstream-Status: Backport
Signed-off-by: Anuj Mittal <anuj.mittal@intel.com>
---
src/opt.cpp | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/src/opt.cpp b/src/opt.cpp
index 910821e26..86219f384 100644
--- a/src/opt.cpp
+++ b/src/opt.cpp
@@ -84,6 +84,9 @@
#include <llvm/Transforms/Scalar.h>
#include <llvm/Transforms/Scalar/GVN.h>
#include <llvm/Transforms/Scalar/InstSimplifyPass.h>
+#if ISPC_LLVM_VERSION >= ISPC_LLVM_15_0
+#include <llvm/Transforms/Scalar/SimpleLoopUnswitch.h>
+#endif
#include <llvm/Transforms/Utils.h>
#include <llvm/Transforms/Utils/BasicBlockUtils.h>
@@ -647,7 +650,11 @@ void ispc::Optimize(llvm::Module *module, int optLevel) {
optPM.add(llvm::createCFGSimplificationPass());
#endif
+#if ISPC_LLVM_VERSION < ISPC_LLVM_15_0
+ // Starting LLVM 15.0 this pass is supported with new pass manager only (217e857)
+ // TODO: switch ISPC to new pass manager: https://github.com/ispc/ispc/issues/2359
optPM.add(llvm::createArgumentPromotionPass());
+#endif
optPM.add(llvm::createAggressiveDCEPass());
optPM.add(llvm::createInstructionCombiningPass(), 241);
@@ -722,7 +729,11 @@ void ispc::Optimize(llvm::Module *module, int optLevel) {
optPM.add(CreateInstructionSimplifyPass());
optPM.add(llvm::createFunctionInliningPass());
+#if ISPC_LLVM_VERSION < ISPC_LLVM_15_0
+ // Starting LLVM 15.0 this pass is supported with new pass manager only (217e857)
+ // TODO: switch ISPC to new pass manager: https://github.com/ispc/ispc/issues/2359
optPM.add(llvm::createArgumentPromotionPass());
+#endif
optPM.add(llvm::createSROAPass());
@@ -736,7 +747,13 @@ void ispc::Optimize(llvm::Module *module, int optLevel) {
optPM.add(llvm::createReassociatePass());
optPM.add(llvm::createLoopRotatePass());
optPM.add(llvm::createLICMPass());
+ // Loop unswitch pass was removed in LLVM 15.0 (fb4113).
+ // Recommended replacement: createSimpleLoopUnswitchLegacyPass
+#if ISPC_LLVM_VERSION < ISPC_LLVM_15_0
optPM.add(llvm::createLoopUnswitchPass(false));
+#else
+ optPM.add(llvm::createSimpleLoopUnswitchLegacyPass(false));
+#endif
optPM.add(llvm::createInstructionCombiningPass());
optPM.add(CreateInstructionSimplifyPass());
optPM.add(llvm::createIndVarSimplifyPass());

View File

@ -15,6 +15,8 @@ SRC_URI = "git://github.com/ispc/ispc.git;protocol=https;branch=main \
file://0001-CMakeLists.txt-link-with-libclang-cpp-library-instea.patch \
file://0002-cmake-don-t-build-for-32-bit-targets.patch \
file://0001-Fix-QA-Issues.patch \
file://6a1b2ffae0cc12467838bc671e3b089924de90a6.patch \
file://ec35a6f8e60ba77e59a6f2bfec27011e0ab34dda.patch \
"
SRCREV = "f7ec3aa173c816377c215d83196b5c7c3a88db1c"