diff options
author | Martin Nowack <m.nowack@imperial.ac.uk> | 2023-10-30 14:46:22 +0000 |
---|---|---|
committer | Cristian Cadar <c.cadar@imperial.ac.uk> | 2024-02-08 13:17:19 +0000 |
commit | 657f9618023923f08adac11eee0a9566b808f805 (patch) | |
tree | 394afc2f0d073a0ecb3b1e4388882f1a2b2be1cb /lib/Core/ExternalDispatcher.cpp | |
parent | 44a38ba6f54046cb4a9f8b08a0b8711ad5d5ebaa (diff) | |
download | klee-657f9618023923f08adac11eee0a9566b808f805.tar.gz |
Add support for opaque pointers
Diffstat (limited to 'lib/Core/ExternalDispatcher.cpp')
-rw-r--r-- | lib/Core/ExternalDispatcher.cpp | 20 |
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; |