aboutsummaryrefslogtreecommitdiff
path: root/src/backend/jit/llvm/llvmjit_expr.c
diff options
context:
space:
mode:
authorAndres Freund <andres@anarazel.de>2018-11-15 22:00:30 -0800
committerAndres Freund <andres@anarazel.de>2018-11-15 22:00:30 -0800
commit675af5c01e297262cd20d7416f7e568393c22c6e (patch)
tree3af0a63c0fb58bfe930f1e7fdff3c4cea1ea448d /src/backend/jit/llvm/llvmjit_expr.c
parent1a0586de3657cd35581f0639c87d5050c6197bb7 (diff)
downloadpostgresql-675af5c01e297262cd20d7416f7e568393c22c6e.tar.gz
postgresql-675af5c01e297262cd20d7416f7e568393c22c6e.zip
Compute information about EEOP_*_FETCHSOME at expression init time.
Previously this information was computed when JIT compiling an expression. But the information is useful for assertions in the non-JIT case too (for assertions), therefore it makes sense to move it. This will, in a followup commit, allow to treat different slot types differently. E.g. for virtual slots there's no need to generate a JIT function to deform the slot. Author: Andres Freund Discussion: https://postgr.es/m/20181105210039.hh4vvi4vwoq5ba2q@alap3.anarazel.de
Diffstat (limited to 'src/backend/jit/llvm/llvmjit_expr.c')
-rw-r--r--src/backend/jit/llvm/llvmjit_expr.c44
1 files changed, 15 insertions, 29 deletions
diff --git a/src/backend/jit/llvm/llvmjit_expr.c b/src/backend/jit/llvm/llvmjit_expr.c
index 0dbc1e41062..be9b2aecffe 100644
--- a/src/backend/jit/llvm/llvmjit_expr.c
+++ b/src/backend/jit/llvm/llvmjit_expr.c
@@ -276,6 +276,8 @@ llvm_compile_expr(ExprState *state)
LLVMValueRef v_slot;
LLVMBasicBlockRef b_fetch;
LLVMValueRef v_nvalid;
+ LLVMValueRef l_jit_deform = NULL;
+ const TupleTableSlotOps *tts_ops = NULL;
b_fetch = l_bb_before_v(opblocks[i + 1],
"op.%d.fetch", i);
@@ -283,40 +285,22 @@ llvm_compile_expr(ExprState *state)
if (op->d.fetch.known_desc)
desc = op->d.fetch.known_desc;
- if (opcode == EEOP_INNER_FETCHSOME)
- {
- PlanState *is = innerPlanState(parent);
+ if (op->d.fetch.fixed)
+ tts_ops = op->d.fetch.kind;
+ if (opcode == EEOP_INNER_FETCHSOME)
v_slot = v_innerslot;
-
- if (!desc &&
- is &&
- is->ps_ResultTupleSlot &&
- TTS_FIXED(is->ps_ResultTupleSlot))
- desc = is->ps_ResultTupleSlot->tts_tupleDescriptor;
- }
else if (opcode == EEOP_OUTER_FETCHSOME)
- {
- PlanState *os = outerPlanState(parent);
-
v_slot = v_outerslot;
-
- if (!desc &&
- os &&
- os->ps_ResultTupleSlot &&
- TTS_FIXED(os->ps_ResultTupleSlot))
- desc = os->ps_ResultTupleSlot->tts_tupleDescriptor;
- }
else
- {
v_slot = v_scanslot;
- if (!desc && parent)
- desc = parent->scandesc;
- }
/*
* Check if all required attributes are available, or
* whether deforming is required.
+ *
+ * TODO: skip nvalid check if slot is fixed and known to
+ * be a virtual slot.
*/
v_nvalid =
l_load_struct_gep(b, v_slot,
@@ -336,19 +320,21 @@ llvm_compile_expr(ExprState *state)
* function specific to tupledesc and the exact number of
* to-be-extracted attributes.
*/
- if (desc && (context->base.flags & PGJIT_DEFORM))
+ if (tts_ops && desc && (context->base.flags & PGJIT_DEFORM))
{
- LLVMValueRef params[1];
- LLVMValueRef l_jit_deform;
-
l_jit_deform =
slot_compile_deform(context, desc,
op->d.fetch.last_var);
+ }
+
+ if (l_jit_deform)
+ {
+ LLVMValueRef params[1];
+
params[0] = v_slot;
LLVMBuildCall(b, l_jit_deform,
params, lengthof(params), "");
-
}
else
{