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

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


The following commit(s) were added to refs/heads/main by this push:
     new 29408e03c6 [FIX][TIRX] Fix dangling Op static reference warning 
(#19806)
29408e03c6 is described below

commit 29408e03c6f937bc22d38fddc2d1132f07df8db5
Author: Tianqi Chen <[email protected]>
AuthorDate: Wed Jun 17 08:04:31 2026 -0400

    [FIX][TIRX] Fix dangling Op static reference warning (#19806)
    
    ## Summary
    
    GCC can diagnose the TIRX intrinsic helper macros when a static local
    reference binds to the value returned by `Op::Get`.
    
    - Store the unary and binary intrinsic macro lookup result as `static
    const Op`.
    - Preserve the existing generated helper behavior while avoiding the
    dangling-reference pattern.
---
 include/tvm/tirx/op.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/tvm/tirx/op.h b/include/tvm/tirx/op.h
index bae96f2d13..416aff73ee 100644
--- a/include/tvm/tirx/op.h
+++ b/include/tvm/tirx/op.h
@@ -739,7 +739,7 @@ inline void CheckMathUnaryOpInputDType(const char* op_name, 
DataType dtype) {
 // Intrinsic operators
 #define TVM_DECLARE_INTRIN_UNARY_WITH_CHECK(OpName, CheckInputDType)         \
   inline PrimExpr OpName(PrimExpr x, Span span = Span()) {                   \
-    static const Op& op = Op::Get("tirx." #OpName);                          \
+    static const Op op = Op::Get("tirx." #OpName);                           \
     CheckInputDType(#OpName, x.dtype());                                     \
     if (x.dtype().is_bfloat16()) {                                           \
       DataType bf16_dtype = x.dtype();                                       \
@@ -786,7 +786,7 @@ TVM_DECLARE_INTRIN_UNARY(clz);
 
 #define TVM_DECLARE_INTRIN_BINARY(OpName)                              \
   inline PrimExpr OpName(PrimExpr x, PrimExpr y, Span span = Span()) { \
-    static const Op& op = Op::Get("tirx." #OpName);                    \
+    static const Op op = Op::Get("tirx." #OpName);                     \
     return tirx::Call(x.dtype(), op, {x, y}, {}, span);                \
   }
 

Reply via email to