Skip to content

Commit

Permalink
Merge pull request #4760 from gxyd/test_undo_m_value_nullptr
Browse files Browse the repository at this point in the history
undo setting m_value as nullptr and remove ASR verify pass check
  • Loading branch information
certik authored Sep 12, 2024
2 parents 342236a + 723d928 commit 4a0a5d0
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 30 deletions.
8 changes: 4 additions & 4 deletions integration_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ RUN(NAME data_08 LABELS gfortran llvmImplicit)
RUN(NAME data_09 LABELS gfortran llvm llvm_wasm llvm_wasm_emcc c llvm17)
RUN(NAME data_10 LABELS gfortran llvm llvm_wasm llvm_wasm_emcc llvm17)
RUN(NAME data_11 LABELS gfortran llvmImplicit)
# RUN(NAME data_12 LABELS gfortran llvm llvm_wasm llvm_wasm_emcc fortran llvm17)
RUN(NAME data_12 LABELS gfortran llvm llvm_wasm llvm_wasm_emcc fortran llvm17)

RUN(NAME minmax_01 LABELS gfortran llvm llvm_wasm llvm_wasm_emcc wasm c fortran llvm17)
RUN(NAME arithmetic_if_01 LABELS gfortran llvm llvm_wasm llvm_wasm_emcc c llvm17) # arithmetic tests use goto
Expand Down Expand Up @@ -505,7 +505,7 @@ RUN(NAME arrays_52 LABELS gfortran llvm llvm_wasm llvm_wasm_emcc llvm17)
RUN(NAME global_allocatable_01 LABELS gfortran llvm llvm_wasm llvm_wasm_emcc)
RUN(NAME global_allocatable_02 LABELS gfortran llvm llvm_wasm llvm_wasm_emcc)
RUN(NAME global_array_pointer_01 LABELS gfortran llvm llvm_wasm llvm_wasm_emcc)
# RUN(NAME global_array_01 LABELS gfortran llvm llvm_wasm llvm_wasm_emcc llvm17)
RUN(NAME global_array_01 LABELS gfortran llvm llvm_wasm llvm_wasm_emcc llvm17)
RUN(NAME pointer_01 LABELS gfortran llvm llvm_wasm llvm_wasm_emcc)
RUN(NAME pointer_02 LABELS gfortran llvm llvm_wasm llvm_wasm_emcc)

Expand Down Expand Up @@ -991,7 +991,7 @@ RUN(NAME modules_53 LABELS gfortran llvm llvm_wasm llvm_wasm_emcc)
RUN(NAME modules_54 LABELS gfortran llvm llvm_wasm llvm_wasm_emcc llvm17)
RUN(NAME modules_55 LABELS gfortran llvm llvm_wasm llvm_wasm_emcc llvm17)
RUN(NAME modules_56 LABELS gfortran llvm llvm_wasm llvm_wasm_emcc NOFAST llvm17)
# RUN(NAME modules_57 LABELS gfortran llvm llvm_wasm llvm_wasm_emcc llvm17)
RUN(NAME modules_57 LABELS gfortran llvm llvm_wasm llvm_wasm_emcc llvm17)
# RUN(NAME modules_58 LABELS gfortran llvm llvm_wasm llvm_wasm_emcc EXTRAFILES modules_58_module.f90)
RUN(NAME operator_overloading_05_module3 LABELS gfortran llvm llvm_wasm llvm_wasm_emcc llvm17 EXTRAFILES
operator_overloading_05_module1.f90 operator_overloading_05_module2.f90)
Expand Down Expand Up @@ -1269,7 +1269,7 @@ RUN(NAME string_27 LABELS gfortran llvm llvm_wasm llvm_wasm_emcc llvm17)
RUN(NAME string_28 LABELS gfortran llvm llvm_wasm llvm_wasm_emcc llvm17)
RUN(NAME string_29 LABELS gfortran llvm llvm_wasm llvm_wasm_emcc)
COMPILE(NAME string_30 COMPILERS gfortran llvm llvm_wasm llvm_wasm_emcc fortran llvm17)
# RUN(NAME string_31 LABELS gfortran llvm llvm_wasm llvm_wasm_emcc llvm17)
RUN(NAME string_31 LABELS gfortran llvm llvm_wasm llvm_wasm_emcc llvm17)
RUN(NAME string_32 LABELS gfortran llvm llvm_wasm llvm_wasm_emcc)
RUN(NAME string_33 LABELS gfortran llvm llvm_wasm llvm_wasm_emcc llvm17)
RUN(NAME string_34 LABELS gfortran llvm llvm_wasm llvm_wasm_emcc llvm17)
Expand Down
21 changes: 3 additions & 18 deletions src/lfortran/semantics/ast_common_visitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -1598,11 +1598,7 @@ class CommonVisitor : public AST::BaseVisitor<Derived> {
ASR::Var_t *v = ASR::down_cast<ASR::Var_t>(object);
v2 = ASR::down_cast<ASR::Variable_t>(v->m_v);
}
if( v2->m_storage == ASR::storage_typeType::Parameter ) {
v2->m_value = ASRUtils::EXPR(tmp);
} else {
v2->m_value = nullptr;
}
v2->m_value = ASRUtils::EXPR(tmp);
v2->m_symbolic_value = ASRUtils::EXPR(tmp);
SetChar var_deps_vec;
var_deps_vec.reserve(al, 1);
Expand Down Expand Up @@ -1685,11 +1681,7 @@ class CommonVisitor : public AST::BaseVisitor<Derived> {
if (ASR::is_a<ASR::StructInstanceMember_t>(*object)) {
ASR::StructInstanceMember_t *mem = ASR::down_cast<ASR::StructInstanceMember_t>(object);
ASR::Variable_t* v2 = ASR::down_cast<ASR::Variable_t>(ASRUtils::symbol_get_past_external(mem->m_m));
if( v2->m_storage == ASR::storage_typeType::Parameter ) {
v2->m_value = expression_value;
} else {
v2->m_value = nullptr;
}
v2->m_value = expression_value;
v2->m_symbolic_value = expression_value;
SetChar var_deps_vec;
var_deps_vec.reserve(al, 1);
Expand All @@ -1707,11 +1699,7 @@ class CommonVisitor : public AST::BaseVisitor<Derived> {
// y / 2 /
ASR::Var_t *v = ASR::down_cast<ASR::Var_t>(object);
ASR::Variable_t *v2 = ASR::down_cast<ASR::Variable_t>(v->m_v);
if( v2->m_storage == ASR::storage_typeType::Parameter ) {
v2->m_value = expression_value;
} else {
v2->m_value = nullptr;
}
v2->m_value = expression_value;
v2->m_symbolic_value = expression_value;
SetChar var_deps_vec;
var_deps_vec.reserve(al, 1);
Expand Down Expand Up @@ -3281,9 +3269,6 @@ class CommonVisitor : public AST::BaseVisitor<Derived> {
}
if( std::find(excluded_from_symtab.begin(), excluded_from_symtab.end(), sym) == excluded_from_symtab.end() ) {
if ( !is_implicitly_declared && !is_external) {
if( storage_type != ASR::storage_typeType::Parameter ) {
value = nullptr;
}
SetChar variable_dependencies_vec;
variable_dependencies_vec.reserve(al, 1);
ASRUtils::collect_variable_dependencies(al, variable_dependencies_vec, type, init_expr, value);
Expand Down
3 changes: 0 additions & 3 deletions src/libasr/asr_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -4126,9 +4126,6 @@ static inline ASR::asr_t* make_Variable_t_util(
ASR::intentType a_intent, ASR::expr_t* a_symbolic_value, ASR::expr_t* a_value,
ASR::storage_typeType a_storage, ASR::ttype_t* a_type, ASR::symbol_t* a_type_declaration,
ASR::abiType a_abi, ASR::accessType a_access, ASR::presenceType a_presence, bool a_value_attr) {
if( a_storage != ASR::storage_typeType::Parameter ) {
a_value = nullptr;
}
return ASR::make_Variable_t(al, a_loc, a_parent_symtab, a_name, a_dependencies, n_dependencies,
a_intent, a_symbolic_value, a_value, a_storage, a_type, a_type_declaration, a_abi, a_access,
a_presence, a_value_attr);
Expand Down
4 changes: 2 additions & 2 deletions src/libasr/asr_verify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -673,8 +673,8 @@ class VerifyVisitor : public BaseWalkVisitor<VerifyVisitor>
// For now restrict this check only to variables which are present
// inside symbols which have a body.
if( x.m_storage != ASR::storage_typeType::Parameter ) {
require(x.m_value == nullptr,
"Only parameter variables can have non-NULL value attribute." )
// require(x.m_value == nullptr,
// "Only parameter variables can have non-NULL value attribute." )
require( (x.m_symbolic_value != nullptr &&
(ASRUtils::is_value_constant(x.m_symbolic_value) ||
ASRUtils::is_value_constant(ASRUtils::expr_value(x.m_symbolic_value))) ) ||
Expand Down
18 changes: 15 additions & 3 deletions src/libasr/pass/simplifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1729,13 +1729,25 @@ class TransformVariableInitialiser:
}
Vec<ASR::stmt_t*>& result_vec = symtab2decls[current_scope];
ASR::expr_t* target = ASRUtils::EXPR(ASR::make_Var_t(al, loc, &(xx.base)));
exprs_with_target[xx.m_symbolic_value] = std::make_pair(target, targetType::OriginalTarget);

// if `m_value` is present, then use that for converting it into
// assignment/association below, otherwise use `m_symbolic_value`
// for the same. As `m_value` is usually more "simplified" than
// `m_symbolic_value`
ASR::expr_t* value = nullptr;
if (xx.m_value) {
value = xx.m_value;
} else {
value = xx.m_symbolic_value;
}

exprs_with_target[value] = std::make_pair(target, targetType::OriginalTarget);
if (ASRUtils::is_pointer(x.m_type)) {
result_vec.push_back(al, ASRUtils::STMT(ASR::make_Associate_t(
al, loc, target, xx.m_symbolic_value)));
al, loc, target, value)));
} else {
result_vec.push_back(al, ASRUtils::STMT(make_Assignment_t_util(
al, loc, target, xx.m_symbolic_value, nullptr, exprs_with_target)));
al, loc, target, value, nullptr, exprs_with_target)));
}
xx.m_symbolic_value = nullptr;
xx.m_value = nullptr;
Expand Down

0 comments on commit 4a0a5d0

Please sign in to comment.