Skip to content

Commit 53ad721

Browse files
Skip duplicating of BlockCall and Goto nodes in inline_function_calls
1 parent 7d78dba commit 53ad721

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/libasr/pass/inline_function_calls.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,10 @@ class InlineFunctionCallVisitor : public PassUtils::PassVisitor<InlineFunctionCa
338338
// Duplicate each and every statement of the function body.
339339
for( size_t i = 0; i < func->n_body && success; i++ ) {
340340
node_duplicator.success = true;
341+
if (ASR::is_a<ASR::BlockCall_t>(*func->m_body[i])
342+
|| ASR::is_a<ASR::GoTo_t>(*func->m_body[i])){
343+
continue;
344+
}
341345
ASR::stmt_t* m_body_copy = node_duplicator.duplicate_stmt(func->m_body[i]);
342346
if( node_duplicator.success ) {
343347
func_copy.push_back(al, m_body_copy);
@@ -350,7 +354,7 @@ class InlineFunctionCallVisitor : public PassUtils::PassVisitor<InlineFunctionCa
350354
// Set inlining_function to true so that we inline
351355
// only one function at a time.
352356
inlining_function = true;
353-
for( size_t i = 0; i < func->n_body && success; i++ ) {
357+
for( size_t i = 0; i < func_copy.size() && success; i++ ) {
354358
fixed_duplicated_expr_stmt = true;
355359
visit_stmt(*func_copy[i]);
356360
success = success && fixed_duplicated_expr_stmt;
@@ -373,7 +377,7 @@ class InlineFunctionCallVisitor : public PassUtils::PassVisitor<InlineFunctionCa
373377
}
374378

375379
bool is_goto_added = false;
376-
for( size_t i = 0; i < func->n_body; i++ ) {
380+
for( size_t i = 0; i < func_copy.size(); i++ ) {
377381
return_replacer.current_stmt = &func_copy.p[i];
378382
return_replacer.has_replacement_happened = false;
379383
return_replacer.replace_stmt(func_copy[i]);

0 commit comments

Comments
 (0)