beignet-1.3.2-llvm10-support.patch 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  1. diff -upr beignet.orig/backend/src/backend/program.cpp beignet/backend/src/backend/program.cpp
  2. --- beignet.orig/backend/src/backend/program.cpp 2020-04-16 03:44:21.153955099 +0300
  3. +++ beignet/backend/src/backend/program.cpp 2020-04-16 03:47:50.369205839 +0300
  4. @@ -694,9 +694,14 @@ namespace gbe {
  5. #endif
  6. );
  7. + llvm::cl::ResetAllOptionOccurrences();
  8. clang::CompilerInvocation::CreateFromArgs(*CI,
  9. +#if LLVM_VERSION_MAJOR < 10
  10. &args[0],
  11. &args[0] + args.size(),
  12. +#else
  13. + clang::ArrayRef<const char*>(args),
  14. +#endif
  15. Diags);
  16. // Create the compiler instance
  17. clang::CompilerInstance Clang;
  18. @@ -1242,8 +1247,12 @@ EXTEND_QUOTE:
  19. // Create the compiler invocation
  20. std::unique_ptr<clang::CompilerInvocation> CI(new clang::CompilerInvocation);
  21. return clang::CompilerInvocation::CreateFromArgs(*CI,
  22. +#if LLVM_VERSION_MAJOR < 10
  23. &args[0],
  24. &args[0] + args.size(),
  25. +#else
  26. + clang::ArrayRef<const char*>(args),
  27. +#endif
  28. Diags);
  29. }
  30. #endif
  31. Only in beignet/backend/src/backend: program.cpp.orig
  32. Only in beignet.orig/backend/src: CMakeLists.txt.orig
  33. diff -upr beignet.orig/backend/src/llvm/llvm_gen_backend.cpp beignet/backend/src/llvm/llvm_gen_backend.cpp
  34. --- beignet.orig/backend/src/llvm/llvm_gen_backend.cpp 2020-04-16 03:44:21.783970632 +0300
  35. +++ beignet/backend/src/llvm/llvm_gen_backend.cpp 2020-04-16 03:45:04.141685867 +0300
  36. @@ -575,11 +575,13 @@ namespace gbe
  37. has_errors(false),
  38. legacyMode(true)
  39. {
  40. +#if LLVM_VERSION_MAJOR < 10
  41. #if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 37
  42. initializeLoopInfoWrapperPassPass(*PassRegistry::getPassRegistry());
  43. #else
  44. initializeLoopInfoPass(*PassRegistry::getPassRegistry());
  45. #endif
  46. +#endif
  47. pass = PASS_EMIT_REGISTERS;
  48. }
  49. diff -upr beignet.orig/backend/src/llvm/llvm_gen_backend.hpp beignet/backend/src/llvm/llvm_gen_backend.hpp
  50. --- beignet.orig/backend/src/llvm/llvm_gen_backend.hpp 2020-04-16 03:44:21.177289008 +0300
  51. +++ beignet/backend/src/llvm/llvm_gen_backend.hpp 2020-04-16 03:45:04.135019035 +0300
  52. @@ -130,10 +130,10 @@ namespace gbe
  53. llvm::FunctionPass *createGenPass(ir::Unit &unit);
  54. /*! Remove the GEP instructions */
  55. - llvm::BasicBlockPass *createRemoveGEPPass(const ir::Unit &unit);
  56. + llvm::FunctionPass *createRemoveGEPPass(const ir::Unit &unit);
  57. /*! Merge load/store if possible */
  58. - llvm::BasicBlockPass *createLoadStoreOptimizationPass();
  59. + llvm::FunctionPass *createLoadStoreOptimizationPass();
  60. /*! Scalarize all vector op instructions */
  61. llvm::FunctionPass* createScalarizePass();
  62. @@ -141,7 +141,7 @@ namespace gbe
  63. llvm::ModulePass* createBarrierNodupPass(bool);
  64. /*! Convert the Intrinsic call to gen function */
  65. - llvm::BasicBlockPass *createIntrinsicLoweringPass();
  66. + llvm::FunctionPass *createIntrinsicLoweringPass();
  67. /*! Passer the printf function call. */
  68. llvm::FunctionPass* createPrintfParserPass(ir::Unit &unit);
  69. diff -upr beignet.orig/backend/src/llvm/llvm_intrinsic_lowering.cpp beignet/backend/src/llvm/llvm_intrinsic_lowering.cpp
  70. --- beignet.orig/backend/src/llvm/llvm_intrinsic_lowering.cpp 2020-04-16 03:44:21.783970632 +0300
  71. +++ beignet/backend/src/llvm/llvm_intrinsic_lowering.cpp 2020-04-16 03:45:04.135019035 +0300
  72. @@ -29,12 +29,12 @@
  73. using namespace llvm;
  74. namespace gbe {
  75. - class InstrinsicLowering : public BasicBlockPass
  76. + class InstrinsicLowering : public FunctionPass
  77. {
  78. public:
  79. static char ID;
  80. InstrinsicLowering() :
  81. - BasicBlockPass(ID) {}
  82. + FunctionPass(ID) {}
  83. void getAnalysisUsage(AnalysisUsage &AU) const {
  84. @@ -93,9 +93,9 @@ namespace gbe {
  85. CI->eraseFromParent();
  86. return NewCI;
  87. }
  88. - virtual bool runOnBasicBlock(BasicBlock &BB)
  89. + virtual bool runOnFunction(Function &F)
  90. {
  91. - bool changedBlock = false;
  92. + for (BasicBlock &BB : F) {
  93. Module *M = BB.getParent()->getParent();
  94. DataLayout TD(M);
  95. @@ -159,13 +159,14 @@ namespace gbe {
  96. }
  97. }
  98. }
  99. - return changedBlock;
  100. + }
  101. + return true;
  102. }
  103. };
  104. char InstrinsicLowering::ID = 0;
  105. - BasicBlockPass *createIntrinsicLoweringPass() {
  106. + FunctionPass *createIntrinsicLoweringPass() {
  107. return new InstrinsicLowering();
  108. }
  109. } // end namespace
  110. diff -upr beignet.orig/backend/src/llvm/llvm_loadstore_optimization.cpp beignet/backend/src/llvm/llvm_loadstore_optimization.cpp
  111. --- beignet.orig/backend/src/llvm/llvm_loadstore_optimization.cpp 2020-04-16 03:44:21.177289008 +0300
  112. +++ beignet/backend/src/llvm/llvm_loadstore_optimization.cpp 2020-04-16 03:45:38.645879307 +0300
  113. @@ -26,13 +26,13 @@
  114. using namespace llvm;
  115. namespace gbe {
  116. - class GenLoadStoreOptimization : public BasicBlockPass {
  117. + class GenLoadStoreOptimization : public FunctionPass {
  118. public:
  119. static char ID;
  120. ScalarEvolution *SE;
  121. const DataLayout *TD;
  122. - GenLoadStoreOptimization() : BasicBlockPass(ID) {}
  123. + GenLoadStoreOptimization() : FunctionPass(ID) {}
  124. void getAnalysisUsage(AnalysisUsage &AU) const {
  125. #if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 38
  126. @@ -45,7 +45,9 @@ namespace gbe {
  127. AU.setPreservesCFG();
  128. }
  129. - virtual bool runOnBasicBlock(BasicBlock &BB) {
  130. + virtual bool runOnFunction(Function &F) {
  131. + bool changedAnyBlock = false;
  132. + for (BasicBlock &BB : F) {
  133. #if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 38
  134. SE = &getAnalysis<ScalarEvolutionWrapperPass>().getSE();
  135. #else
  136. @@ -59,7 +61,9 @@ namespace gbe {
  137. #else
  138. TD = getAnalysisIfAvailable<DataLayout>();
  139. #endif
  140. - return optimizeLoadStore(BB);
  141. + changedAnyBlock = optimizeLoadStore(BB) | changedAnyBlock;
  142. + }
  143. + return changedAnyBlock;
  144. }
  145. Type *getValueType(Value *insn);
  146. Value *getPointerOperand(Value *I);
  147. @@ -159,7 +163,11 @@ namespace gbe {
  148. values.push_back(merged[i]);
  149. }
  150. LoadInst *ld = cast<LoadInst>(first);
  151. +#if LLVM_VERSION_MAJOR < 10
  152. unsigned align = ld->getAlignment();
  153. +#else
  154. + MaybeAlign align = ld->getAlign();
  155. +#endif
  156. unsigned addrSpace = ld->getPointerAddressSpace();
  157. // insert before first load
  158. Builder.SetInsertPoint(ld);
  159. @@ -352,7 +360,11 @@ namespace gbe {
  160. unsigned addrSpace = st->getPointerAddressSpace();
  161. +#if LLVM_VERSION_MAJOR < 10
  162. unsigned align = st->getAlignment();
  163. +#else
  164. + MaybeAlign align = st->getAlign();
  165. +#endif
  166. // insert before the last store
  167. Builder.SetInsertPoint(last);
  168. @@ -466,7 +478,7 @@ namespace gbe {
  169. return changed;
  170. }
  171. - BasicBlockPass *createLoadStoreOptimizationPass() {
  172. + FunctionPass *createLoadStoreOptimizationPass() {
  173. return new GenLoadStoreOptimization();
  174. }
  175. };
  176. Only in beignet/backend/src/llvm: llvm_loadstore_optimization.cpp.orig
  177. Only in beignet/backend/src/llvm: llvm_loadstore_optimization.cpp.rej
  178. diff -upr beignet.orig/backend/src/llvm/llvm_passes.cpp beignet/backend/src/llvm/llvm_passes.cpp
  179. --- beignet.orig/backend/src/llvm/llvm_passes.cpp 2020-04-16 03:44:21.177289008 +0300
  180. +++ beignet/backend/src/llvm/llvm_passes.cpp 2020-04-16 03:45:04.135019035 +0300
  181. @@ -37,7 +37,7 @@
  182. #include "sys/map.hpp"
  183. using namespace llvm;
  184. -
  185. +template class cfg::Update<BasicBlock *>;
  186. namespace gbe
  187. {
  188. bool isKernelFunction(const llvm::Function &F) {
  189. @@ -219,13 +219,13 @@ namespace gbe
  190. return offset;
  191. }
  192. - class GenRemoveGEPPasss : public BasicBlockPass
  193. + class GenRemoveGEPPasss : public FunctionPass
  194. {
  195. public:
  196. static char ID;
  197. GenRemoveGEPPasss(const ir::Unit &unit) :
  198. - BasicBlockPass(ID),
  199. + FunctionPass(ID),
  200. unit(unit) {}
  201. const ir::Unit &unit;
  202. void getAnalysisUsage(AnalysisUsage &AU) const {
  203. @@ -242,16 +242,18 @@ namespace gbe
  204. bool simplifyGEPInstructions(GetElementPtrInst* GEPInst);
  205. - virtual bool runOnBasicBlock(BasicBlock &BB)
  206. + virtual bool runOnFunction(Function &F)
  207. {
  208. - bool changedBlock = false;
  209. + bool changedAnyBlock = false;
  210. + for (BasicBlock &BB : F) {
  211. iplist<Instruction>::iterator I = BB.getInstList().begin();
  212. for (auto nextI = I, E = --BB.getInstList().end(); I != E; I = nextI) {
  213. iplist<Instruction>::iterator I = nextI++;
  214. if(GetElementPtrInst* gep = dyn_cast<GetElementPtrInst>(&*I))
  215. - changedBlock = (simplifyGEPInstructions(gep) || changedBlock);
  216. + changedAnyBlock = (simplifyGEPInstructions(gep) | changedAnyBlock);
  217. }
  218. - return changedBlock;
  219. + }
  220. + return changedAnyBlock;
  221. }
  222. };
  223. @@ -367,7 +369,7 @@ namespace gbe
  224. return true;
  225. }
  226. - BasicBlockPass *createRemoveGEPPass(const ir::Unit &unit) {
  227. + FunctionPass *createRemoveGEPPass(const ir::Unit &unit) {
  228. return new GenRemoveGEPPasss(unit);
  229. }
  230. } /* namespace gbe */
  231. diff -upr beignet.orig/backend/src/llvm/llvm_sampler_fix.cpp beignet/backend/src/llvm/llvm_sampler_fix.cpp
  232. --- beignet.orig/backend/src/llvm/llvm_sampler_fix.cpp 2020-04-16 03:44:21.783970632 +0300
  233. +++ beignet/backend/src/llvm/llvm_sampler_fix.cpp 2020-04-16 03:45:04.138352451 +0300
  234. @@ -33,11 +33,13 @@ namespace gbe {
  235. class SamplerFix : public FunctionPass {
  236. public:
  237. SamplerFix() : FunctionPass(ID) {
  238. +#if LLVM_VERSION_MAJOR < 10
  239. #if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 35
  240. initializeDominatorTreeWrapperPassPass(*PassRegistry::getPassRegistry());
  241. #else
  242. initializeDominatorTreePass(*PassRegistry::getPassRegistry());
  243. #endif
  244. +#endif
  245. }
  246. bool visitCallInst(CallInst *I) {
  247. diff -upr beignet.orig/backend/src/llvm/llvm_scalarize.cpp beignet/backend/src/llvm/llvm_scalarize.cpp
  248. --- beignet.orig/backend/src/llvm/llvm_scalarize.cpp 2020-04-16 03:44:21.670634504 +0300
  249. +++ beignet/backend/src/llvm/llvm_scalarize.cpp 2020-04-16 03:45:04.141685867 +0300
  250. @@ -96,11 +96,13 @@ namespace gbe {
  251. Scalarize() : FunctionPass(ID)
  252. {
  253. +#if LLVM_VERSION_MAJOR < 10
  254. #if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 35
  255. initializeDominatorTreeWrapperPassPass(*PassRegistry::getPassRegistry());
  256. #else
  257. initializeDominatorTreePass(*PassRegistry::getPassRegistry());
  258. #endif
  259. +#endif
  260. }
  261. virtual bool runOnFunction(Function&);
  262. diff -upr beignet.orig/CMake/FindLLVM.cmake beignet/CMake/FindLLVM.cmake
  263. --- beignet.orig/CMake/FindLLVM.cmake 2020-04-16 03:44:21.137288022 +0300
  264. +++ beignet/CMake/FindLLVM.cmake 2020-04-16 03:46:38.104039602 +0300
  265. @@ -104,30 +104,16 @@ string(REGEX REPLACE " *\n" "" LLVM_SYST
  266. endif (LLVM_SYSTEM_LIBS_ORIG)
  267. endif (LLVM_VERSION_NODOT VERSION_GREATER 34)
  268. +#something harmless because whitespace at start is an error
  269. +set(CLANG_LIBRARIES "-ldl")
  270. macro(add_one_lib name)
  271. FIND_LIBRARY(CLANG_LIB
  272. NAMES ${name}
  273. PATHS ${LLVM_LIBRARY_DIR} NO_DEFAULT_PATH)
  274. - set(CLANG_LIBRARIES ${CLANG_LIBRARIES} ${CLANG_LIB})
  275. + set(CLANG_LIBRARIES "${CLANG_LIBRARIES} ${CLANG_LIB}")
  276. + message(STATUS "clanglibs name ${name} this ${CLANG_LIB} all ${CLANG_LIBRARIES} ")
  277. unset(CLANG_LIB CACHE)
  278. endmacro()
  279. #Assume clang lib path same as llvm lib path
  280. -add_one_lib("clangCodeGen")
  281. -add_one_lib("clangFrontend")
  282. -add_one_lib("clangSerialization")
  283. -add_one_lib("clangDriver")
  284. -add_one_lib("clangSema")
  285. -add_one_lib("clangStaticAnalyzerFrontend")
  286. -add_one_lib("clangStaticAnalyzerCheckers")
  287. -add_one_lib("clangStaticAnalyzerCore")
  288. -add_one_lib("clangAnalysis")
  289. -add_one_lib("clangEdit")
  290. -if (LLVM_VERSION_NODOT VERSION_GREATER 80)
  291. -add_one_lib("clangASTMatchers")
  292. -endif (LLVM_VERSION_NODOT VERSION_GREATER 80)
  293. -add_one_lib("clangAST")
  294. -add_one_lib("clangParse")
  295. -add_one_lib("clangSema")
  296. -add_one_lib("clangLex")
  297. -add_one_lib("clangBasic")
  298. +add_one_lib("clang-cpp")
  299. Only in beignet/CMake: FindLLVM.cmake.orig
  300. diff -upr beignet.orig/CMakeLists.txt beignet/CMakeLists.txt
  301. --- beignet.orig/CMakeLists.txt 2020-04-16 03:44:21.137288022 +0300
  302. +++ beignet/CMakeLists.txt 2020-04-16 03:45:04.131685618 +0300
  303. @@ -80,7 +80,7 @@ elseif (COMPILER STREQUAL "CLANG")
  304. elseif (COMPILER STREQUAL "ICC")
  305. set (CMAKE_C_CXX_FLAGS "${CMAKE_C_CXX_FLAGS} -wd2928 -Wall -fPIC -fstrict-aliasing -fp-model fast -msse4.1 -Wl,-E")
  306. endif ()
  307. -set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_C_CXX_FLAGS} -std=c++0x -Wno-invalid-offsetof")
  308. +set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_C_CXX_FLAGS} -Wno-invalid-offsetof")
  309. set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_C_CXX_FLAGS}")
  310. set (CMAKE_CXX_FLAGS_DEBUG "-O0 -g -DGBE_DEBUG=1")
  311. set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g -DGBE_DEBUG=1")
  312. diff -upr beignet.orig/utests/CMakeLists.txt beignet/utests/CMakeLists.txt
  313. --- beignet.orig/utests/CMakeLists.txt 2020-04-16 03:44:21.220623410 +0300
  314. +++ beignet/utests/CMakeLists.txt 2020-04-16 03:45:04.131685618 +0300
  315. @@ -26,8 +26,8 @@ if (NOT NOT_BUILD_STAND_ALONE_UTEST)
  316. # Threads
  317. Find_Package(Threads)
  318. - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_C_CXX_FLAGS} -std=c++0x -Wno-invalid-offsetof")
  319. - set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_C_CXX_FLAGS}")
  320. + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_C_CXX_FLAGS} -Wno-invalid-offsetof -ffloat-store -fno-strict-aliasing")
  321. + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_C_CXX_FLAGS} -ffloat-store -fno-strict-aliasing") #compiler_{degrees,radians,function_argument2} use equality comparison of floats, compiler_long_bitcast uses aliasing
  322. set (CMAKE_CXX_FLAGS_DEBUG "-O0 -g -DGBE_DEBUG=1")
  323. set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g -DGBE_DEBUG=1")
  324. set (CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG -DGBE_DEBUG=0")