]> granicus.if.org Git - postgresql/commitdiff
Don't generate tuple deforming functions for virtual slots.
authorAndres Freund <andres@anarazel.de>
Fri, 16 Nov 2018 06:00:30 +0000 (22:00 -0800)
committerAndres Freund <andres@anarazel.de>
Fri, 16 Nov 2018 06:00:30 +0000 (22:00 -0800)
Virtual tuple table slots never need tuple deforming. Therefore, if we
know at expression compilation time, that a certain slot will always
be virtual, there's no need to create a tuple deforming routine for
it.

Author: Andres Freund
Discussion: https://postgr.es/m/20181105210039.hh4vvi4vwoq5ba2q@alap3.anarazel.de

src/backend/jit/llvm/llvmjit_deform.c
src/backend/jit/llvm/llvmjit_expr.c
src/include/jit/llvmjit.h

index 59e38d2d9557ce6ddfada883f98121f261f79ee7..938dfc733616aed66c0121375104114d2d26532e 100644 (file)
@@ -31,7 +31,8 @@
  * Create a function that deforms a tuple of type desc up to natts columns.
  */
 LLVMValueRef
-slot_compile_deform(LLVMJitContext *context, TupleDesc desc, int natts)
+slot_compile_deform(LLVMJitContext *context, TupleDesc desc,
+                                       const TupleTableSlotOps *ops, int natts)
 {
        char       *funcname;
 
@@ -88,6 +89,10 @@ slot_compile_deform(LLVMJitContext *context, TupleDesc desc, int natts)
 
        int                     attnum;
 
+       /* virtual tuples never need deforming, so don't generate code */
+       if (ops == &TTSOpsVirtual)
+               return NULL;
+
        mod = llvm_mutable_module(context);
 
        funcname = llvm_expand_funcname(context, "deform");
index be9b2aecffe0103ce74def93e80e3dc0caa6a210..4cee35f582cc33f604bed82aaa506ec86264f214 100644 (file)
@@ -324,6 +324,7 @@ llvm_compile_expr(ExprState *state)
                                        {
                                                l_jit_deform =
                                                        slot_compile_deform(context, desc,
+                                                                                               tts_ops,
                                                                                                op->d.fetch.last_var);
                                        }
 
index f3ea2492835a2aaafb4014e007c0b3046023b3a5..3eae5e68319ba9ea513a7a3c9aac487cef579ef1 100644 (file)
@@ -111,7 +111,9 @@ extern void llvm_inline(LLVMModuleRef mod);
  ****************************************************************************
  */
 extern bool llvm_compile_expr(struct ExprState *state);
-extern LLVMValueRef slot_compile_deform(struct LLVMJitContext *context, TupleDesc desc, int natts);
+struct TupleTableSlotOps;
+extern LLVMValueRef slot_compile_deform(struct LLVMJitContext *context, TupleDesc desc,
+                                                                               const struct TupleTableSlotOps *ops, int natts);
 
 /*
  ****************************************************************************