summaryrefslogtreecommitdiffstats
path: root/dynamic-layers/clang-layer/recipes-core/ispc/ispc/ec35a6f8e60ba77e59a6f2bfec27011e0ab34dda.patch
blob: a5ab8c19afe20114e1e1be010c8b3ac0972b5e1f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
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());