On Mon, Aug 30, 2021 at 5:41 AM Andres Freund <and...@anarazel.de> wrote: > - if (F.getAttributes().hasFnAttribute(llvm::Attribute::NoInline)) > + if (F.getAttributes().hasAttribute(llvm::Attribute::FunctionIndex, > llvm::Attribute::NoInline))
Yeah, that's already stopped working since you wrote it a few weeks ago... There's also been a second breakage site in our code due to LLVM commit 85b732b5. New fix attached. Tested on LLVM 7, 9, 13, 14 (= LLVM main branch commit 945df8bc4cf3 built 2021-09-15). Even though the macro approach is ugly, we're already handling every other API change that way, and at least it's at least very clear which lines to delete in a few years when older LLVMs fall off the conveyor belt of time. Admittedly renaming an identifiers is a new kludge, but I didn't want to duplicate the whole if block or confuse pgindent.
From 8678db35ef27b7f197bebcd5da1f91f55f583f8c Mon Sep 17 00:00:00 2001 From: Thomas Munro <tmu...@postgresql.org> Date: Fri, 24 Sep 2021 12:45:22 +1200 Subject: [PATCH] Track LLVM 14 API changes. Discussion: https://postgr.es/m/CA%2BhUKGL%3Dyg6qqgg6W6SAuvRQejditeoDNy-X3b9H_6Fnw8j5Wg%40mail.gmail.com --- src/backend/jit/llvm/llvmjit_inline.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/backend/jit/llvm/llvmjit_inline.cpp b/src/backend/jit/llvm/llvmjit_inline.cpp index 6f03595db5..9bb4b672a7 100644 --- a/src/backend/jit/llvm/llvmjit_inline.cpp +++ b/src/backend/jit/llvm/llvmjit_inline.cpp @@ -594,7 +594,11 @@ function_inlinable(llvm::Function &F, if (F.materialize()) elog(FATAL, "failed to materialize metadata"); - if (F.getAttributes().hasFnAttribute(llvm::Attribute::NoInline)) +#if LLVM_VERSION_MAJOR < 14 +#define hasFnAttr hasFnAttribute +#endif + + if (F.getAttributes().hasFnAttr(llvm::Attribute::NoInline)) { ilog(DEBUG1, "ineligibile to import %s due to noinline", F.getName().data()); @@ -871,7 +875,9 @@ create_redirection_function(std::unique_ptr<llvm::Module> &importMod, llvm::Function *AF; llvm::BasicBlock *BB; llvm::CallInst *fwdcall; +#if LLVM_VERSION_MAJOR < 14 llvm::Attribute inlineAttribute; +#endif AF = llvm::Function::Create(F->getFunctionType(), LinkageTypes::AvailableExternallyLinkage, @@ -880,9 +886,13 @@ create_redirection_function(std::unique_ptr<llvm::Module> &importMod, Builder.SetInsertPoint(BB); fwdcall = Builder.CreateCall(F, &*AF->arg_begin()); +#if LLVM_VERSION_MAJOR < 14 inlineAttribute = llvm::Attribute::get(Context, llvm::Attribute::AlwaysInline); fwdcall->addAttribute(~0U, inlineAttribute); +#else + fwdcall->addFnAttr(llvm::Attribute::AlwaysInline); +#endif Builder.CreateRet(fwdcall); return AF; -- 2.30.2