Fixing GCC warning on pointer passed into tracy on frees. (#14721)
diff --git a/runtime/src/iree/base/allocator.c b/runtime/src/iree/base/allocator.c
index c162dd2..fc7f1b4 100644
--- a/runtime/src/iree/base/allocator.c
+++ b/runtime/src/iree/base/allocator.c
@@ -94,6 +94,7 @@
}
});
+ void* existing_ptr_value = iree_tracing_obscure_ptr(existing_ptr);
void* new_ptr = NULL;
if (existing_ptr && command == IREE_ALLOCATOR_COMMAND_REALLOC) {
new_ptr = realloc(existing_ptr, byte_length);
@@ -110,8 +111,8 @@
"system allocator failed the request");
}
- if (existing_ptr) {
- IREE_TRACE_FREE(existing_ptr);
+ if (existing_ptr_value) {
+ IREE_TRACE_FREE(existing_ptr_value);
}
IREE_TRACE_ALLOC(new_ptr, byte_length);
diff --git a/runtime/src/iree/base/tracing.h b/runtime/src/iree/base/tracing.h
index cd59a99..ae5b120 100644
--- a/runtime/src/iree/base/tracing.h
+++ b/runtime/src/iree/base/tracing.h
@@ -306,6 +306,8 @@
#if !(IREE_TRACING_FEATURES & IREE_TRACING_FEATURE_ALLOCATION_TRACKING)
+static void* iree_tracing_obscure_ptr(void* ptr) { return ptr; }
+
// Traces a new memory allocation with host |ptr| and the given |size|.
// A balanced IREE_TRACE_FREE on the same |ptr| is required for proper memory
// tracking. Allocations will be attributed to their parent zone.
diff --git a/runtime/src/iree/base/tracing/console.h b/runtime/src/iree/base/tracing/console.h
index 012f4cf..0177cef 100644
--- a/runtime/src/iree/base/tracing/console.h
+++ b/runtime/src/iree/base/tracing/console.h
@@ -233,6 +233,8 @@
#if IREE_TRACING_FEATURES & IREE_TRACING_FEATURE_ALLOCATION_TRACKING
+static inline void* iree_tracing_obscure_ptr(void* ptr) { return ptr; }
+
// TODO(benvanik): console tracing allocation support. We could just print out
// pointers or keep track of statistics and dump them in IREE_TRACE_APP_EXIT.
#define IREE_TRACE_ALLOC(ptr, size)
diff --git a/runtime/src/iree/base/tracing/tracy.cc b/runtime/src/iree/base/tracing/tracy.cc
index 1962052..d500a5c 100644
--- a/runtime/src/iree/base/tracing/tracy.cc
+++ b/runtime/src/iree/base/tracing/tracy.cc
@@ -321,6 +321,8 @@
#endif // IREE_TRACING_FEATURE_INSTRUMENTATION_DEVICE
+void* iree_tracing_obscure_ptr(void* ptr) { return ptr; }
+
#endif // IREE_TRACING_FEATURES
#ifdef __cplusplus
diff --git a/runtime/src/iree/base/tracing/tracy.h b/runtime/src/iree/base/tracing/tracy.h
index 5bff452..ffe410c 100644
--- a/runtime/src/iree/base/tracing/tracy.h
+++ b/runtime/src/iree/base/tracing/tracy.h
@@ -169,6 +169,8 @@
#endif // IREE_TRACING_FEATURE_INSTRUMENTATION_DEVICE
+void* iree_tracing_obscure_ptr(void* ptr);
+
#endif // IREE_TRACING_FEATURES
#ifdef __cplusplus