Fix LLVMExecutableFunction called with const arguments

This commit is contained in:
Maksim Kita 2021-05-10 01:02:54 +03:00
parent 99dadfe3c4
commit 8bc511eaa0
4 changed files with 16 additions and 15 deletions

View File

@ -45,8 +45,6 @@ static Poco::Logger * getLogger()
class LLVMExecutableFunction : public IExecutableFunctionImpl
{
std::string name;
JITCompiledFunction function = nullptr;
public:
explicit LLVMExecutableFunction(const std::string & name_, JITCompiledFunction function_)
@ -73,13 +71,13 @@ public:
result_column = result_column->cloneResized(input_rows_count);
std::vector<ColumnData> columns(arguments.size() + 1);
std::vector<ColumnPtr> columns_backup;
for (size_t i = 0; i < arguments.size(); ++i)
{
const auto * column = arguments[i].column.get();
if (!column)
throw Exception(ErrorCodes::LOGICAL_ERROR, "Column {} is missing", arguments[i].name);
columns[i] = getColumnData(column);
auto column = arguments[i].column->convertToFullColumnIfConst();
columns_backup.emplace_back(column);
columns[i] = getColumnData(column.get());
}
columns[arguments.size()] = getColumnData(result_column.get());
@ -111,6 +109,9 @@ public:
return result_column;
}
private:
std::string name;
JITCompiledFunction function = nullptr;
};
class LLVMFunction : public IFunctionBaseImpl

View File

@ -30,7 +30,7 @@ namespace DB
* Node a, Constant 1, Function add(a + 1), Input b, Constant 1, Function add(b, 1), Function add(add(a + 1), add(a + 1)).
*
* Compile function must be called with input_nodes_values equal to input nodes count.
* During compile funciton call CompileDAG is compiled in order of added nodes.
* When compile method is called added nodes are compiled in order.
*/
class CompileDAG
{

View File

@ -15,10 +15,10 @@ namespace
{
struct ColumnDataPlaceholder
{
llvm::Value * data_init; /// first row
llvm::Value * null_init;
llvm::PHINode * data; /// current row
llvm::PHINode * null;
llvm::Value * data_init = nullptr; /// first row
llvm::Value * null_init = nullptr;
llvm::PHINode * data = nullptr; /// current row
llvm::PHINode * null = nullptr;
};
}
@ -78,11 +78,11 @@ static void compileFunction(llvm::Module & module, const IFunctionBaseImpl & fun
llvm::Value * counter_arg = &*args++;
llvm::Value * columns_arg = &*args++;
/// Initialize ColumnDataPlaceholder llvm represenation of ColumnData
/// Last columns ColumnDataPlaceholder is result column
/// Initialize ColumnDataPlaceholder llvm representation of ColumnData
auto * entry = llvm::BasicBlock::Create(b.getContext(), "entry", func);
b.SetInsertPoint(entry);
std::vector<ColumnDataPlaceholder> columns(arg_types.size() + 1);
for (size_t i = 0; i <= arg_types.size(); ++i)
{

View File

@ -23,7 +23,7 @@ struct ColumnData
};
/** Returns ColumnData for column.
* If constant column is passed, LOGICAL_ERROR will be throwed.
* If constant column is passed, LOGICAL_ERROR will be thrown.
*/
ColumnData getColumnData(const IColumn * column);