Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

diffs to compile for clang 9 #96

Open
dokipen3d opened this issue Feb 17, 2021 · 0 comments
Open

diffs to compile for clang 9 #96

dokipen3d opened this issue Feb 17, 2021 · 0 comments

Comments

@dokipen3d
Copy link
Contributor

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;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant