]>
Commit | Line | Data |
---|---|---|
7d3d7cb5 JB |
1 | Description: Add LLVM 7 support |
2 | ||
3 | 1.Change linking order, as clangCodeGen now links to clangFrontend | |
4 | 2.Pass references not pointers to WriteBitcodeToFile and CloneModule | |
5 | 3.Add the headers that LoopSimplifyID, LCSSAID and | |
6 | some create*Pass have moved to | |
7 | 4.Define our DEBUG whether or not we just undefined LLVM's | |
8 | (theirs is now LLVM_DEBUG, but we never actually use it) | |
9 | ||
10 | Author: Rebecca N. Palmer <rebecca_palmer@zoho.com> | |
11 | Bug-Debian: https://bugs.debian.org/912787 | |
12 | Forwarded: https://lists.freedesktop.org/archives/beignet/2018-July/009212.html | |
13 | ||
14 | --- a/CMake/FindLLVM.cmake | |
15 | +++ b/CMake/FindLLVM.cmake | |
16 | @@ -113,10 +113,10 @@ macro(add_one_lib name) | |
17 | endmacro() | |
18 | ||
19 | #Assume clang lib path same as llvm lib path | |
20 | +add_one_lib("clangCodeGen") | |
21 | add_one_lib("clangFrontend") | |
22 | add_one_lib("clangSerialization") | |
23 | add_one_lib("clangDriver") | |
24 | -add_one_lib("clangCodeGen") | |
25 | add_one_lib("clangSema") | |
26 | add_one_lib("clangStaticAnalyzerFrontend") | |
27 | add_one_lib("clangStaticAnalyzerCheckers") | |
28 | --- a/backend/src/backend/gen_program.cpp | |
29 | +++ b/backend/src/backend/gen_program.cpp | |
30 | @@ -449,7 +449,11 @@ namespace gbe { | |
31 | #ifdef GBE_COMPILER_AVAILABLE | |
32 | std::string str; | |
33 | llvm::raw_string_ostream OS(str); | |
34 | +#if LLVM_VERSION_MAJOR >= 7 | |
35 | + llvm::WriteBitcodeToFile(*((llvm::Module*)prog->module), OS); | |
36 | +#else | |
37 | llvm::WriteBitcodeToFile((llvm::Module*)prog->module, OS); | |
38 | +#endif | |
39 | std::string& bin_str = OS.str(); | |
40 | int llsz = bin_str.size(); | |
41 | *binary = (char *)malloc(sizeof(char) * (llsz+1) ); | |
42 | @@ -540,7 +544,11 @@ namespace gbe { | |
43 | &modRef); | |
44 | src = llvm::unwrap(modRef); | |
45 | } | |
46 | +#if LLVM_VERSION_MAJOR >= 7 | |
47 | + llvm::Module* clone = llvm::CloneModule(*src).release(); | |
48 | +#else | |
49 | llvm::Module* clone = llvm::CloneModule(src).release(); | |
50 | +#endif | |
51 | if (LLVMLinkModules2(wrap(dst), wrap(clone))) { | |
52 | #elif LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 37 | |
53 | if (LLVMLinkModules(wrap(dst), wrap(src), LLVMLinkerPreserveSource_Removed, &errMsg)) { | |
54 | --- a/backend/src/backend/program.cpp | |
55 | +++ b/backend/src/backend/program.cpp | |
56 | @@ -794,7 +794,11 @@ namespace gbe { | |
57 | llvm::raw_fd_ostream ostream (dumpSPIRBinaryName.c_str(), | |
58 | err, llvm::sys::fs::F_None); | |
59 | if (!err) | |
60 | +#if LLVM_VERSION_MAJOR<7 | |
61 | llvm::WriteBitcodeToFile(*out_module, ostream); | |
62 | +#else | |
63 | + llvm::WriteBitcodeToFile(**out_module, ostream); | |
64 | +#endif | |
65 | } | |
66 | #endif | |
67 | return true; | |
68 | --- a/backend/src/llvm/llvm_bitcode_link.cpp | |
69 | +++ b/backend/src/llvm/llvm_bitcode_link.cpp | |
70 | @@ -340,7 +340,11 @@ namespace gbe | |
71 | /* We use beignet's bitcode as dst because it will have a lot of | |
72 | lazy functions which will not be loaded. */ | |
73 | #if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 39 | |
74 | +#if LLVM_VERSION_MAJOR >= 7 | |
75 | + llvm::Module * linked_module = llvm::CloneModule(*(llvm::Module*)mod).release(); | |
76 | +#else | |
77 | llvm::Module * linked_module = llvm::CloneModule((llvm::Module*)mod).release(); | |
78 | +#endif | |
79 | if(LLVMLinkModules2(wrap(clonedLib), wrap(linked_module))) { | |
80 | #else | |
81 | char* errorMsg; | |
82 | --- a/backend/src/llvm/llvm_includes.hpp | |
83 | +++ b/backend/src/llvm/llvm_includes.hpp | |
84 | @@ -89,6 +89,10 @@ | |
85 | #include "llvm/CodeGen/IntrinsicLowering.h" | |
86 | ||
87 | #include "llvm/Transforms/Scalar.h" | |
88 | +#if LLVM_VERSION_MAJOR >= 7 | |
89 | +#include "llvm/Transforms/Utils.h" | |
90 | +#include "llvm/Transforms/InstCombine/InstCombine.h" | |
91 | +#endif | |
92 | #include "llvm/MC/MCAsmInfo.h" | |
93 | #include "llvm/MC/MCContext.h" | |
94 | #include "llvm/MC/MCInstrInfo.h" | |
95 | --- a/backend/src/llvm/ExpandLargeIntegers.cpp | |
96 | +++ b/backend/src/llvm/ExpandLargeIntegers.cpp | |
97 | @@ -99,8 +99,8 @@ using namespace llvm; | |
98 | ||
99 | #ifdef DEBUG | |
100 | #undef DEBUG | |
101 | - #define DEBUG(...) | |
102 | #endif | |
103 | +#define DEBUG(...) | |
104 | // Break instructions up into no larger than 64-bit chunks. | |
105 | static const unsigned kChunkBits = 64; | |
106 | static const unsigned kChunkBytes = kChunkBits / CHAR_BIT; |