agora inbox for pgsql-hackers@postgresql.org
help / color / mirror / Atom feedFrom: Pierre <pierre.ducroquet@people-doc.com>
Subject: [PATCH 3/8] Add LLVM4 support in llvmjit_inline.cpp
Date: Fri, 2 Feb 2018 09:23:56 +0100
---
src/backend/jit/llvm/llvmjit_inline.cpp | 36 +++++++++++++++++++++++++++++++--
1 file changed, 34 insertions(+), 2 deletions(-)
diff --git a/src/backend/jit/llvm/llvmjit_inline.cpp b/src/backend/jit/llvm/llvmjit_inline.cpp
index 7d0d18b43d..4fa0e5ab64 100644
--- a/src/backend/jit/llvm/llvmjit_inline.cpp
+++ b/src/backend/jit/llvm/llvmjit_inline.cpp
@@ -100,6 +100,13 @@ llvm_inline(LLVMModuleRef M)
llvm_execute_inline_plan(mod, globalsToInline.get());
}
+#if LLVM_VERSION_MAJOR < 5
+bool operator!(const llvm::ValueInfo &vi) {
+ return !( (vi.Kind == llvm::ValueInfo::VI_GUID && vi.TheValue.Id)
+ || (vi.Kind == llvm::ValueInfo::VI_Value && vi.TheValue.GV));
+}
+#endif
+
/*
* Build information necessary for inlining external function references in
* mod.
@@ -146,7 +153,14 @@ llvm_build_inline_plan(llvm::Module *mod)
if (threshold == -1)
continue;
+#if LLVM_VERSION_MAJOR > 4
llvm::ValueInfo funcVI = llvm_index->getValueInfo(funcGUID);
+#else
+ const llvm::const_gvsummary_iterator &I = llvm_index->findGlobalValueSummaryList(funcGUID);
+ if (I == llvm_index->end())
+ continue;
+ llvm::ValueInfo funcVI = llvm::ValueInfo(I->first);
+#endif
/* if index doesn't know function, we don't have a body, continue */
if (!funcVI)
@@ -157,7 +171,12 @@ llvm_build_inline_plan(llvm::Module *mod)
* look up module(s), check if function actually is defined (there
* could be hash conflicts).
*/
+#if LLVM_VERSION_MAJOR > 4
for (const auto &gvs : funcVI.getSummaryList())
+#else
+ auto it_gvs = llvm_index->findGlobalValueSummaryList(funcVI.getGUID());
+ for (const auto &gvs: it_gvs->second)
+#endif
{
const llvm::FunctionSummary *fs;
llvm::StringRef modPath = gvs->modulePath();
@@ -318,9 +337,14 @@ llvm_execute_inline_plan(llvm::Module *mod, ImportMapTy *globalsToInline)
}
+#if LLVM_VERSION_MAJOR > 4
+#define IRMOVE_PARAMS , /*IsPerformingImport=*/false
+#else
+#define IRMOVE_PARAMS , /*LinkModuleInlineAsm=*/false, /*IsPerformingImport=*/false
+#endif
if (Mover.move(std::move(importMod), GlobalsToImport.getArrayRef(),
- [](llvm::GlobalValue &, llvm::IRMover::ValueAdder) {},
- /*IsPerformingImport=*/false))
+ [](llvm::GlobalValue &, llvm::IRMover::ValueAdder) {}
+ IRMOVE_PARAMS))
elog(ERROR, "function import failed with linker error");
}
}
@@ -619,9 +643,17 @@ llvm_load_index(void)
elog(ERROR, "failed to open %s: %s", subpath,
EC.message().c_str());
llvm::MemoryBufferRef ref(*MBOrErr.get().get());
+#if LLVM_VERSION_MAJOR > 4
llvm::Error e = llvm::readModuleSummaryIndex(ref, *index, 0);
if (e)
elog(ERROR, "could not load summary at %s", subpath);
+#else
+ std::unique_ptr<llvm::ModuleSummaryIndex> subindex = std::move(llvm::getModuleSummaryIndex(ref).get());
+ if (!subindex)
+ elog(ERROR, "could not load summary at %s", subpath);
+ else
+ index->mergeFrom(std::move(subindex), 0);
+#endif
}
}
--
2.16.1
--nextPart2004836.nyjv7E8iqn
Content-Disposition: attachment;
filename="0004-Don-t-emit-bitcode-depending-on-an-LLVM-5-function.patch"
Content-Transfer-Encoding: 7Bit
Content-Type: text/x-patch; charset="UTF-8";
name="0004-Don-t-emit-bitcode-depending-on-an-LLVM-5-function.patch"
view thread (4+ messages) latest in thread
Message-ID: <no-message-id-765477@localhost>
Permalink: ../../no-message-id-765477@localhost/
Also on: postgresql.org/message-id/no-message-id-765477@localhost
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: pierre.ducroquet@people-doc.com
Subject: Re: [PATCH 3/8] Add LLVM4 support in llvmjit_inline.cpp
In-Reply-To: <no-message-id-765477@localhost>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox