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
Mark externally used records #9408
Conversation
perost
commented
Sep 21, 2022
- Implement marking of externally used records as needed by Handle mapping of record members to external C code types and layout. #9399.
- Implement marking of externally used records as needed by OpenModelica#9399.
@mahge: Hopefully this is what you need for #9399. Unfortunately it's a nightmare to deal with this in MetaModelica due to some things being mutable and other being immutable, so it might be not all needed record types are actually updated correctly. Let me know if you find some record types somewhere that doesn't have the flag set when they should and I'll try to catch those too. |
Ohh I was hoping the NF would help since it is not really doable if the OF or even SimCode. At least not easily or cheap. If we get some false negatives then that is okay assuming it can be fixed when found. The false positive are unfortunate because they generate additional code for nothing and we might not know. I don't think we need to worry that much though. I will check some bigger models and let you know. |
* Use the externally used records marker. * Set marker to always be true for the OF. * Use a map/dictionary instead of keeping separate lists. - Use a map (string, record Declaration) to keep a track of records in the SimCode. This allows for a simpler and quicker check. In addition we can update entries easily. * Add MetaModelica records to the map as well. * Debug help * Fix traversal order to avoid possible(?) infinite recursion. * Disable the old creation of record declarations. - See what fails in the testsuite. - It was actually affecting some tests because nested records were cycling back and messing with the order. Not exactly sure how but is not relevant anymore. * Simplify processing of record declrations. - Remove returned lists from functions: elaborateNestedRecordDeclarations elaborateRecordDeclarationsFromTypes elaborateRecordDeclarationsForRecord elaborateNestedRecordDeclarations - Remove input lists from functions: - elaborateRecordDeclarationsFromTypes * Make sure we do not overwrite true values to false. - If an entry already exists in the map and we always update, then there is a chance we might overwrite a 'true' value with a 'false' value for external conversion marker. Check if the entry exists and if it is marked false while then new incoming entry is marked true, then update it. Otherwise do nothing. * Remove input lists from functions - Remove input lists from functions: - elaborateNestedRecordDeclarations - elaborateRecordDeclarationsForRecord * Remove input and output lists from more functions. - Removed from - elaborateRecordDeclarationsForMetarecords * Remove input and output lists from elaborateRecordDeclarations. * Remove input and output lists from more functions. - Remove input and output lists from functions: - elaborateFunctions2 - elaborateFunction * Convert recursive functions to loops. - Recursive functions converted to loops: - elaborateNestedRecordDeclarations - elaborateRecordDeclarationsForMetarecords - elaborateRecordDeclarationsFromTypes * Rename some functions to be more descriptive. - elaborateRecordDeclarationsForMetarecords -> collectRecDeclsFromMetaRecordCallExps - elaborateNestedRecordDeclarations -> collectRecDeclsFromTypesVars - elaborateRecordDeclarationsFromTypes -> collectRecDeclsFromTypes - elaborateRecordDeclarationsForRecord -> collectRecDeclsFromType * Change how records are collected from metarecordcalls - Instead of: - traversing all expressions, collecting all meta record calls to a list, and then traversing this list to collect record declarations - collect record declarations while traversing all expressions (without collecting metarecordcalls into a whole new list.) * Rename functions to be more descriptive. - elaborateRecordDeclarations -> collectRecDeclsFromElems * Convert recursive functions to loops. - Convert recursive functions to loops: - collectRecDeclsFromElems (used to be `elaborateRecordDeclarations`) * Some minor cleanup and renaming. - declMap -> recDeclsMap - needsExternalConversion -> usedExternally