gemini-code-assist[bot] commented on code in PR #20018:
URL: https://github.com/apache/tvm/pull/20018#discussion_r3596038250


##########
src/tirx/ir/stmt_functor.cc:
##########
@@ -59,6 +59,8 @@ void StmtVisitor::VisitStmt_(const WhileNode* op) {
   this->VisitStmt(op->body);
 }
 
+void StmtVisitor::VisitStmt_(const ReturnNode* op) { 
this->VisitExpr(op->value); }

Review Comment:
   ![high](https://www.gstatic.com/codereviewagent/high-priority.svg)
   
   In TVM/TIRx, `StmtVisitor` is designed to only traverse statement nodes and 
does not define or inherit a `VisitExpr` method (unlike `StmtExprVisitor`). 
Calling `this->VisitExpr(op->value)` here will result in a compilation error.
   
   To fix this, `StmtVisitor::VisitStmt_(const ReturnNode* op)` should be 
empty, similar to `VisitStmt_(const EvaluateNode* op)`. 
   
   Additionally, to ensure that expressions inside `Return` statements are 
correctly visited and mutated during IR passes, you must explicitly override 
`VisitStmt_(const ReturnNode* op)` in `StmtExprVisitor` and `StmtExprMutator` 
(defined in `include/tvm/tirx/stmt_functor.h` and implemented in 
`src/tirx/ir/stmt_functor.cc`) to call `this->VisitExpr(op->value)` and mutate 
`op->value` respectively. Without these overrides, passes like 
`LinearAccessPatternFinder` (in `storage_rewrite.cc`) will fail to detect 
buffer/variable accesses within `Return` statements, leading to critical 
correctness bugs.
   
   ```suggestion
   void StmtVisitor::VisitStmt_(const ReturnNode* op) {}
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to