This is an automated email from the ASF dual-hosted git repository.

tqchen pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm-tirx.git


The following commit(s) were added to refs/heads/main by this push:
     new cf7178ddf [FIX][TIRx] Bind TensorVar handle before iterating its shape 
(#78)
cf7178ddf is described below

commit cf7178ddfd9d764e6a7358dfc1f14b514b8f6119
Author: Tianqi Chen <[email protected]>
AuthorDate: Mon Oct 26 07:47:29 2026 -0400

    [FIX][TIRx] Bind TensorVar handle before iterating its shape (#78)
    
    `StmtExprMutatorWithConstraintContext::AddParamConstraints` iterated
    over `shape()` called on the temporary returned by
    `as_or_throw<TensorVar>()`. The referenced array is owned by the
    parameter's type, so the loop is safe today, but it relies on an
    implicit lifetime invariant and GCC 13+ reports it under
    `-Wdangling-reference`.
    
    This binds the handle to a named local and iterates by const reference,
    making the lifetime explicit and the build free of this warning. No
    behavior change.
---
 src/tirx/ir/stmt_functor_with_constraint_context.cc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/tirx/ir/stmt_functor_with_constraint_context.cc 
b/src/tirx/ir/stmt_functor_with_constraint_context.cc
index 1efafb9f3..4f357c9cd 100644
--- a/src/tirx/ir/stmt_functor_with_constraint_context.cc
+++ b/src/tirx/ir/stmt_functor_with_constraint_context.cc
@@ -29,7 +29,8 @@ namespace tirx {
 void StmtExprMutatorWithConstraintContext::AddParamConstraints(const Function& 
func) {
   for (const Var& param : func->params) {
     if (!param->ty.as<TensorTypeObj>()) continue;
-    for (PrimExpr shape : param.as_or_throw<TensorVar>().shape()) {
+    TensorVar tensor = param.as_or_throw<TensorVar>();
+    for (const PrimExpr& shape : tensor.shape()) {
       constraints->Append(sym::PredicateConstraint(shape >= 
prim::MakeConst(shape.ty(), 0)));
     }
   }

Reply via email to