meta-intel/dynamic-layers/clang-layer/recipes-core/ispc/ispc/ec35a6f8e60ba77e59a6f2bfec27011e0ab34dda.patch
Anuj Mittal ad81baa4f5 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>
2022-09-19 15:19:13 +08:00

64 lines
2.5 KiB
Diff

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());