-
-
Notifications
You must be signed in to change notification settings - Fork 87
Open
Description
Here are some changes required to get coriander compiling with clang 9. I've tested this on my macbook pro M1 and just using the clang 9 release download. I'll now check 10 and 11.
+++ b/src/mutations.cpp
@@ -44,12 +44,14 @@ void appendGlobalConstructorCall(Module *M, std::string functionName) {
for(int i = 0; i < oldNumConstructors; i++) {
initializers[i] = initializer->getAggregateElement((unsigned int)i);
}
- Constant *structValues[] = {
- ConstantInt::get(IntegerType::get(M->getContext(), 32), 1000000),
- M->getOrInsertFunction(
+ auto callee = M->getOrInsertFunction(
functionName,
Type::getVoidTy(M->getContext()),
- NULL),
+ static_cast<size_t>(NULL));
+ auto kernelGo = dyn_cast<Constant>(callee.getCallee());
+ Constant *structValues[] = {
+ ConstantInt::get(IntegerType::get(M->getContext(), 32), 1000000),
+ kernelGo,
ConstantPointerNull::get(PointerType::get(IntegerType::get(M->getContext(), 8), 0))
};
initializers[oldNumConstructors] = ConstantStruct::getAnon(ArrayRef<Constant *>(&structValues[0], &structValues[3]));
diff --git a/src/patch_hostside.cpp b/src/patch_hostside.cpp
index 51d251c..a0ceefc 100644
--- a/src/patch_hostside.cpp
+++ b/src/patch_hostside.cpp
@@ -64,8 +64,12 @@ std::unique_ptr<GenericCallInst> GenericCallInst::create(llvm::CallInst *inst) {
template<typename... ArgsTy>
Constant *getOrInsertFunction(Module* m, StringRef Name, Type *RetTy, ArgsTy... Args) {
-#if LLVM_VERSION_MAJOR > 4
+#if LLVM_VERSION_MAJOR > 4 && LLVM_VERSION_MAJOR < 9
return m->getOrInsertFunction(Name, RetTy, Args...);
+#elif LLVM_VERSION_MAJOR > 8
@@ -64,8 +64,12 @@ std::unique_ptr<GenericCallInst> GenericCallInst::create(llvm::CallInst *inst) {
template<typename... ArgsTy>
Constant *getOrInsertFunction(Module* m, StringRef Name, Type *RetTy, ArgsTy... Args) {
-#if LLVM_VERSION_MAJOR > 4
+#if LLVM_VERSION_MAJOR > 4 && LLVM_VERSION_MAJOR < 9
return m->getOrInsertFunction(Name, RetTy, Args...);
+#elif LLVM_VERSION_MAJOR > 8
+ auto callee = m->getOrInsertFunction(Name, RetTy, Args...);
+ auto kernelGo = dyn_cast<Constant>(callee.getCallee());
+ return kernelGo;
#else
return m->getOrInsertFunction(Name, RetTy, Args..., NULL);
#endif
@@ -559,10 +563,11 @@ void PatchHostside::patchCudaLaunch(
i++;
}
// trigger the kernel...
- Function *kernelGo = cast<Function>(F->getParent()->getOrInsertFunction(
+ auto callee = F->getParent()->getOrInsertFunction(
"kernelGo",
Type::getVoidTy(context),
- NULL));
+ static_cast<size_t>(NULL));
+ auto kernelGo = dyn_cast<Constant>(callee.getCallee());
CallInst *kernelGoInst = CallInst::Create(kernelGo);
kernelGoInst->insertAfter(lastInst);
lastInst = kernelGoInst;
hughperkins
Metadata
Metadata
Assignees
Labels
No labels