codegen: keep a symbolically-sized register array on the stack - #2504
Draft
ThrudPrimrose wants to merge 6 commits into
Draft
codegen: keep a symbolically-sized register array on the stack#2504ThrudPrimrose wants to merge 6 commits into
ThrudPrimrose wants to merge 6 commits into
Conversation
A StorageType.Register array whose size is symbolic was allocated on the heap with a warning. GCC, Clang and NVHPC all accept variable-length arrays, so it is now declared in place; allocation and deallocation share one predicate so they cannot disagree, and a VLA takes a memset rather than a brace initializer.
A VLA dies with its block, but Global, Persistent and External arrays are declared outside it -- codegen emits a program-level pointer for those, which the local declaration shadowed while leaving the pointer null.
… emitter MarkVLAArrays sets Data.vla on the symbolically-sized register arrays whose lifetime ends with the block they are declared in and whose size is already defined there; code generation reads the flag and nothing else. A size that only an interstate edge assigns splits the declaration from the allocation, and a VLA declared under that split shadows the SDFG-scope pointer, which stays null - the segfaulting case the earlier in-emitter predicate missed.
…declaration A size that only an interstate edge assigns makes framecode declare the pointer at SDFG scope and allocate in a later block; a VLA there shadows that pointer, which stays null - four tests segfaulted on it. declared_arrays already records that, so allocation and deallocation both ask the same predicate rather than a descriptor flag no pass can set correctly.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A
StorageType.Registerarray whose size is symbolic was allocated on the heap with a warning, though GCC, Clang and NVHPC all accept variable-length arrays. It is now declared in place, with allocation and deallocation sharing one predicate so they cannot disagree.I think this is important because this means CloudSC and Velocity Tendencies code gets 2x faster!