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


##########
python/tvm_ffi/cython/tvm_ffi_python_helpers.h:
##########
@@ -36,6 +36,29 @@
 #endif
 #endif
 
+// Local mirror of TVM_FFI_COLD_CODE / TVM_FFI_PREDICT_* from
+// <tvm/ffi/base_details.h>. The Cython helper deliberately avoids that header
+// (keeps the include surface c-headers-only), so we duplicate the macro
+// definitions here. Keep these in sync with base_details.h: same expansion on
+// GCC/Clang, no-op on MSVC.
+#ifndef TVM_FFI_COLD_CODE
+#if defined(__GNUC__) || defined(__clang__)
+#define TVM_FFI_COLD_CODE [[gnu::cold]]
+#else
+#define TVM_FFI_COLD_CODE
+#endif
+#endif
+
+#ifndef TVM_FFI_PREDICT_FALSE
+#if defined(__GNUC__) || defined(__clang__)
+#define TVM_FFI_PREDICT_FALSE(cond) (__builtin_expect(static_cast<bool>(cond), 
0))
+#define TVM_FFI_PREDICT_TRUE(cond) (__builtin_expect(static_cast<bool>(cond), 
1))
+#else
+#define TVM_FFI_PREDICT_FALSE(cond) (cond)
+#define TVM_FFI_PREDICT_TRUE(cond) (cond)
+#endif
+#endif

Review Comment:
   ![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg)
   
   The macros `TVM_FFI_COLD_CODE`, `TVM_FFI_PREDICT_FALSE`, and 
`TVM_FFI_PREDICT_TRUE` are duplicated from `include/tvm/ffi/base_details.h`. 
This duplication introduces a maintenance burden and increases the risk of 
inconsistency if the definitions are updated in one place but not the other. 
Although the comment mentions avoiding the header to keep the include surface 
'c-headers-only', this file already includes several C++ standard library 
headers (e.g., `<vector>`, `<unordered_map>`, `<exception>`). Including 
`tvm/ffi/base_details.h` directly is a cleaner approach and ensures consistency 
across the codebase.
   
   ```c
   #include <tvm/ffi/base_details.h>
   
   ```



-- 
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