mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-29 11:02:08 +00:00
Fix LLVMExecutableFunction called with const arguments
This commit is contained in:
parent
99dadfe3c4
commit
8bc511eaa0
@ -45,8 +45,6 @@ static Poco::Logger * getLogger()
|
|||||||
|
|
||||||
class LLVMExecutableFunction : public IExecutableFunctionImpl
|
class LLVMExecutableFunction : public IExecutableFunctionImpl
|
||||||
{
|
{
|
||||||
std::string name;
|
|
||||||
JITCompiledFunction function = nullptr;
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
explicit LLVMExecutableFunction(const std::string & name_, JITCompiledFunction function_)
|
explicit LLVMExecutableFunction(const std::string & name_, JITCompiledFunction function_)
|
||||||
@ -73,13 +71,13 @@ public:
|
|||||||
result_column = result_column->cloneResized(input_rows_count);
|
result_column = result_column->cloneResized(input_rows_count);
|
||||||
|
|
||||||
std::vector<ColumnData> columns(arguments.size() + 1);
|
std::vector<ColumnData> columns(arguments.size() + 1);
|
||||||
|
std::vector<ColumnPtr> columns_backup;
|
||||||
|
|
||||||
for (size_t i = 0; i < arguments.size(); ++i)
|
for (size_t i = 0; i < arguments.size(); ++i)
|
||||||
{
|
{
|
||||||
const auto * column = arguments[i].column.get();
|
auto column = arguments[i].column->convertToFullColumnIfConst();
|
||||||
if (!column)
|
columns_backup.emplace_back(column);
|
||||||
throw Exception(ErrorCodes::LOGICAL_ERROR, "Column {} is missing", arguments[i].name);
|
columns[i] = getColumnData(column.get());
|
||||||
|
|
||||||
columns[i] = getColumnData(column);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
columns[arguments.size()] = getColumnData(result_column.get());
|
columns[arguments.size()] = getColumnData(result_column.get());
|
||||||
@ -111,6 +109,9 @@ public:
|
|||||||
return result_column;
|
return result_column;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::string name;
|
||||||
|
JITCompiledFunction function = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
class LLVMFunction : public IFunctionBaseImpl
|
class LLVMFunction : public IFunctionBaseImpl
|
||||||
|
@ -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)).
|
* 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.
|
* 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
|
class CompileDAG
|
||||||
{
|
{
|
||||||
|
@ -15,10 +15,10 @@ namespace
|
|||||||
{
|
{
|
||||||
struct ColumnDataPlaceholder
|
struct ColumnDataPlaceholder
|
||||||
{
|
{
|
||||||
llvm::Value * data_init; /// first row
|
llvm::Value * data_init = nullptr; /// first row
|
||||||
llvm::Value * null_init;
|
llvm::Value * null_init = nullptr;
|
||||||
llvm::PHINode * data; /// current row
|
llvm::PHINode * data = nullptr; /// current row
|
||||||
llvm::PHINode * null;
|
llvm::PHINode * null = nullptr;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,11 +78,11 @@ static void compileFunction(llvm::Module & module, const IFunctionBaseImpl & fun
|
|||||||
llvm::Value * counter_arg = &*args++;
|
llvm::Value * counter_arg = &*args++;
|
||||||
llvm::Value * columns_arg = &*args++;
|
llvm::Value * columns_arg = &*args++;
|
||||||
|
|
||||||
/// Initialize ColumnDataPlaceholder llvm represenation of ColumnData
|
/// Initialize ColumnDataPlaceholder llvm representation of ColumnData
|
||||||
/// Last columns ColumnDataPlaceholder is result column
|
|
||||||
|
|
||||||
auto * entry = llvm::BasicBlock::Create(b.getContext(), "entry", func);
|
auto * entry = llvm::BasicBlock::Create(b.getContext(), "entry", func);
|
||||||
b.SetInsertPoint(entry);
|
b.SetInsertPoint(entry);
|
||||||
|
|
||||||
std::vector<ColumnDataPlaceholder> columns(arg_types.size() + 1);
|
std::vector<ColumnDataPlaceholder> columns(arg_types.size() + 1);
|
||||||
for (size_t i = 0; i <= arg_types.size(); ++i)
|
for (size_t i = 0; i <= arg_types.size(); ++i)
|
||||||
{
|
{
|
||||||
|
@ -23,7 +23,7 @@ struct ColumnData
|
|||||||
};
|
};
|
||||||
|
|
||||||
/** Returns ColumnData for column.
|
/** 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);
|
ColumnData getColumnData(const IColumn * column);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user