Skip to content

Implemented ASR checks for function dependencies #2167

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
049fbc6
fix: check dependencies are from same symbol table
arteevraina Jul 16, 2023
fc86d98
fix: remove print statement
arteevraina Jul 16, 2023
42d5146
fix: update verify logic
arteevraina Jul 17, 2023
4805b69
fix: update logic for verification of dependencies
arteevraina Jul 18, 2023
71bee66
refactor: remove cout
arteevraina Jul 18, 2023
70f2f9c
fix: get the parent symtab of x
arteevraina Jul 18, 2023
a2e802b
fix: skip the symbols which are nullptr or of type External Symbol
arteevraina Jul 18, 2023
8d8bbc7
fix: update cmakelists
arteevraina Jul 19, 2023
c1116e3
fix: check while adding dependencies to make sure they are from same …
arteevraina Jul 26, 2023
b531009
fix: asr verify passes for callback_01 test
arteevraina Aug 11, 2023
2c436ba
fix: tests relating to external symbols and function dependencies
arteevraina Aug 12, 2023
6fc8a6d
fix: condition for checking intrinsic function
arteevraina Aug 15, 2023
f1d77ae
Allow global scope dependencies as well
certik Aug 18, 2023
f94840f
Merge main
czgdp1807 Aug 25, 2023
47d0f5d
Robust check for making sure that dependency isn't defined inside the…
czgdp1807 Aug 25, 2023
456071b
fix: add robust checking using resolve symbol when symbol is nested
arteevraina Aug 26, 2023
ca26122
fix: improved check by checking only in parent scopes and not in curr…
arteevraina Aug 26, 2023
dd2d3ab
fix: improved checks for dependencies in asr verify
arteevraina Aug 27, 2023
681514f
Check if external symbol is not nested inside the current_scope
czgdp1807 Aug 28, 2023
433d944
fix: applied correct checks in ast to asr
arteevraina Aug 28, 2023
14632b4
refactor: added function to check for current scope in asr utils
arteevraina Aug 28, 2023
0491339
refactor: remove unused function
arteevraina Aug 28, 2023
d943c5a
updated references
arteevraina Aug 28, 2023
f97063f
Merge branch 'main' into checks-for-same-symtab-dependencies
arteevraina Aug 28, 2023
b1d00d4
remove nofast
arteevraina Aug 28, 2023
c1c8bd2
Merge branch 'main' into checks-for-same-symtab-dependencies
arteevraina Aug 29, 2023
f1e1c2f
refactor: function call & subroutine call dependencies
arteevraina Sep 2, 2023
261c187
feat: sync libasr
arteevraina Oct 4, 2023
6f7c8fa
fix: update branch
arteevraina Oct 4, 2023
ccaa3ec
dev: udpate branch
arteevraina Oct 4, 2023
f68f71a
fix: updated all references
arteevraina Oct 4, 2023
0c7e8b5
dev: sync libasr with lfortran
arteevraina Oct 18, 2023
74e4251
test: update references
arteevraina Oct 18, 2023
1801bb5
tests: update references
arteevraina Oct 18, 2023
895f411
fix: set asr_owner when visiting For
arteevraina Oct 24, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion integration_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ RUN(NAME global_syms_01 LABELS cpython llvm c)
RUN(NAME global_syms_02 LABELS cpython llvm c)
RUN(NAME global_syms_03_b LABELS cpython llvm c)
RUN(NAME global_syms_03_c LABELS cpython llvm c)
RUN(NAME global_syms_04 LABELS cpython llvm c wasm wasm_x64)
RUN(NAME global_syms_04 LABELS cpython llvm c wasm wasm_x64 NOFAST)
RUN(NAME global_syms_05 LABELS cpython llvm c)
RUN(NAME global_syms_06 LABELS cpython llvm c)

Expand Down
19 changes: 19 additions & 0 deletions src/libasr/asr_verify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,25 @@ class VerifyVisitor : public BaseWalkVisitor<VerifyVisitor>
verify_unique_dependencies(x.m_dependencies, x.n_dependencies,
x.m_name, x.base.base.loc);

// Get the x symtab.
SymbolTable *sym = x.m_symtab->parent;

// Dependencies of the function should be from function's symbol table.
for( size_t i = 0; i < x.n_dependencies; i++ ) {
std::string found_dep = x.m_dependencies[i];

// Get the symbol of the found_dep.
ASR::symbol_t* dep_sym = sym->get_symbol(found_dep);

// If dep_sym is External Symbol or nullptr. It should be skipped.
if (dep_sym == nullptr || ASR::is_a<ASR::ExternalSymbol_t>(*dep_sym)) {
continue;
}

require(dep_sym != nullptr,
"Dependency " + found_dep + " does not belong to same parent symbol table of " + std::string(x.m_name));
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am trying to understand the logic here.

Are we ensuring that all dependencies are from the same parent symbol table?

It seems this logic is testing that all the symbols (except ExternalSymbol) are NOT from the parent symbol table. Tests pass, so I guess this is the correct logic, but I don't understand it. Once I understand it, let's document this as a comment.


// Check if there are unnecessary dependencies
// present in the dependency list of the function
for( size_t i = 0; i < x.n_dependencies; i++ ) {
Expand Down