diff options
author | Andres Freund <andres@anarazel.de> | 2020-02-06 19:09:06 -0800 |
---|---|---|
committer | Andres Freund <andres@anarazel.de> | 2020-02-06 19:54:43 -0800 |
commit | 8c2769405ff1f4617b0d3af50760b1ee357733ef (patch) | |
tree | 53e5e115d5609edd11d0a7bf692e81b0af7f2b99 /src/backend/jit/llvm/llvmjit_expr.c | |
parent | 1fdb7f9789c4550204cd62d1746a7deed1dc4c29 (diff) | |
download | postgresql-8c2769405ff1f4617b0d3af50760b1ee357733ef.tar.gz postgresql-8c2769405ff1f4617b0d3af50760b1ee357733ef.zip |
jit: Reference functions by name in IOCOERCE steps.
Previously we used constant function pointer addresses, which prevents
inlining and other related optimizations.
Author: Andres Freund
Discussion: https://postgr.es/m/20191023163849.sosqbfs5yenocez3@alap3.anarazel.de
Diffstat (limited to 'src/backend/jit/llvm/llvmjit_expr.c')
-rw-r--r-- | src/backend/jit/llvm/llvmjit_expr.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/backend/jit/llvm/llvmjit_expr.c b/src/backend/jit/llvm/llvmjit_expr.c index 521d9337e7c..cd9d8c1c760 100644 --- a/src/backend/jit/llvm/llvmjit_expr.c +++ b/src/backend/jit/llvm/llvmjit_expr.c @@ -1261,10 +1261,10 @@ llvm_compile_expr(ExprState *state) { FunctionCallInfo fcinfo_out, fcinfo_in; + LLVMValueRef v_fn_out, + v_fn_in; LLVMValueRef v_fcinfo_out, v_fcinfo_in; - LLVMValueRef v_fn_addr_out, - v_fn_addr_in; LLVMValueRef v_fcinfo_in_isnullp; LLVMValueRef v_retval; LLVMValueRef v_resvalue; @@ -1290,10 +1290,10 @@ llvm_compile_expr(ExprState *state) b_inputcall = l_bb_before_v(opblocks[opno + 1], "op.%d.inputcall", opno); + v_fn_out = llvm_function_reference(context, b, mod, fcinfo_out); + v_fn_in = llvm_function_reference(context, b, mod, fcinfo_in); v_fcinfo_out = l_ptr_const(fcinfo_out, l_ptr(StructFunctionCallInfoData)); v_fcinfo_in = l_ptr_const(fcinfo_in, l_ptr(StructFunctionCallInfoData)); - v_fn_addr_out = l_ptr_const(fcinfo_out->flinfo->fn_addr, TypePGFunction); - v_fn_addr_in = l_ptr_const(fcinfo_in->flinfo->fn_addr, TypePGFunction); v_fcinfo_in_isnullp = LLVMBuildStructGEP(b, v_fcinfo_in, @@ -1323,7 +1323,7 @@ llvm_compile_expr(ExprState *state) l_sbool_const(0), l_funcnullp(b, v_fcinfo_out, 0)); /* and call output function (can never return NULL) */ - v_output = LLVMBuildCall(b, v_fn_addr_out, &v_fcinfo_out, + v_output = LLVMBuildCall(b, v_fn_out, &v_fcinfo_out, 1, "funccall_coerce_out"); LLVMBuildBr(b, b_input); @@ -1378,7 +1378,7 @@ llvm_compile_expr(ExprState *state) /* reset fcinfo_in->isnull */ LLVMBuildStore(b, l_sbool_const(0), v_fcinfo_in_isnullp); /* and call function */ - v_retval = LLVMBuildCall(b, v_fn_addr_in, &v_fcinfo_in, 1, + v_retval = LLVMBuildCall(b, v_fn_in, &v_fcinfo_in, 1, "funccall_iocoerce_in"); LLVMBuildStore(b, v_retval, v_resvaluep); |