@@ -1251,9 +1251,14 @@ llvm_compile_expr(ExprState *state)
12511251
12521252case EEOP_IOCOERCE :
12531253{
1254- FunctionCallInfo fcinfo_out ;
1255- LLVMValueRef v_fn_out ;
1256- LLVMValueRef v_fcinfo_out ;
1254+ FunctionCallInfo fcinfo_out ,
1255+ fcinfo_in ;
1256+ LLVMValueRef v_fn_out ,
1257+ v_fn_in ;
1258+ LLVMValueRef v_fcinfo_out ,
1259+ v_fcinfo_in ;
1260+ LLVMValueRef v_fcinfo_in_isnullp ;
1261+ LLVMValueRef v_retval ;
12571262LLVMValueRef v_resvalue ;
12581263LLVMValueRef v_resnull ;
12591264
@@ -1266,6 +1271,7 @@ llvm_compile_expr(ExprState *state)
12661271LLVMBasicBlockRef b_inputcall ;
12671272
12681273fcinfo_out = op -> d .iocoerce .fcinfo_data_out ;
1274+ fcinfo_in = op -> d .iocoerce .fcinfo_data_in ;
12691275
12701276b_skipoutput = l_bb_before_v (opblocks [opno + 1 ],
12711277"op.%d.skipoutputnull" ,opno );
@@ -1277,7 +1283,14 @@ llvm_compile_expr(ExprState *state)
12771283"op.%d.inputcall" ,opno );
12781284
12791285v_fn_out = llvm_function_reference (context ,b ,mod ,fcinfo_out );
1286+ v_fn_in = llvm_function_reference (context ,b ,mod ,fcinfo_in );
12801287v_fcinfo_out = l_ptr_const (fcinfo_out ,l_ptr (StructFunctionCallInfoData ));
1288+ v_fcinfo_in = l_ptr_const (fcinfo_in ,l_ptr (StructFunctionCallInfoData ));
1289+
1290+ v_fcinfo_in_isnullp =
1291+ LLVMBuildStructGEP (b ,v_fcinfo_in ,
1292+ FIELDNO_FUNCTIONCALLINFODATA_ISNULL ,
1293+ "v_fcinfo_in_isnull" );
12811294
12821295/* output functions are not called on nulls */
12831296v_resnull = LLVMBuildLoad (b ,v_resnullp ,"" );
@@ -1343,44 +1356,24 @@ llvm_compile_expr(ExprState *state)
13431356LLVMBuildBr (b ,b_inputcall );
13441357}
13451358
1346- /*
1347- * Call the input function.
1348- *
1349- * If op->d.iocoerce.escontext references an
1350- * ErrorSaveContext, InputFunctionCallSafe() would return
1351- * false upon encountering an error.
1352- */
13531359LLVMPositionBuilderAtEnd (b ,b_inputcall );
1354- {
1355- Oid ioparam = op -> d .iocoerce .typioparam ;
1356- LLVMValueRef v_params [6 ];
1357- LLVMValueRef v_success ;
1358-
1359- v_params [0 ]= l_ptr_const (op -> d .iocoerce .finfo_in ,
1360- l_ptr (StructFmgrInfo ));
1361- v_params [1 ]= v_output ;
1362- v_params [2 ]= l_oid_const (lc ,ioparam );
1363- v_params [3 ]= l_int32_const (lc ,-1 );
1364- v_params [4 ]= l_ptr_const (op -> d .iocoerce .escontext ,
1365- l_ptr (StructErrorSaveContext ));
1360+ /* set arguments */
1361+ /* arg0: output */
1362+ LLVMBuildStore (b ,v_output ,
1363+ l_funcvaluep (b ,v_fcinfo_in ,0 ));
1364+ LLVMBuildStore (b ,v_resnull ,
1365+ l_funcnullp (b ,v_fcinfo_in ,0 ));
1366+
1367+ /* arg1: ioparam: preset in execExpr.c */
1368+ /* arg2: typmod: preset in execExpr.c */
1369+
1370+ /* reset fcinfo_in->isnull */
1371+ LLVMBuildStore (b ,l_sbool_const (0 ),v_fcinfo_in_isnullp );
1372+ /* and call function */
1373+ v_retval = LLVMBuildCall (b ,v_fn_in ,& v_fcinfo_in ,1 ,
1374+ "funccall_iocoerce_in" );
13661375
1367- /*
1368- * InputFunctionCallSafe() will write directly into
1369- * *op->resvalue.
1370- */
1371- v_params [5 ]= v_resvaluep ;
1372-
1373- v_success = LLVMBuildCall (b ,llvm_pg_func (mod ,"InputFunctionCallSafe" ),
1374- v_params ,lengthof (v_params ),
1375- "funccall_iocoerce_in_safe" );
1376-
1377- /*
1378- * Return null if InputFunctionCallSafe() encountered
1379- * an error.
1380- */
1381- v_resnullp = LLVMBuildICmp (b ,LLVMIntEQ ,v_success ,
1382- l_sbool_const (0 ),"" );
1383- }
1376+ LLVMBuildStore (b ,v_retval ,v_resvaluep );
13841377
13851378LLVMBuildBr (b ,opblocks [opno + 1 ]);
13861379break ;