Skip to content

Commit

Permalink
Fixed addition of SOLVE block to kernel's FOR loop (#636)
Browse files Browse the repository at this point in the history
* Fix `append_statements_from_block` function in LLVM helper visitor.
* Before, if nonspecific current was not specified, the whole `BREAKPOINT`
   block would be added to the kernel body.
* This led to cases when `SOLVE` block was together with the actual
    solution to `DERIVATIVE`
  • Loading branch information
georgemitenkov authored and iomaganaris committed Sep 15, 2022
1 parent 8e9b4f1 commit 60c74e3
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/codegen/llvm/codegen_llvm_helper_visitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,12 @@ std::shared_ptr<ast::InstanceStruct> CodegenLLVMHelperVisitor::create_instance_s
static void append_statements_from_block(ast::StatementVector& statements,
const std::shared_ptr<ast::StatementBlock>& block) {
const auto& block_statements = block->get_statements();
statements.insert(statements.end(), block_statements.begin(), block_statements.end());
for (const auto& statement: block_statements) {
const auto& expression_statement = std::dynamic_pointer_cast<ast::ExpressionStatement>(
statement);
if (!expression_statement->get_expression()->is_solve_block())
statements.push_back(statement);
}
}

static std::shared_ptr<ast::CodegenAtomicStatement> create_atomic_statement(std::string& lhs_str,
Expand Down Expand Up @@ -638,7 +643,6 @@ void CodegenLLVMHelperVisitor::visit_nrn_state_block(ast::NrnStateBlock& node) {
/// add breakpoint block if no current
if (info.currents.empty() && info.breakpoint_node != nullptr) {
auto block = info.breakpoint_node->get_statement_block();
// \todo this automatically adds `SOLVE states METHOD ...`
append_statements_from_block(loop_body_statements, block);
}

Expand Down

0 comments on commit 60c74e3

Please sign in to comment.