summaryrefslogtreecommitdiff
path: root/src/makefiles
diff options
context:
space:
mode:
authorAndres Freund <andres@anarazel.de>2018-03-28 13:19:08 -0700
committerAndres Freund <andres@anarazel.de>2018-03-28 13:19:08 -0700
commit9370462e9a79755aea367c62eb0fef96f0c42258 (patch)
treed8ca54a939c284d6106f2603b586ba01881b2e0b /src/makefiles
parent8a934d6778331f2ac04a40f4f22178a56a232315 (diff)
downloadpostgresql-9370462e9a79755aea367c62eb0fef96f0c42258.tar.gz
Add inlining support to LLVM JIT provider.
This provides infrastructure to allow JITed code to inline code implemented in C. This e.g. can be postgres internal functions or extension code. This already speeds up long running queries, by allowing the LLVM optimizer to optimize across function boundaries. The optimization potential currently doesn't reach its full potential because LLVM cannot optimize the FunctionCallInfoData argument fully away, because it's allocated on the heap rather than the stack. Fixing that is beyond what's realistic for v11. To be able to do that, use CLANG to convert C code to LLVM bitcode, and have LLVM build a summary for it. That bitcode can then be used to to inline functions at runtime. For that the bitcode needs to be installed. Postgres bitcode goes into $pkglibdir/bitcode/postgres, extensions go into equivalent directories. PGXS has been modified so that happens automatically if postgres has been compiled with LLVM support. Currently this isn't the fastest inline implementation, modules are reloaded from disk during inlining. That's to work around an apparent LLVM bug, triggering an apparently spurious error in LLVM assertion enabled builds. Once that is resolved we can remove the superfluous read from disk. Docs will follow in a later commit containing docs for the whole JIT feature. Author: Andres Freund Discussion: https://postgr.es/m/20170901064131.tazjxwus3k2w3ybh@alap3.anarazel.de
Diffstat (limited to 'src/makefiles')
-rw-r--r--src/makefiles/pgxs.mk26
1 files changed, 22 insertions, 4 deletions
diff --git a/src/makefiles/pgxs.mk b/src/makefiles/pgxs.mk
index c27004ecfb..5beb1e6b3c 100644
--- a/src/makefiles/pgxs.mk
+++ b/src/makefiles/pgxs.mk
@@ -101,6 +101,10 @@ endif
all: $(PROGRAM) $(DATA_built) $(SCRIPTS_built) $(addsuffix $(DLSUFFIX), $(MODULES)) $(addsuffix .control, $(EXTENSION))
+ifeq ($(with_llvm), yes)
+all: $(addsuffix .bc, $(MODULES)) $(patsubst %.o,%.bc, $(OBJS))
+endif
+
ifdef MODULE_big
# shared library parameters
NAME = $(MODULE_big)
@@ -123,6 +127,9 @@ ifneq (,$(DATA_TSEARCH))
endif # DATA_TSEARCH
ifdef MODULES
$(INSTALL_SHLIB) $(addsuffix $(DLSUFFIX), $(MODULES)) '$(DESTDIR)$(pkglibdir)/'
+ifeq ($(with_llvm), yes)
+ $(foreach mod, $(MODULES), $(call install_llvm_module,$(mod),$(mod).bc))
+endif # with_llvm
endif # MODULES
ifdef DOCS
ifdef docdir
@@ -138,8 +145,11 @@ endif # SCRIPTS
ifdef SCRIPTS_built
$(INSTALL_SCRIPT) $(SCRIPTS_built) '$(DESTDIR)$(bindir)/'
endif # SCRIPTS_built
-
ifdef MODULE_big
+ifeq ($(with_llvm), yes)
+ $(call install_llvm_module,$(MODULE_big),$(OBJS))
+endif # with_llvm
+
install: install-lib
endif # MODULE_big
@@ -183,7 +193,10 @@ ifneq (,$(DATA_TSEARCH))
endif
ifdef MODULES
rm -f $(addprefix '$(DESTDIR)$(pkglibdir)'/, $(addsuffix $(DLSUFFIX), $(MODULES)))
-endif
+ifeq ($(with_llvm), yes)
+ $(foreach mod, $(MODULES), $(call uninstall_llvm_module,$(mod)))
+endif # with_llvm
+endif # MODULES
ifdef DOCS
rm -f $(addprefix '$(DESTDIR)$(docdir)/$(docmoduledir)'/, $(DOCS))
endif
@@ -198,13 +211,18 @@ ifdef SCRIPTS_built
endif
ifdef MODULE_big
+ifeq ($(with_llvm), yes)
+ $(call uninstall_llvm_module,$(MODULE_big))
+endif # with_llvm
+
uninstall: uninstall-lib
endif # MODULE_big
clean:
ifdef MODULES
- rm -f $(addsuffix $(DLSUFFIX), $(MODULES)) $(addsuffix .o, $(MODULES)) $(if $(PGFILEDESC),$(WIN32RES))
+ rm -f $(addsuffix $(DLSUFFIX), $(MODULES)) $(addsuffix .o, $(MODULES)) $(if $(PGFILEDESC),$(WIN32RES)) \
+ $(addsuffix .bc, $(MODULES))
endif
ifdef DATA_built
rm -f $(DATA_built)
@@ -216,7 +234,7 @@ ifdef PROGRAM
rm -f $(PROGRAM)$(X)
endif
ifdef OBJS
- rm -f $(OBJS)
+ rm -f $(OBJS) $(patsubst %.o,%.bc, $(OBJS))
endif
ifdef EXTRA_CLEAN
rm -rf $(EXTRA_CLEAN)