Skip to content

Commit 390d34a

Browse files
committed
Added support for Out[S]
1 parent a8dbbc2 commit 390d34a

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/libasr/pass/pass_utils.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ namespace LCompilers {
116116

117117
static inline bool is_aggregate_or_array_type(ASR::expr_t* var) {
118118
return (ASR::is_a<ASR::Struct_t>(*ASRUtils::expr_type(var)) ||
119-
ASRUtils::is_array(ASRUtils::expr_type(var)));
119+
ASRUtils::is_array(ASRUtils::expr_type(var)) ||
120+
ASR::is_a<ASR::SymbolicExpression_t>(*ASRUtils::expr_type(var)));
120121
}
121122

122123
template <class Struct>
@@ -775,7 +776,7 @@ namespace LCompilers {
775776
}
776777

777778
static inline void handle_fn_return_var(Allocator &al, ASR::Function_t *x,
778-
bool (*is_array_or_struct)(ASR::expr_t*)) {
779+
bool (*is_array_or_struct_or_symbolic)(ASR::expr_t*)) {
779780
if (ASRUtils::get_FunctionType(x)->m_abi == ASR::abiType::BindPython) {
780781
return;
781782
}
@@ -787,7 +788,7 @@ namespace LCompilers {
787788
* in avoiding deep copies and the destination memory directly gets
788789
* filled inside the function.
789790
*/
790-
if( is_array_or_struct(x->m_return_var)) {
791+
if( is_array_or_struct_or_symbolic(x->m_return_var)) {
791792
for( auto& s_item: x->m_symtab->get_scope() ) {
792793
ASR::symbol_t* curr_sym = s_item.second;
793794
if( curr_sym->type == ASR::symbolType::Variable ) {
@@ -826,7 +827,7 @@ namespace LCompilers {
826827
for (auto &item : x->m_symtab->get_scope()) {
827828
if (ASR::is_a<ASR::Function_t>(*item.second)) {
828829
handle_fn_return_var(al, ASR::down_cast<ASR::Function_t>(
829-
item.second), is_array_or_struct);
830+
item.second), is_array_or_struct_or_symbolic);
830831
}
831832
}
832833
}

src/libasr/pass/replace_symbolic.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ class ReplaceSymbolicVisitor : public PassUtils::PassVisitor<ReplaceSymbolicVisi
123123

124124
ASR::ttype_t *type1 = ASRUtils::TYPE(ASR::make_CPtr_t(al, xx.base.base.loc));
125125
xx.m_type = type1;
126-
if (var_name != "_lpython_return_variable") {
126+
if (var_name != "_lpython_return_variable" && xx.m_intent != ASR::intentType::Out) {
127127
symbolic_vars_to_free.insert(ASR::down_cast<ASR::symbol_t>((ASR::asr_t*)&xx));
128128
}
129129
if(xx.m_intent == ASR::intentType::In){

0 commit comments

Comments
 (0)