From 657f9618023923f08adac11eee0a9566b808f805 Mon Sep 17 00:00:00 2001 From: Martin Nowack Date: Mon, 30 Oct 2023 14:46:22 +0000 Subject: Add support for opaque pointers --- lib/Module/FunctionAlias.cpp | 8 +++++++- lib/Module/IntrinsicCleaner.cpp | 11 ++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) (limited to 'lib/Module') diff --git a/lib/Module/FunctionAlias.cpp b/lib/Module/FunctionAlias.cpp index aa80b35d..c00bde58 100644 --- a/lib/Module/FunctionAlias.cpp +++ b/lib/Module/FunctionAlias.cpp @@ -134,10 +134,16 @@ bool FunctionAliasPass::runOnModule(Module &M) { } const FunctionType *FunctionAliasPass::getFunctionType(const GlobalValue *gv) { +#if LLVM_VERSION_CODE >= LLVM_VERSION(15, 0) + if (auto *ft = dyn_cast(gv->getType())) + return ft; + return dyn_cast(gv->getValueType()); +#else const Type *type = gv->getType(); while (type->isPointerTy()) type = type->getPointerElementType(); - return cast(type); + return dyn_cast(type); +#endif } bool FunctionAliasPass::checkType(const GlobalValue *match, diff --git a/lib/Module/IntrinsicCleaner.cpp b/lib/Module/IntrinsicCleaner.cpp index ad7c0631..40ff2874 100644 --- a/lib/Module/IntrinsicCleaner.cpp +++ b/lib/Module/IntrinsicCleaner.cpp @@ -100,9 +100,14 @@ bool IntrinsicCleanerPass::runOnBasicBlock(BasicBlock &b, Module &M) { Builder.CreatePointerCast(dst, i8pp, "vacopy.cast.dst"); auto castedSrc = Builder.CreatePointerCast(src, i8pp, "vacopy.cast.src"); +#if LLVM_VERSION_CODE >= LLVM_VERSION(15, 0) + auto load = Builder.CreateLoad(Builder.getInt8PtrTy(), castedSrc, + "vacopy.read"); +#else auto load = Builder.CreateLoad(castedSrc->getType()->getPointerElementType(), castedSrc, "vacopy.read"); +#endif Builder.CreateStore(load, castedDst, false /* isVolatile */); } else { assert(WordSize == 8 && "Invalid word size!"); @@ -110,9 +115,13 @@ bool IntrinsicCleanerPass::runOnBasicBlock(BasicBlock &b, Module &M) { auto pDst = Builder.CreatePointerCast(dst, i64p, "vacopy.cast.dst"); auto pSrc = Builder.CreatePointerCast(src, i64p, "vacopy.cast.src"); +#if LLVM_VERSION_CODE >= LLVM_VERSION(15, 0) + auto pSrcType = Builder.getPtrTy(); + auto pDstType = Builder.getPtrTy(); +#else auto pSrcType = pSrc->getType()->getPointerElementType(); auto pDstType = pDst->getType()->getPointerElementType(); - +#endif auto val = Builder.CreateLoad(pSrcType, pSrc); Builder.CreateStore(val, pDst, ii); -- cgit 1.4.1