aboutsummaryrefslogtreecommitdiff
path: root/src/backend/jit/llvm/llvmjit_expr.c
diff options
context:
space:
mode:
authorAndres Freund <andres@anarazel.de>2018-11-07 11:08:45 -0800
committerAndres Freund <andres@anarazel.de>2018-11-07 11:08:45 -0800
commitb84a6dafbf2bb921baee53c0c1aba7719ee38817 (patch)
tree0b93d0dd7dd559c6acad4cc0f53731eebb8e68ee /src/backend/jit/llvm/llvmjit_expr.c
parent517b0d0b5f38c92c1807a40d71ca4bf6428ca7d5 (diff)
downloadpostgresql-b84a6dafbf2bb921baee53c0c1aba7719ee38817.tar.gz
postgresql-b84a6dafbf2bb921baee53c0c1aba7719ee38817.zip
Move EEOP_*_SYSVAR evaluation out of line.
This mainly de-duplicates code. As evaluating a system variable isn't the hottest path and the current inline implementation ends up calling out to an external function anyway, this is OK from a performance POV. The main motivation for de-duplicating is the upcoming slot abstraction work, after which there's not guaranteed to be a HeapTuple backing the slot. Author: Andres Freund, Amit Khandekar 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.c38
1 files changed, 8 insertions, 30 deletions
diff --git a/src/backend/jit/llvm/llvmjit_expr.c b/src/backend/jit/llvm/llvmjit_expr.c
index 42258774783..13e981e5641 100644
--- a/src/backend/jit/llvm/llvmjit_expr.c
+++ b/src/backend/jit/llvm/llvmjit_expr.c
@@ -406,13 +406,8 @@ llvm_compile_expr(ExprState *state)
case EEOP_OUTER_SYSVAR:
case EEOP_SCAN_SYSVAR:
{
- int attnum = op->d.var.attnum;
- LLVMValueRef v_attnum;
- LLVMValueRef v_tuple;
- LLVMValueRef v_tupleDescriptor;
- LLVMValueRef v_params[4];
- LLVMValueRef v_syscol;
LLVMValueRef v_slot;
+ LLVMValueRef v_params[4];
if (opcode == EEOP_INNER_SYSVAR)
v_slot = v_innerslot;
@@ -421,31 +416,14 @@ llvm_compile_expr(ExprState *state)
else
v_slot = v_scanslot;
- Assert(op->d.var.attnum < 0);
-
- v_tuple = l_load_struct_gep(b, v_slot,
- FIELDNO_TUPLETABLESLOT_TUPLE,
- "v.tuple");
+ v_params[0] = v_state;
+ v_params[1] = l_ptr_const(op, l_ptr(StructExprEvalStep));
+ v_params[2] = v_econtext;
+ v_params[3] = v_slot;
- /*
- * Could optimize this a bit for fixed descriptors, but
- * this shouldn't be that critical a path.
- */
- v_tupleDescriptor =
- l_load_struct_gep(b, v_slot,
- FIELDNO_TUPLETABLESLOT_TUPLEDESCRIPTOR,
- "v.tupledesc");
- v_attnum = l_int32_const(attnum);
-
- v_params[0] = v_tuple;
- v_params[1] = v_attnum;
- v_params[2] = v_tupleDescriptor;
- v_params[3] = v_resnullp;
- v_syscol = LLVMBuildCall(b,
- llvm_get_decl(mod, FuncHeapGetsysattr),
- v_params, lengthof(v_params),
- "");
- LLVMBuildStore(b, v_syscol, v_resvaluep);
+ LLVMBuildCall(b,
+ FuncExecEvalSysVar,
+ v_params, lengthof(v_params), "");
LLVMBuildBr(b, opblocks[i + 1]);
break;