diff --git a/enzyme/Enzyme/Utils.cpp b/enzyme/Enzyme/Utils.cpp index 756c972996d9..8f94f7b8321f 100644 --- a/enzyme/Enzyme/Utils.cpp +++ b/enzyme/Enzyme/Utils.cpp @@ -309,6 +309,10 @@ Value *CreateAllocation(IRBuilder<> &Builder, llvm::Type *T, Value *Count, ZeroMem = nullptr; } } else { +#if LLVM_VERSION_MAJOR > 17 + res = Builder.CreateMalloc(Count->getType(), T->getType(), Align, Count, + nullptr, Name); +#else if (Builder.GetInsertPoint() == Builder.GetInsertBlock()->end()) { res = CallInst::CreateMalloc(Builder.GetInsertBlock(), Count->getType(), T, Align, Count, nullptr, Name); @@ -319,6 +323,7 @@ Value *CreateAllocation(IRBuilder<> &Builder, llvm::Type *T, Value *Count, } if (!cast(res)->getParent()) Builder.Insert(cast(res)); +#endif malloccall = dyn_cast(res); if (malloccall == nullptr) {