beignet-1.3.2-llvm7-support.patch 3.8 KB

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