Fix compile functions data type offset

This commit is contained in:
Maksim Kita 2021-06-04 15:42:46 +03:00 committed by Maksim Kita
parent a5ef0067b8
commit b491e75a56
2 changed files with 26 additions and 10 deletions

View File

@ -80,6 +80,28 @@ private:
llvm::TargetMachine & target_machine;
};
// class AssemblyPrinter
// {
// public:
// explicit AssemblyPrinter(llvm::TargetMachine &target_machine_)
// : target_machine(target_machine_)
// {
// }
// void print(llvm::Module & module)
// {
// llvm::legacy::PassManager pass_manager;
// target_machine.Options.MCOptions.AsmVerbose = true;
// if (target_machine.addPassesToEmitFile(pass_manager, llvm::errs(), nullptr, llvm::CodeGenFileType::CGFT_AssemblyFile))
// throw Exception(ErrorCodes::CANNOT_COMPILE_CODE, "MachineCode cannot be printed");
// pass_manager.run(module);
// }
// private:
// llvm::TargetMachine & target_machine;
// };
/** MemoryManager for module.
* Keep total allocated size during RuntimeDyld linker execution.
* Actual compiled code memory is stored in llvm::SectionMemoryManager member, we cannot use ZeroBase optimization here
@ -216,9 +238,6 @@ CHJIT::CompiledModule CHJIT::compileModule(std::unique_ptr<llvm::Module> module)
auto buffer = compiler->compile(*module);
// llvm::errs() << "Module after optimizations " << "\n";
// module->print(llvm::errs(), nullptr);
llvm::Expected<std::unique_ptr<llvm::object::ObjectFile>> object = llvm::object::ObjectFile::createObjectFile(*buffer);
if (!object)

View File

@ -329,21 +329,18 @@ static void compileAddIntoAggregateStatesFunctions(llvm::Module & module, const
std::vector<ColumnDataPlaceholder> columns;
size_t previous_columns_size = 0;
for (size_t i = 0; i < functions.size(); ++i)
for (const auto & function : functions)
{
auto argument_types = functions[i].function->getArgumentTypes();
auto argument_types = function.function->getArgumentTypes();
ColumnDataPlaceholder data_placeholder;
std::cerr << "Function " << functions[i].function->getName() << std::endl;
size_t function_arguments_size = argument_types.size();
for (size_t column_argument_index = 0; column_argument_index < function_arguments_size; ++column_argument_index)
{
const auto & argument_type = argument_types[previous_columns_size + column_argument_index];
auto * data = b.CreateLoad(column_data_type, b.CreateConstInBoundsGEP1_32(column_data_type, columns_arg, column_argument_index));
std::cerr << "Argument type " << argument_type->getName() << std::endl;
const auto & argument_type = argument_types[column_argument_index];
auto * data = b.CreateLoad(column_data_type, b.CreateConstInBoundsGEP1_32(column_data_type, columns_arg, previous_columns_size + column_argument_index));
data_placeholder.data_init = b.CreatePointerCast(b.CreateExtractValue(data, {0}), toNativeType(b, removeNullable(argument_type))->getPointerTo());
columns.emplace_back(data_placeholder);
}