1 Description: Fix build with LLVM/Clang 9
3 Origin: (mostly) FreeBSD https://svnweb.freebsd.org/ports/head/lang/beignet/files/patch-llvm9?view=markup
4 Author: Jan Beich, Rebecca N. Palmer
6 --- a/CMake/FindLLVM.cmake
7 +++ b/CMake/FindLLVM.cmake
8 @@ -126,6 +126,9 @@ macro(add_one_lib name)
9 add_one_lib("clangStaticAnalyzerCore")
10 add_one_lib("clangAnalysis")
11 add_one_lib("clangEdit")
12 +if (LLVM_VERSION_NODOT VERSION_GREATER 80)
13 +add_one_lib("clangASTMatchers")
14 +endif (LLVM_VERSION_NODOT VERSION_GREATER 80)
15 add_one_lib("clangAST")
16 add_one_lib("clangParse")
17 add_one_lib("clangSema")
18 --- a/backend/src/llvm/llvm_intrinsic_lowering.cpp
19 +++ b/backend/src/llvm/llvm_intrinsic_lowering.cpp
20 @@ -77,7 +77,11 @@ namespace gbe {
21 std::vector<Type *> ParamTys;
22 for (Value** I = ArgBegin; I != ArgEnd; ++I)
23 ParamTys.push_back((*I)->getType());
24 +#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 90
25 + FunctionCallee FCache = M->getOrInsertFunction(NewFn,
27 Constant* FCache = M->getOrInsertFunction(NewFn,
29 FunctionType::get(RetTy, ParamTys, false));
31 IRBuilder<> Builder(CI->getParent(), BasicBlock::iterator(CI));
32 --- a/backend/src/llvm/llvm_sampler_fix.cpp
33 +++ b/backend/src/llvm/llvm_sampler_fix.cpp
34 @@ -82,7 +82,11 @@ namespace gbe {
35 #if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 40
36 Module *M = I->getParent()->getParent()->getParent();
37 #if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 50
38 +#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 90
39 + FunctionCallee samplerCvt = M->getOrInsertFunction("__gen_ocl_sampler_to_int", i32Ty, I->getOperand(0)->getType());
41 Value* samplerCvt = M->getOrInsertFunction("__gen_ocl_sampler_to_int", i32Ty, I->getOperand(0)->getType());
44 Value* samplerCvt = M->getOrInsertFunction("__gen_ocl_sampler_to_int", i32Ty, I->getOperand(0)->getType(), nullptr);
46 @@ -124,7 +128,11 @@ namespace gbe {
47 #if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 40
48 Module *M = I->getParent()->getParent()->getParent();
49 #if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 50
50 +#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 90
51 + FunctionCallee samplerCvt = M->getOrInsertFunction("__gen_ocl_sampler_to_int", i32Ty, I->getOperand(0)->getType());
53 Value* samplerCvt = M->getOrInsertFunction("__gen_ocl_sampler_to_int", i32Ty, I->getOperand(0)->getType());
56 Value* samplerCvt = M->getOrInsertFunction("__gen_ocl_sampler_to_int", i32Ty, I->getOperand(0)->getType(), nullptr);
58 --- a/backend/src/llvm/llvm_profiling.cpp
59 +++ b/backend/src/llvm/llvm_profiling.cpp
60 @@ -163,10 +163,18 @@ namespace gbe
61 // __gen_ocl_store_timestamp(int nth, int type);
62 Value *Args[2] = {ConstantInt::get(intTy, pointNum++), ConstantInt::get(intTy, profilingType)};
63 #if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 50
64 +#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 90
65 + builder->CreateCall(module->getOrInsertFunction(
67 builder->CreateCall(cast<llvm::Function>(module->getOrInsertFunction(
69 "__gen_ocl_calc_timestamp", Type::getVoidTy(module->getContext()),
70 IntegerType::getInt32Ty(module->getContext()),
71 +#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 90
72 + IntegerType::getInt32Ty(module->getContext())),
74 IntegerType::getInt32Ty(module->getContext()))),
76 ArrayRef<Value*>(Args));
78 builder->CreateCall(cast<llvm::Function>(module->getOrInsertFunction(
79 @@ -185,10 +193,18 @@ namespace gbe
80 Value *Args2[2] = {profilingBuf, ConstantInt::get(intTy, profilingType)};
82 #if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 50
83 +#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 90
84 + builder->CreateCall(module->getOrInsertFunction(
86 builder->CreateCall(cast<llvm::Function>(module->getOrInsertFunction(
88 "__gen_ocl_store_profiling", Type::getVoidTy(module->getContext()),
90 +#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 90
91 + IntegerType::getInt32Ty(module->getContext())),
93 IntegerType::getInt32Ty(module->getContext()))),
95 ArrayRef<Value*>(Args2));
97 builder->CreateCall(cast<llvm::Function>(module->getOrInsertFunction(
98 --- a/backend/src/llvm/llvm_device_enqueue.cpp
99 +++ b/backend/src/llvm/llvm_device_enqueue.cpp
100 @@ -398,8 +398,13 @@ namespace gbe {
101 std::vector<Type *> ParamTys;
102 for (Value** iter = args.begin(); iter != args.end(); ++iter)
103 ParamTys.push_back((*iter)->getType());
104 +#if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 90
105 + CallInst* newCI = builder.CreateCall(mod->getOrInsertFunction(
106 + "__gen_enqueue_kernel_slm", FunctionType::get(intTy, ParamTys, false)), args);
108 CallInst* newCI = builder.CreateCall(cast<llvm::Function>(mod->getOrInsertFunction(
109 "__gen_enqueue_kernel_slm", FunctionType::get(intTy, ParamTys, false))), args);
111 CI->replaceAllUsesWith(newCI);
112 deadInsnSet.insert(CI);