summaryrefslogtreecommitdiff
path: root/beignet-llvm7-support.patch
blob: 9d460ce643858c9a1d2a9327b29d6ed91d4a5bf1 (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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
Description: Add LLVM 7 support

1.Change linking order, as clangCodeGen now links to clangFrontend
2.Pass references not pointers to WriteBitcodeToFile and CloneModule
3.Add the headers that LoopSimplifyID, LCSSAID and
some create*Pass have moved to
4.Define our DEBUG whether or not we just undefined LLVM's
(theirs is now LLVM_DEBUG, but we never actually use it)

Author: Rebecca N. Palmer <rebecca_palmer@zoho.com>
Bug-Debian: https://bugs.debian.org/912787
Forwarded: https://lists.freedesktop.org/archives/beignet/2018-July/009212.html

--- a/CMake/FindLLVM.cmake
+++ b/CMake/FindLLVM.cmake
@@ -113,10 +113,10 @@ macro(add_one_lib name)
 endmacro()
 
 #Assume clang lib path same as llvm lib path
+add_one_lib("clangCodeGen")
 add_one_lib("clangFrontend")
 add_one_lib("clangSerialization")
 add_one_lib("clangDriver")
-add_one_lib("clangCodeGen")
 add_one_lib("clangSema")
 add_one_lib("clangStaticAnalyzerFrontend")
 add_one_lib("clangStaticAnalyzerCheckers")
--- a/backend/src/backend/gen_program.cpp
+++ b/backend/src/backend/gen_program.cpp
@@ -449,7 +449,11 @@ namespace gbe {
 #ifdef GBE_COMPILER_AVAILABLE
       std::string str;
       llvm::raw_string_ostream OS(str);
+#if LLVM_VERSION_MAJOR >= 7
+      llvm::WriteBitcodeToFile(*((llvm::Module*)prog->module), OS);
+#else
       llvm::WriteBitcodeToFile((llvm::Module*)prog->module, OS);
+#endif
       std::string& bin_str = OS.str();
       int llsz = bin_str.size();
       *binary = (char *)malloc(sizeof(char) * (llsz+1) );
@@ -540,7 +544,11 @@ namespace gbe {
                                     &modRef);
         src = llvm::unwrap(modRef);
       }
+#if LLVM_VERSION_MAJOR >= 7
+      llvm::Module* clone = llvm::CloneModule(*src).release();
+#else
       llvm::Module* clone = llvm::CloneModule(src).release();
+#endif
       if (LLVMLinkModules2(wrap(dst), wrap(clone))) {
 #elif LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 37
       if (LLVMLinkModules(wrap(dst), wrap(src), LLVMLinkerPreserveSource_Removed, &errMsg)) {
--- a/backend/src/backend/program.cpp
+++ b/backend/src/backend/program.cpp
@@ -794,7 +794,11 @@ namespace gbe {
       llvm::raw_fd_ostream ostream (dumpSPIRBinaryName.c_str(),
                                     err, llvm::sys::fs::F_None);
       if (!err)
+#if LLVM_VERSION_MAJOR<7
         llvm::WriteBitcodeToFile(*out_module, ostream);
+#else
+        llvm::WriteBitcodeToFile(**out_module, ostream);
+#endif
     }
 #endif
     return true;
--- a/backend/src/llvm/llvm_bitcode_link.cpp
+++ b/backend/src/llvm/llvm_bitcode_link.cpp
@@ -340,7 +340,11 @@ namespace gbe
     /* We use beignet's bitcode as dst because it will have a lot of
        lazy functions which will not be loaded. */
 #if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 39
+#if LLVM_VERSION_MAJOR >= 7
+    llvm::Module * linked_module = llvm::CloneModule(*(llvm::Module*)mod).release();
+#else
     llvm::Module * linked_module = llvm::CloneModule((llvm::Module*)mod).release();
+#endif
     if(LLVMLinkModules2(wrap(clonedLib), wrap(linked_module))) {
 #else
     char* errorMsg;
--- a/backend/src/llvm/llvm_includes.hpp
+++ b/backend/src/llvm/llvm_includes.hpp
@@ -89,6 +89,10 @@
 #include "llvm/CodeGen/IntrinsicLowering.h"
 
 #include "llvm/Transforms/Scalar.h"
+#if LLVM_VERSION_MAJOR >= 7
+#include "llvm/Transforms/Utils.h"
+#include "llvm/Transforms/InstCombine/InstCombine.h"
+#endif
 #include "llvm/MC/MCAsmInfo.h"
 #include "llvm/MC/MCContext.h"
 #include "llvm/MC/MCInstrInfo.h"
--- a/backend/src/llvm/ExpandLargeIntegers.cpp
+++ b/backend/src/llvm/ExpandLargeIntegers.cpp
@@ -99,8 +99,8 @@ using namespace llvm;
 
 #ifdef DEBUG
   #undef DEBUG
-  #define DEBUG(...)
 #endif
+#define DEBUG(...)
 // Break instructions up into no larger than 64-bit chunks.
 static const unsigned kChunkBits = 64;
 static const unsigned kChunkBytes = kChunkBits / CHAR_BIT;