-
Notifications
You must be signed in to change notification settings - Fork 164
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
ASR pass for unique symbols #2149
Conversation
@certik This PR now passes all the integration tests with LLVM and C backend with every possible name-mangling. It just fails for one test and that has something to do with nested structs and External Symbol. Can you please test this PR against your use cases? |
Both the test cases in #2129 as well as |
I would structure this ASR pass like this:
We can then keep extending the logic in the first pass as needed, and it could be that there is no single way forward, and users will select the behavior on the command line that they need for their application / build system. |
Register the pass in https://github.com/lcompilers/lpython/blob/main/src/libasr/gen_pass.py and run the script to generate the |
src/libasr/pass/unique_symbols.cpp
Outdated
std::map<std::string, ASR::symbol_t*> current_scope; | ||
|
||
UniqueSymbolVisitor(Allocator& al_, | ||
std::map<ASR::symbol_t*, std::string> sn) : al(al_), sym_to_new_name(sn){} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a hashtable might be faster here.
@@ -1616,7 +1635,7 @@ int main(int argc, char *argv[]) | |||
app.require_subcommand(0, 1); | |||
CLI11_PARSE(app, argc, argv); | |||
|
|||
lcompilers_unique_ID = LCompilers::get_unique_ID(); | |||
lcompilers_unique_ID = separate_compilation ? LCompilers::get_unique_ID(): ""; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would not do that here, but rather have lcompilers_unique_ID
always have a unique ID. But have this logic of turning it on and off in asr_scopes. If asr_scopes doesn't have access to separate_compilation
then let's create another variable lcompilers_unique_ID_separate_compilation
and have that variable on and off as needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that this is fine. Let's merge it and we can iterate on this as needed and fix any bugs as we encounter them.
#2129, #2142