about summary refs log tree commit diff homepage
path: root/lib/Core/ExternalDispatcher.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Core/ExternalDispatcher.cpp')
-rw-r--r--lib/Core/ExternalDispatcher.cpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/lib/Core/ExternalDispatcher.cpp b/lib/Core/ExternalDispatcher.cpp
index 718b1c31..7b43218b 100644
--- a/lib/Core/ExternalDispatcher.cpp
+++ b/lib/Core/ExternalDispatcher.cpp
@@ -250,7 +250,7 @@ bool ExternalDispatcherImpl::runProtectedCall(Function *f, uint64_t *args) {
 }
 
 // FIXME: This might have been relevant for the old JIT but the MCJIT
-// has a completly different implementation so this comment below is
+// has a completely different implementation so this comment below is
 // likely irrelevant and misleading.
 //
 // For performance purposes we construct the stub in such a way that the
@@ -283,13 +283,20 @@ Function *ExternalDispatcherImpl::createDispatcher(KCallable *target,
 
   llvm::IRBuilder<> Builder(dBB);
   // Get a Value* for &gTheArgsP, as an i64**.
+#if LLVM_VERSION_CODE >= LLVM_VERSION(15, 0)
+  auto argI64sp = Builder.CreateIntToPtr(
+      ConstantInt::get(Type::getInt64Ty(ctx), (uintptr_t)&gTheArgsP),
+      PointerType::getUnqual(PointerType::getUnqual(Type::getInt64Ty(ctx))),
+      "argsp");
+  auto argI64s = Builder.CreateLoad(Builder.getPtrTy(), argI64sp, "args");
+#else
   auto argI64sp = Builder.CreateIntToPtr(
       ConstantInt::get(Type::getInt64Ty(ctx), (uintptr_t)(void *)&gTheArgsP),
       PointerType::getUnqual(PointerType::getUnqual(Type::getInt64Ty(ctx))),
       "argsp");
   auto argI64s = Builder.CreateLoad(
       argI64sp->getType()->getPointerElementType(), argI64sp, "args");
-
+#endif
   // Get the target function type.
   FunctionType *FTy = target->getFunctionType();
 
@@ -306,6 +313,14 @@ Function *ExternalDispatcherImpl::createDispatcher(KCallable *target,
     if (argTy->isX86_FP80Ty() && idx & 0x01)
       idx++;
 
+#if LLVM_VERSION_CODE >= LLVM_VERSION(15, 0)
+    auto argI64p =
+        Builder.CreateGEP(Builder.getPtrTy(), argI64s,
+                          ConstantInt::get(Type::getInt32Ty(ctx), idx));
+
+    auto argp = Builder.CreateBitCast(argI64p, PointerType::getUnqual(argTy));
+    args[i] = Builder.CreateLoad(argTy, argp);
+#else
     auto argI64p =
         Builder.CreateGEP(argI64s->getType()->getPointerElementType(), argI64s,
                           ConstantInt::get(Type::getInt32Ty(ctx), idx));
@@ -313,6 +328,7 @@ Function *ExternalDispatcherImpl::createDispatcher(KCallable *target,
     auto argp = Builder.CreateBitCast(argI64p, PointerType::getUnqual(argTy));
     args[i] =
         Builder.CreateLoad(argp->getType()->getPointerElementType(), argp);
+#endif
 
     unsigned argSize = argTy->getPrimitiveSizeInBits();
     idx += ((!!argSize ? argSize : 64) + 63) / 64;