[Bugfix][TIR] Handle AttrStmt of upcoming tir.Var in ConvertSSA #16682
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.
In some cases, an
AttrStmtmay legally refer to a TIR variable that hasn't yet been defined. For example, the"pragma_parallel_launch_point"attribute, which annotates a variable that is about to occur in a ForNode. Prior to this commit,ConvertSSAtreated theAttrStmtas the usage of a variable, followed by a nested definition to be de-duplicated. This resulted in the outputAttrStmtcontaining a reference to an undefined variable.This commit updates
ConvertSSAto handle this case. If anAttrStmtrefers to a not-yet-defined variable, the body is visited before marking it as defined.This implementation may be simplified in the future by moving "pragma_parallel_launch_point" to be an annotation on the
ForNode, rather than anAttrStmt.