Allow defining `IREE_HOST_SIZE_T` to other types. (#14040)
I tried redefining these:
```c
// iree/base/config.h
#if !defined(IREE_HOST_SIZE_T)
#define IREE_HOST_SIZE_T size_t
#define PRIhsz "zu"
#endif // !IREE_HOST_SIZE_T
```
to `uint32_t` and `PRIu32` while debugging some issues with Emscripten
builds, but many parts of the project failed to build.
`IREE_HOST_SIZE_T` should really be set to `size_t` in most/all cases,
but the project should still build if someone wants to redefine it.
Some cases were obviously using the wrong format specifier (e.g. `zu`
instead of `PRIhsz`), but other were more subtle (e.g. interop between
`std::string` with `iree_string_view_t` or using `SIZE_MAX` instead of
`IREE_HOST_SIZE_MAX`). I tried to update as many places as I could
safely.
diff --git a/compiler/src/iree/compiler/ConstEval/Runtime.cpp b/compiler/src/iree/compiler/ConstEval/Runtime.cpp
index ccae609..356082d 100644
--- a/compiler/src/iree/compiler/ConstEval/Runtime.cpp
+++ b/compiler/src/iree/compiler/ConstEval/Runtime.cpp
@@ -99,7 +99,9 @@
iree_vm_function_t function;
if (auto status = iree_vm_module_lookup_function_by_name(
main_module.get(), IREE_VM_FUNCTION_LINKAGE_EXPORT,
- iree_string_view_t{name.data(), name.size()}, &function)) {
+ iree_string_view_t{name.data(),
+ static_cast<iree_host_size_t>(name.size())},
+ &function)) {
iree_status_ignore(status);
return emitError(loc) << "internal error evaling constant: func '" << name
<< "' not found";
diff --git a/experimental/cuda2/cuda_device.c b/experimental/cuda2/cuda_device.c
index e51d326..fd37585 100644
--- a/experimental/cuda2/cuda_device.c
+++ b/experimental/cuda2/cuda_device.c
@@ -411,12 +411,10 @@
"exchanging NCCL ID with other participants");
} else if (params.id.data_length != IREE_ARRAYSIZE(id.data)) {
// User provided something but it's not what we expect.
- return iree_make_status(
- IREE_STATUS_INVALID_ARGUMENT,
- "NCCL ID must be %" PRIhsz
- " bytes matching the ncclUniqueId struct but caller provided %" PRIhsz
- " bytes",
- IREE_ARRAYSIZE(id.data), sizeof(id));
+ return iree_make_status(IREE_STATUS_INVALID_ARGUMENT,
+ "NCCL ID must be %zu bytes matching the "
+ "ncclUniqueId struct but caller provided %zu bytes",
+ IREE_ARRAYSIZE(id.data), sizeof(id));
} else {
// User provided the ID - we treat it as opaque here and let NCCL validate.
memcpy(id.data, params.id.data, IREE_ARRAYSIZE(id.data));
diff --git a/experimental/cuda2/cuda_driver.c b/experimental/cuda2/cuda_driver.c
index b72dab2..4fab559 100644
--- a/experimental/cuda2/cuda_driver.c
+++ b/experimental/cuda2/cuda_driver.c
@@ -448,7 +448,8 @@
"no compatible CUDA devices were found");
} else if (default_device_index >= device_count) {
status = iree_make_status(IREE_STATUS_NOT_FOUND,
- "default device %d not found (of %ld enumerated)",
+ "default device %d not found (of %" PRIhsz
+ " enumerated)",
default_device_index, device_count);
} else {
*out_device = IREE_DEVICE_ID_TO_CUDEVICE(
diff --git a/experimental/cuda2/native_executable.c b/experimental/cuda2/native_executable.c
index 786c179..162c947 100644
--- a/experimental/cuda2/native_executable.c
+++ b/experimental/cuda2/native_executable.c
@@ -297,7 +297,7 @@
if (entry_point >= executable->entry_point_count) {
return iree_make_status(IREE_STATUS_OUT_OF_RANGE,
"entry point ordinal %d out of range; executable "
- "only contains %ld entry points",
+ "only contains %" PRIhsz " entry points",
entry_point, executable->entry_point_count);
}
memcpy(out_params, &executable->entry_points[entry_point],
diff --git a/experimental/cuda2/pipeline_layout.c b/experimental/cuda2/pipeline_layout.c
index 154195e..d05ba3e 100644
--- a/experimental/cuda2/pipeline_layout.c
+++ b/experimental/cuda2/pipeline_layout.c
@@ -142,10 +142,10 @@
*out_pipeline_layout = NULL;
if (push_constant_count > IREE_HAL_CUDA_MAX_PUSH_CONSTANT_COUNT) {
IREE_TRACE_ZONE_END(z0);
- return iree_make_status(IREE_STATUS_INVALID_ARGUMENT,
- "push constant count %zu over the limit of %d",
- push_constant_count,
- IREE_HAL_CUDA_MAX_PUSH_CONSTANT_COUNT);
+ return iree_make_status(
+ IREE_STATUS_INVALID_ARGUMENT,
+ "push constant count %" PRIhsz " over the limit of %d",
+ push_constant_count, IREE_HAL_CUDA_MAX_PUSH_CONSTANT_COUNT);
}
// Currently the pipeline layout doesn't do anything.
diff --git a/experimental/cuda2/tracing.c b/experimental/cuda2/tracing.c
index 6243ad8..e680c46 100644
--- a/experimental/cuda2/tracing.c
+++ b/experimental/cuda2/tracing.c
@@ -95,8 +95,8 @@
if (iree_status_is_ok(status)) {
IREE_TRACE_ZONE_BEGIN_NAMED(
z_event_pool, "iree_hal_cuda2_tracing_context_allocate_event_pool");
- IREE_TRACE_ZONE_APPEND_VALUE(z_event_pool,
- (int64_t)context->query_capacity);
+ IREE_TRACE_ZONE_APPEND_VALUE_I64(z_event_pool,
+ (int64_t)context->query_capacity);
for (iree_host_size_t i = 0; i < context->query_capacity; ++i) {
status = IREE_CURESULT_TO_STATUS(
symbols, cuEventCreate(&context->event_pool[i], CU_EVENT_DEFAULT));
@@ -182,7 +182,7 @@
context->query_head < context->query_tail
? context->query_capacity - context->query_tail
: context->query_head - context->query_tail;
- IREE_TRACE_ZONE_APPEND_VALUE(z0, (int64_t)try_query_count);
+ IREE_TRACE_ZONE_APPEND_VALUE_I64(z0, (int64_t)try_query_count);
// Scan and feed the times to tracy, stopping when we hit the first
// unavailable query.
@@ -207,7 +207,7 @@
read_query_count = i + 1;
}
- IREE_TRACE_ZONE_APPEND_VALUE(z0, (int64_t)read_query_count);
+ IREE_TRACE_ZONE_APPEND_VALUE_I64(z0, (int64_t)read_query_count);
context->query_tail += read_query_count;
if (context->query_tail >= context->query_capacity) {
diff --git a/experimental/rocm/pipeline_layout.c b/experimental/rocm/pipeline_layout.c
index ee137ab..0a27c5b 100644
--- a/experimental/rocm/pipeline_layout.c
+++ b/experimental/rocm/pipeline_layout.c
@@ -132,10 +132,10 @@
IREE_TRACE_ZONE_BEGIN(z0);
if (push_constant_count > IREE_HAL_ROCM_MAX_PUSH_CONSTANT_COUNT) {
- return iree_make_status(IREE_STATUS_INVALID_ARGUMENT,
- "push constant count %zu over the limit of %d",
- push_constant_count,
- IREE_HAL_ROCM_MAX_PUSH_CONSTANT_COUNT);
+ return iree_make_status(
+ IREE_STATUS_INVALID_ARGUMENT,
+ "push constant count %" PRIhsz " over the limit of %d",
+ push_constant_count, IREE_HAL_ROCM_MAX_PUSH_CONSTANT_COUNT);
}
// Currently the pipeline layout doesn't do anything.
diff --git a/experimental/web/sample_dynamic/main.c b/experimental/web/sample_dynamic/main.c
index 4f7d2d5..1eb7c75 100644
--- a/experimental/web/sample_dynamic/main.c
+++ b/experimental/web/sample_dynamic/main.c
@@ -334,7 +334,7 @@
// Query total length (excluding NUL terminator).
iree_host_size_t result_length = 0;
iree_status_t status = iree_hal_buffer_view_format(
- buffer_view, SIZE_MAX, 0, NULL, &result_length);
+ buffer_view, IREE_HOST_SIZE_MAX, 0, NULL, &result_length);
if (!iree_status_is_out_of_range(status)) return status;
++result_length; // include NUL
@@ -343,7 +343,8 @@
IREE_RETURN_IF_ERROR(iree_allocator_malloc(
iree_allocator_system(), result_length, (void**)&result_str));
IREE_RETURN_IF_ERROR(iree_hal_buffer_view_format(
- buffer_view, SIZE_MAX, result_length, result_str, &result_length));
+ buffer_view, IREE_HOST_SIZE_MAX, result_length, result_str,
+ &result_length));
IREE_RETURN_IF_ERROR(iree_string_builder_append_format(
outputs_builder, "%.*s", (int)result_length, result_str));
iree_allocator_free(iree_allocator_system(), result_str);
diff --git a/experimental/webgpu/command_buffer.c b/experimental/webgpu/command_buffer.c
index b5d783d..84af3a1 100644
--- a/experimental/webgpu/command_buffer.c
+++ b/experimental/webgpu/command_buffer.c
@@ -746,7 +746,8 @@
if (IREE_UNLIKELY(offset + values_length >=
sizeof(command_buffer->state.push_constants))) {
return iree_make_status(IREE_STATUS_INVALID_ARGUMENT,
- "push constant range %zu (length=%zu) out of range",
+ "push constant range %" PRIhsz " (length=%" PRIhsz
+ ") out of range",
offset, values_length);
}
diff --git a/experimental/webgpu/executable.c b/experimental/webgpu/executable.c
index 87da423..f9a0fe9 100644
--- a/experimental/webgpu/executable.c
+++ b/experimental/webgpu/executable.c
@@ -38,7 +38,8 @@
if (!flatbuffer_data.data || flatbuffer_data.data_length < 16) {
return iree_make_status(
IREE_STATUS_INVALID_ARGUMENT,
- "flatbuffer data is not present or less than 16 bytes (%zu total)",
+ "flatbuffer data is not present or less than 16 bytes (%" PRIhsz
+ " total)",
flatbuffer_data.data_length);
}
@@ -77,17 +78,17 @@
if (entry_point_count != expected_entry_point_count) {
return iree_make_status(IREE_STATUS_FAILED_PRECONDITION,
"executable provides %zu entry points but caller "
- "provided %zu; must match",
+ "provided %" PRIhsz "; must match",
entry_point_count, expected_entry_point_count);
}
for (size_t i = 0; i < entry_point_count; ++i) {
uint32_t module_ordinal = flatbuffers_uint32_vec_at(entry_points_vec, i);
if (module_ordinal >= shader_module_count) {
- return iree_make_status(
- IREE_STATUS_INVALID_ARGUMENT,
- "executable entry point %zu references an invalid shader module %d",
- i, module_ordinal);
+ return iree_make_status(IREE_STATUS_INVALID_ARGUMENT,
+ "executable entry point %zu"
+ " references an invalid shader module %d",
+ i, module_ordinal);
}
}
diff --git a/experimental/webgpu/pipeline_layout.c b/experimental/webgpu/pipeline_layout.c
index e271cfd..a5c940c 100644
--- a/experimental/webgpu/pipeline_layout.c
+++ b/experimental/webgpu/pipeline_layout.c
@@ -55,7 +55,7 @@
IREE_TRACE_ZONE_END(z0);
return iree_make_status(IREE_STATUS_OUT_OF_RANGE,
"bindings must be in the range of 0-%d; binding "
- "%zu is has ordinal %d",
+ "%" PRIhsz " is has ordinal %d",
IREE_HAL_WEBGPU_MAX_DESCRIPTOR_SET_BINDING_COUNT,
i, bindings[i].binding);
}
diff --git a/experimental/webgpu/simple_allocator.c b/experimental/webgpu/simple_allocator.c
index ddd88ea..20fabca 100644
--- a/experimental/webgpu/simple_allocator.c
+++ b/experimental/webgpu/simple_allocator.c
@@ -128,7 +128,7 @@
static iree_status_t iree_hal_webgpu_simple_allocator_allocate_buffer(
iree_hal_allocator_t* IREE_RESTRICT base_allocator,
const iree_hal_buffer_params_t* IREE_RESTRICT params,
- iree_host_size_t allocation_size, iree_const_byte_span_t initial_data,
+ iree_device_size_t allocation_size, iree_const_byte_span_t initial_data,
iree_hal_buffer_t** IREE_RESTRICT out_buffer) {
IREE_ASSERT_ARGUMENT(base_allocator);
IREE_ASSERT_ARGUMENT(params);
diff --git a/experimental/webgpu/staging_buffer.c b/experimental/webgpu/staging_buffer.c
index 36e5582..d9181e8 100644
--- a/experimental/webgpu/staging_buffer.c
+++ b/experimental/webgpu/staging_buffer.c
@@ -26,8 +26,8 @@
if ((host_buffer_capacity % limits->minUniformBufferOffsetAlignment) != 0) {
IREE_TRACE_ZONE_END(z0);
return iree_make_status(IREE_STATUS_INVALID_ARGUMENT,
- "host buffer capacity (%zu) must match the buffer "
- "offset alignment (%d)",
+ "host buffer capacity (%" PRIhsz
+ ") must match the buffer offset alignment (%d)",
host_buffer_capacity,
limits->minUniformBufferOffsetAlignment);
}
diff --git a/runtime/bindings/python/hal.cc b/runtime/bindings/python/hal.cc
index accae92..eb65c5b 100644
--- a/runtime/bindings/python/hal.cc
+++ b/runtime/bindings/python/hal.cc
@@ -268,7 +268,8 @@
py::object HalDriver::Create(const std::string& device_uri,
py::dict& driver_cache) {
iree_string_view_t driver_name, device_path, params_str;
- iree_string_view_t device_uri_sv{device_uri.data(), device_uri.size()};
+ iree_string_view_t device_uri_sv{
+ device_uri.data(), static_cast<iree_host_size_t>(device_uri.size())};
iree_uri_split(device_uri_sv, &driver_name, &device_path, ¶ms_str);
// Check cache.
@@ -393,7 +394,8 @@
HalDevice HalDriver::CreateDeviceByURI(std::string& device_uri,
const py::kwargs& kwargs) {
iree_hal_device_t* device;
- iree_string_view_t device_uri_sv{device_uri.data(), device_uri.size()};
+ iree_string_view_t device_uri_sv{
+ device_uri.data(), static_cast<iree_host_size_t>(device_uri.size())};
CheckApiStatus(
iree_hal_driver_create_device_by_uri(raw_ptr(), device_uri_sv,
iree_allocator_system(), &device),
diff --git a/runtime/bindings/python/py_module.cc b/runtime/bindings/python/py_module.cc
index 1f7ccd3..f3b8b34 100644
--- a/runtime/bindings/python/py_module.cc
+++ b/runtime/bindings/python/py_module.cc
@@ -58,7 +58,8 @@
static iree_string_view_t ModuleName(void* vself) {
auto self = AsSelf(vself);
- return {self->module_name_.data(), self->module_name_.size()};
+ return {self->module_name_.data(),
+ static_cast<iree_host_size_t>(self->module_name_.size())};
}
static iree_vm_module_signature_t ModuleSignature(void* vself) {
@@ -93,11 +94,12 @@
out_function->ordinal = ordinal;
}
if (IREE_LIKELY(out_name)) {
- *out_name = {f->name.data(), f->name.size()};
+ *out_name = {f->name.data(),
+ static_cast<iree_host_size_t>(f->name.size())};
}
if (IREE_LIKELY(out_signature)) {
- out_signature->calling_convention = {f->cconv.data(),
- f->cconv.size()};
+ out_signature->calling_convention = {
+ f->cconv.data(), static_cast<iree_host_size_t>(f->cconv.size())};
}
return iree_ok_status();
}
@@ -239,9 +241,11 @@
std::move(name), std::move(cconv), std::move(callable));
exports_.push_back({});
iree_vm_native_export_descriptor_t& d = exports_.back();
- d.local_name = {py_function->name.data(), py_function->name.size()};
- d.calling_convention = {py_function->cconv.data(),
- py_function->cconv.size()};
+ d.local_name = {py_function->name.data(),
+ static_cast<iree_host_size_t>(py_function->name.size())};
+ d.calling_convention = {
+ py_function->cconv.data(),
+ static_cast<iree_host_size_t>(py_function->cconv.size())};
d.attr_count = 0;
d.attrs = nullptr;
std::string& alloced_name = py_function->name;
@@ -261,7 +265,8 @@
AssertMutable();
initialized_ = true;
memset(&descriptor_, 0, sizeof(descriptor_));
- descriptor_.name = {module_name_.data(), module_name_.size()};
+ descriptor_.name = {module_name_.data(),
+ static_cast<iree_host_size_t>(module_name_.size())};
descriptor_.version = version_;
descriptor_.attr_count = attrs_.size();
descriptor_.attrs = attrs_.empty() ? nullptr : attrs_.data();
@@ -298,7 +303,8 @@
iree_status_t ParseCconv() {
iree_vm_function_signature_t signature;
memset(&signature, 0, sizeof(signature));
- signature.calling_convention = {cconv.data(), cconv.size()};
+ signature.calling_convention = {
+ cconv.data(), static_cast<iree_host_size_t>(cconv.size())};
IREE_RETURN_IF_ERROR(iree_vm_function_call_get_cconv_fragments(
&signature, &cconv_arguments, &cconv_results));
@@ -324,10 +330,11 @@
&packed_arguments_required_size));
if (IREE_UNLIKELY(packed_arguments_required_size !=
call.arguments.data_length)) {
- return iree_make_status(
- IREE_STATUS_INVALID_ARGUMENT,
- "mismatched packed argument size: actual=%zu, required=%zu",
- call.arguments.data_length, packed_arguments_required_size);
+ return iree_make_status(IREE_STATUS_INVALID_ARGUMENT,
+ "mismatched packed argument size: actual=%" PRIhsz
+ ", required=%" PRIhsz,
+ call.arguments.data_length,
+ packed_arguments_required_size);
}
// Unpack arguments.
diff --git a/runtime/bindings/python/vm.cc b/runtime/bindings/python/vm.cc
index 9a3a4fd..c39a374 100644
--- a/runtime/bindings/python/vm.cc
+++ b/runtime/bindings/python/vm.cc
@@ -205,7 +205,8 @@
const std::string& name, iree_vm_function_linkage_t linkage) {
iree_vm_function_t f;
auto status = iree_vm_module_lookup_function_by_name(
- raw_ptr(), linkage, {name.data(), name.size()}, &f);
+ raw_ptr(), linkage,
+ {name.data(), static_cast<iree_host_size_t>(name.size())}, &f);
if (iree_status_is_not_found(status)) {
iree_status_ignore(status);
return std::nullopt;
@@ -388,7 +389,7 @@
}
// Extract dims from the buffer view.
- size_t rank = 0;
+ iree_host_size_t rank = 0;
std::vector<iree_hal_dim_t> dims(6);
iree_status_t status = iree_hal_buffer_view_shape(
buffer_view, dims.capacity(), dims.data(), &rank);
diff --git a/runtime/src/iree/base/internal/dynamic_library_posix.c b/runtime/src/iree/base/internal/dynamic_library_posix.c
index 8c080c2..b9b43a6 100644
--- a/runtime/src/iree/base/internal/dynamic_library_posix.c
+++ b/runtime/src/iree/base/internal/dynamic_library_posix.c
@@ -95,10 +95,10 @@
if (iree_status_is_ok(status)) {
if (fwrite((char*)source_data.data, source_data.data_length, 1,
file_handle) != 1) {
- status =
- iree_make_status(iree_status_code_from_errno(errno),
- "unable to write file span of %zu bytes to '%s'",
- source_data.data_length, *out_file_path);
+ status = iree_make_status(iree_status_code_from_errno(errno),
+ "unable to write file span of %" PRIhsz
+ " bytes to '%s'",
+ source_data.data_length, *out_file_path);
}
}
diff --git a/runtime/src/iree/base/internal/dynamic_library_win32.c b/runtime/src/iree/base/internal/dynamic_library_win32.c
index d123d63..e4c2175 100644
--- a/runtime/src/iree/base/internal/dynamic_library_win32.c
+++ b/runtime/src/iree/base/internal/dynamic_library_win32.c
@@ -141,10 +141,10 @@
if (iree_status_is_ok(status)) {
if (WriteFile(file_handle, source_data.data, (DWORD)source_data.data_length,
NULL, NULL) == FALSE) {
- status =
- iree_make_status(iree_status_code_from_win32_error(GetLastError()),
- "unable to write file span of %zu bytes to '%s'",
- source_data.data_length, *out_file_path);
+ status = iree_make_status(
+ iree_status_code_from_win32_error(GetLastError()),
+ "unable to write file span of %" PRIhsz " bytes to '%s'",
+ source_data.data_length, *out_file_path);
}
}
diff --git a/runtime/src/iree/base/internal/file_io.c b/runtime/src/iree/base/internal/file_io.c
index a9974c1..9a686c0 100644
--- a/runtime/src/iree/base/internal/file_io.c
+++ b/runtime/src/iree/base/internal/file_io.c
@@ -146,7 +146,8 @@
if (fread(contents->buffer.data, 1, file_size, file) != file_size) {
iree_allocator_free(allocator, contents);
return iree_make_status(IREE_STATUS_PERMISSION_DENIED,
- "unable to read entire %zu file bytes", file_size);
+ "unable to read entire %" PRIhsz " file bytes",
+ file_size);
}
// Add trailing NUL to make the contents C-string compatible.
@@ -199,10 +200,10 @@
if (content.data_length > 0) {
int ret = fwrite((char*)content.data, content.data_length, 1, file);
if (ret != 1) {
- status =
- iree_make_status(IREE_STATUS_DATA_LOSS,
- "unable to write file contents of %zu bytes to '%s'",
- content.data_length, path);
+ status = iree_make_status(IREE_STATUS_DATA_LOSS,
+ "unable to write file contents of %" PRIhsz
+ " bytes to '%s'",
+ content.data_length, path);
}
}
diff --git a/runtime/src/iree/base/internal/wait_handle_inproc.c b/runtime/src/iree/base/internal/wait_handle_inproc.c
index 6eb3041..e319259 100644
--- a/runtime/src/iree/base/internal/wait_handle_inproc.c
+++ b/runtime/src/iree/base/internal/wait_handle_inproc.c
@@ -112,9 +112,9 @@
iree_wait_set_t** out_set) {
// Be reasonable; 64K objects is too high.
if (capacity >= UINT16_MAX) {
- return iree_make_status(IREE_STATUS_INVALID_ARGUMENT,
- "wait set capacity of %zu is unreasonably large",
- capacity);
+ return iree_make_status(
+ IREE_STATUS_INVALID_ARGUMENT,
+ "wait set capacity of %" PRIhsz " is unreasonably large", capacity);
}
IREE_TRACE_ZONE_BEGIN(z0);
diff --git a/runtime/src/iree/base/internal/wait_handle_poll.c b/runtime/src/iree/base/internal/wait_handle_poll.c
index 2ff7cfc..b2adc9b 100644
--- a/runtime/src/iree/base/internal/wait_handle_poll.c
+++ b/runtime/src/iree/base/internal/wait_handle_poll.c
@@ -139,9 +139,9 @@
// Be reasonable; 64K objects is too high (even if poll supports it, which is
// hard to tell if it does).
if (capacity >= UINT16_MAX) {
- return iree_make_status(IREE_STATUS_INVALID_ARGUMENT,
- "wait set capacity of %zu is unreasonably large",
- capacity);
+ return iree_make_status(
+ IREE_STATUS_INVALID_ARGUMENT,
+ "wait set capacity of %" PRIhsz " is unreasonably large", capacity);
}
IREE_TRACE_ZONE_BEGIN(z0);
diff --git a/runtime/src/iree/base/internal/wait_handle_win32.c b/runtime/src/iree/base/internal/wait_handle_win32.c
index b24b455..ef0d61a 100644
--- a/runtime/src/iree/base/internal/wait_handle_win32.c
+++ b/runtime/src/iree/base/internal/wait_handle_win32.c
@@ -138,9 +138,9 @@
// Be reasonable; 64 MAXIMUM_WAIT_OBJECTS is low, but 64K objects is too high.
if (capacity >= UINT16_MAX) {
- return iree_make_status(IREE_STATUS_INVALID_ARGUMENT,
- "wait set capacity of %zu is unreasonably large",
- capacity);
+ return iree_make_status(
+ IREE_STATUS_INVALID_ARGUMENT,
+ "wait set capacity of %" PRIhsz " is unreasonably large", capacity);
}
IREE_TRACE_ZONE_BEGIN(z0);
diff --git a/runtime/src/iree/base/string_view.h b/runtime/src/iree/base/string_view.h
index d93945e..b342dab 100644
--- a/runtime/src/iree/base/string_view.h
+++ b/runtime/src/iree/base/string_view.h
@@ -22,7 +22,7 @@
typedef struct iree_status_handle_t* iree_status_t;
-#define IREE_STRING_VIEW_NPOS SIZE_MAX
+#define IREE_STRING_VIEW_NPOS IREE_HOST_SIZE_MAX
// A string view (ala std::string_view) into a non-NUL-terminated string.
typedef struct iree_string_view_t {
@@ -164,8 +164,8 @@
iree_string_view_trim(iree_string_view_t value);
// Returns a substring of the string view at offset |pos| and length |n|.
-// Use |n| == INTPTR_MAX to take the remainder of the string after |pos|.
-// Returns empty string on failure.
+// Use |n| == IREE_HOST_SIZE_MAX to take the remainder of the string after
+// |pos|. Returns empty string on failure.
IREE_API_EXPORT iree_string_view_t iree_string_view_substr(
iree_string_view_t value, iree_host_size_t pos, iree_host_size_t n);
diff --git a/runtime/src/iree/base/string_view_test.cc b/runtime/src/iree/base/string_view_test.cc
index a2dbf7c..c0d9eba 100644
--- a/runtime/src/iree/base/string_view_test.cc
+++ b/runtime/src/iree/base/string_view_test.cc
@@ -330,27 +330,27 @@
};
EXPECT_EQ(substr("", 0, 0), "");
EXPECT_EQ(substr("", 0, 1), "");
- EXPECT_EQ(substr("", 0, INTPTR_MAX), "");
+ EXPECT_EQ(substr("", 0, IREE_STRING_VIEW_NPOS), "");
EXPECT_EQ(substr("", 1, 0), "");
EXPECT_EQ(substr("", 1, 1), "");
- EXPECT_EQ(substr("", 1, INTPTR_MAX), "");
+ EXPECT_EQ(substr("", 1, IREE_STRING_VIEW_NPOS), "");
EXPECT_EQ(substr("a", 0, 0), "");
EXPECT_EQ(substr("a", 0, 1), "a");
EXPECT_EQ(substr("a", 0, 2), "a");
- EXPECT_EQ(substr("a", 0, INTPTR_MAX), "a");
+ EXPECT_EQ(substr("a", 0, IREE_STRING_VIEW_NPOS), "a");
EXPECT_EQ(substr("a", 1, 0), "");
EXPECT_EQ(substr("a", 1, 1), "");
- EXPECT_EQ(substr("a", 1, INTPTR_MAX), "");
+ EXPECT_EQ(substr("a", 1, IREE_STRING_VIEW_NPOS), "");
EXPECT_EQ(substr("abc", 0, 1), "a");
EXPECT_EQ(substr("abc", 1, 1), "b");
EXPECT_EQ(substr("abc", 2, 1), "c");
EXPECT_EQ(substr("abc", 0, 2), "ab");
EXPECT_EQ(substr("abc", 1, 2), "bc");
- EXPECT_EQ(substr("abc", 1, INTPTR_MAX), "bc");
+ EXPECT_EQ(substr("abc", 1, IREE_STRING_VIEW_NPOS), "bc");
EXPECT_EQ(substr("abc", 0, 3), "abc");
- EXPECT_EQ(substr("abc", 0, INTPTR_MAX), "abc");
+ EXPECT_EQ(substr("abc", 0, IREE_STRING_VIEW_NPOS), "abc");
}
TEST(StringViewTest, Split) {
@@ -608,7 +608,8 @@
iree::StatusOr<iree_device_size_t> ParseDeviceSize(std::string_view value) {
iree_device_size_t size = 0;
IREE_RETURN_IF_ERROR(iree::Status(iree_string_view_parse_device_size(
- iree_string_view_t{value.data(), value.size()}, &size)));
+ iree_string_view_t{value.data(), (iree_host_size_t)value.size()},
+ &size)));
return size;
}
diff --git a/runtime/src/iree/hal/buffer.c b/runtime/src/iree/hal/buffer.c
index 2c95237..7a682e7 100644
--- a/runtime/src/iree/hal/buffer.c
+++ b/runtime/src/iree/hal/buffer.c
@@ -588,9 +588,10 @@
if (IREE_UNLIKELY(pattern_length != 1 && pattern_length != 2 &&
pattern_length != 4)) {
- return iree_make_status(IREE_STATUS_INVALID_ARGUMENT,
- "fill patterns must be 1, 2, or 4 bytes (got %zu)",
- pattern_length);
+ return iree_make_status(
+ IREE_STATUS_INVALID_ARGUMENT,
+ "fill patterns must be 1, 2, or 4 bytes (got %" PRIhsz ")",
+ pattern_length);
}
if (byte_length == 0) {
@@ -612,7 +613,8 @@
iree_status_ignore(iree_hal_buffer_unmap_range(&target_mapping));
IREE_TRACE_ZONE_END(z0);
return iree_make_status(IREE_STATUS_INVALID_ARGUMENT,
- "attempting to fill a range with %zu byte values "
+ "attempting to fill a range with %" PRIhsz
+ " byte values "
"that is not aligned (offset=%" PRIdsz
", length=%" PRIdsz ")",
pattern_length, byte_offset, byte_length);
@@ -652,7 +654,7 @@
}
default:
status = iree_make_status(IREE_STATUS_INVALID_ARGUMENT,
- "unsupported fill pattern length: %zu",
+ "unsupported fill pattern length: %" PRIhsz,
pattern_length);
break;
}
diff --git a/runtime/src/iree/hal/buffer_view.c b/runtime/src/iree/hal/buffer_view.c
index 508c0c0..3dd6632 100644
--- a/runtime/src/iree/hal/buffer_view.c
+++ b/runtime/src/iree/hal/buffer_view.c
@@ -175,7 +175,7 @@
// remembering all the conditions in which they may be.
return iree_make_status(IREE_STATUS_INVALID_ARGUMENT,
"buffer view reshapes must have the same rank; "
- "target=%zu, existing=%zu",
+ "target=%" PRIhsz " , existing=%" PRIhsz,
shape_rank, buffer_view->shape_rank);
}
diff --git a/runtime/src/iree/hal/buffer_view_util.c b/runtime/src/iree/hal/buffer_view_util.c
index 73fa880..7413a64 100644
--- a/runtime/src/iree/hal/buffer_view_util.c
+++ b/runtime/src/iree/hal/buffer_view_util.c
@@ -72,7 +72,8 @@
"opaque and sub-byte aligned element types cannot be indexed");
} else if (IREE_UNLIKELY(shape_rank != indices_count)) {
return iree_make_status(IREE_STATUS_INVALID_ARGUMENT,
- "shape rank/indices mismatch: %zu != %zu",
+ "shape rank/indices mismatch: %" PRIhsz
+ " != %" PRIhsz,
shape_rank, indices_count);
}
@@ -80,7 +81,7 @@
for (iree_host_size_t i = 0; i < indices_count; ++i) {
if (IREE_UNLIKELY(indices[i] >= shape[i])) {
return iree_make_status(IREE_STATUS_OUT_OF_RANGE,
- "index[%zu] out of bounds: %" PRIdim
+ "index[%" PRIhsz "] out of bounds: %" PRIdim
" >= %" PRIdim,
i, indices[i], shape[i]);
}
@@ -121,11 +122,12 @@
"opaque and sub-byte aligned element types cannot be indexed");
} else if (IREE_UNLIKELY(indices_count != lengths_count)) {
return iree_make_status(IREE_STATUS_INVALID_ARGUMENT,
- "indices/lengths mismatch: %zu != %zu",
+ "indices/lengths mismatch: %" PRIhsz " != %" PRIhsz,
indices_count, lengths_count);
} else if (IREE_UNLIKELY(shape_rank != indices_count)) {
return iree_make_status(IREE_STATUS_INVALID_ARGUMENT,
- "shape rank/indices mismatch: %zu != %zu",
+ "shape rank/indices mismatch: %" PRIhsz
+ " != %" PRIhsz,
shape_rank, indices_count);
}
@@ -381,9 +383,10 @@
!iree_status_is_out_of_range(shape_result)) {
return shape_result;
} else if (shape_rank > 128) {
- return iree_make_status(
- IREE_STATUS_RESOURCE_EXHAUSTED,
- "a shape rank of %zu is just a little bit excessive, eh?", shape_rank);
+ return iree_make_status(IREE_STATUS_RESOURCE_EXHAUSTED,
+ "a shape rank of %" PRIhsz
+ " is just a little bit excessive, eh?",
+ shape_rank);
}
shape_result = iree_status_ignore(shape_result);
iree_hal_dim_t* shape =
diff --git a/runtime/src/iree/hal/command_buffer.c b/runtime/src/iree/hal/command_buffer.c
index 8c95eb5..49c60dc 100644
--- a/runtime/src/iree/hal/command_buffer.c
+++ b/runtime/src/iree/hal/command_buffer.c
@@ -674,9 +674,10 @@
transfer_command->update.length);
break;
default:
- status = iree_make_status(IREE_STATUS_INVALID_ARGUMENT,
- "unknown transfer_commands[%zu] type %d", i,
- (int)transfer_command->type);
+ status =
+ iree_make_status(IREE_STATUS_INVALID_ARGUMENT,
+ "unknown transfer_commands[%" PRIhsz "] type %d",
+ i, (int)transfer_command->type);
break;
}
if (!iree_status_is_ok(status)) break;
diff --git a/runtime/src/iree/hal/command_buffer_validation.c b/runtime/src/iree/hal/command_buffer_validation.c
index 5e87c39..09f7415 100644
--- a/runtime/src/iree/hal/command_buffer_validation.c
+++ b/runtime/src/iree/hal/command_buffer_validation.c
@@ -246,7 +246,7 @@
if (pattern_length != 1 && pattern_length != 2 && pattern_length != 4) {
return iree_make_status(IREE_STATUS_INVALID_ARGUMENT,
"fill value length is not one of the supported "
- "values (pattern_length=%zu)",
+ "values (pattern_length=%" PRIhsz ")",
pattern_length);
}
@@ -256,7 +256,7 @@
IREE_STATUS_INVALID_ARGUMENT,
"fill offset and/or length do not match the natural alignment of the "
"fill value (target_offset=%" PRIdsz ", length=%" PRIdsz
- ", pattern_length=%zu)",
+ ", pattern_length=%" PRIhsz ")",
target_offset, length, pattern_length);
}
@@ -473,9 +473,9 @@
command_buffer, validation_state, IREE_HAL_COMMAND_CATEGORY_DISPATCH));
if (IREE_UNLIKELY((values_length % 4) != 0)) {
- return iree_make_status(IREE_STATUS_INVALID_ARGUMENT,
- "invalid alignment %zu, must be 4-byte aligned",
- values_length);
+ return iree_make_status(
+ IREE_STATUS_INVALID_ARGUMENT,
+ "invalid alignment %" PRIhsz ", must be 4-byte aligned", values_length);
}
// TODO(benvanik): validate offset and value count with layout.
diff --git a/runtime/src/iree/hal/drivers/cuda/cuda_device.c b/runtime/src/iree/hal/drivers/cuda/cuda_device.c
index 0bcc0be..832b638 100644
--- a/runtime/src/iree/hal/drivers/cuda/cuda_device.c
+++ b/runtime/src/iree/hal/drivers/cuda/cuda_device.c
@@ -409,12 +409,10 @@
"exchanging NCCL ID with other participants");
} else if (params.id.data_length != IREE_ARRAYSIZE(id.data)) {
// User provided something but it's not what we expect.
- return iree_make_status(
- IREE_STATUS_INVALID_ARGUMENT,
- "NCCL ID must be %" PRIhsz
- " bytes matching the ncclUniqueId struct but caller provided %" PRIhsz
- " bytes",
- IREE_ARRAYSIZE(id.data), sizeof(id));
+ return iree_make_status(IREE_STATUS_INVALID_ARGUMENT,
+ "NCCL ID must be %zu bytes matching the "
+ "ncclUniqueId struct but caller provided %zu bytes",
+ IREE_ARRAYSIZE(id.data), sizeof(id));
} else {
// User provided the ID - we treat it as opaque here and let NCCL validate.
memcpy(id.data, params.id.data, IREE_ARRAYSIZE(id.data));
diff --git a/runtime/src/iree/hal/drivers/cuda/cuda_driver.c b/runtime/src/iree/hal/drivers/cuda/cuda_driver.c
index 46f73ec..7d2f50a 100644
--- a/runtime/src/iree/hal/drivers/cuda/cuda_driver.c
+++ b/runtime/src/iree/hal/drivers/cuda/cuda_driver.c
@@ -253,7 +253,8 @@
"no compatible CUDA devices were found");
} else if (default_device_index >= device_count) {
status = iree_make_status(IREE_STATUS_NOT_FOUND,
- "default device %d not found (of %ld enumerated)",
+ "default device %d not found (of %" PRIhsz
+ " enumerated)",
default_device_index, device_count);
} else {
*out_device =
diff --git a/runtime/src/iree/hal/drivers/cuda/pipeline_layout.c b/runtime/src/iree/hal/drivers/cuda/pipeline_layout.c
index cddec7b..abd55b7 100644
--- a/runtime/src/iree/hal/drivers/cuda/pipeline_layout.c
+++ b/runtime/src/iree/hal/drivers/cuda/pipeline_layout.c
@@ -132,10 +132,10 @@
IREE_TRACE_ZONE_BEGIN(z0);
if (push_constant_count > IREE_HAL_CUDA_MAX_PUSH_CONSTANT_COUNT) {
- return iree_make_status(IREE_STATUS_INVALID_ARGUMENT,
- "push constant count %zu over the limit of %d",
- push_constant_count,
- IREE_HAL_CUDA_MAX_PUSH_CONSTANT_COUNT);
+ return iree_make_status(
+ IREE_STATUS_INVALID_ARGUMENT,
+ "push constant count %" PRIhsz " over the limit of %d",
+ push_constant_count, IREE_HAL_CUDA_MAX_PUSH_CONSTANT_COUNT);
}
// Currently the pipeline layout doesn't do anything.
diff --git a/runtime/src/iree/hal/drivers/local_task/task_command_buffer.c b/runtime/src/iree/hal/drivers/local_task/task_command_buffer.c
index 389dd18..cd1cdbe 100644
--- a/runtime/src/iree/hal/drivers/local_task/task_command_buffer.c
+++ b/runtime/src/iree/hal/drivers/local_task/task_command_buffer.c
@@ -741,7 +741,8 @@
if (IREE_UNLIKELY(offset + values_length >=
sizeof(command_buffer->state.push_constants))) {
return iree_make_status(IREE_STATUS_INVALID_ARGUMENT,
- "push constant range %zu (length=%zu) out of range",
+ "push constant range %" PRIhsz " (length=%" PRIhsz
+ ") out of range",
offset, values_length);
}
diff --git a/runtime/src/iree/hal/drivers/vulkan/native_executable.cc b/runtime/src/iree/hal/drivers/vulkan/native_executable.cc
index 7aabf5b..fb91041 100644
--- a/runtime/src/iree/hal/drivers/vulkan/native_executable.cc
+++ b/runtime/src/iree/hal/drivers/vulkan/native_executable.cc
@@ -198,7 +198,8 @@
if (!flatbuffer_data.data || flatbuffer_data.data_length < 16) {
return iree_make_status(
IREE_STATUS_INVALID_ARGUMENT,
- "FlatBuffer data is not present or less than 16 bytes (%zu total)",
+ "FlatBuffer data is not present or less than 16 bytes (%" PRIhsz
+ " total)",
flatbuffer_data.data_length);
}
@@ -222,7 +223,7 @@
if (entry_point_count != expected_entry_point_count) {
return iree_make_status(IREE_STATUS_FAILED_PRECONDITION,
"executable provides %zu entry points but caller "
- "provided %zu; must match",
+ "provided %" PRIhsz "; must match",
entry_point_count, expected_entry_point_count);
}
@@ -241,7 +242,8 @@
if (subgroup_sizes_count != expected_entry_point_count) {
return iree_make_status(
IREE_STATUS_INVALID_ARGUMENT,
- "executable has %zu entry points but %zu subgroup sizes are defined",
+ "executable has %" PRIhsz
+ " entry points but %zu subgroup sizes are defined",
expected_entry_point_count, subgroup_sizes_count);
}
}
@@ -419,7 +421,8 @@
iree_hal_vulkan_native_executable_cast(base_executable);
if (entry_ordinal >= executable->entry_point_count) {
return iree_make_status(IREE_STATUS_OUT_OF_RANGE,
- "invalid entry point ordinal %zu", entry_ordinal);
+ "invalid entry point ordinal %" PRIhsz,
+ entry_ordinal);
}
*out_pipeline_handle = executable->entry_points[entry_ordinal].pipeline;
return iree_ok_status();
diff --git a/runtime/src/iree/hal/local/elf/elf_module.c b/runtime/src/iree/hal/local/elf/elf_module.c
index eff2632..3d1b0a3 100644
--- a/runtime/src/iree/hal/local/elf/elf_module.c
+++ b/runtime/src/iree/hal/local/elf/elf_module.c
@@ -37,10 +37,10 @@
iree_const_byte_span_t raw_data) {
// Size must be larger than the header we are trying to load.
if (raw_data.data_length < sizeof(iree_elf_ehdr_t)) {
- return iree_make_status(
- IREE_STATUS_FAILED_PRECONDITION,
- "ELF data provided (%zu) is smaller than ehdr (%zu)",
- raw_data.data_length, sizeof(iree_elf_ehdr_t));
+ return iree_make_status(IREE_STATUS_FAILED_PRECONDITION,
+ "ELF data provided (%" PRIhsz
+ ") is smaller than ehdr (%zu)",
+ raw_data.data_length, sizeof(iree_elf_ehdr_t));
}
// Check for ELF identifier.
diff --git a/runtime/src/iree/hal/local/executable_library_util.c b/runtime/src/iree/hal/local/executable_library_util.c
index 2e763ef..50352fb 100644
--- a/runtime/src/iree/hal/local/executable_library_util.c
+++ b/runtime/src/iree/hal/local/executable_library_util.c
@@ -24,7 +24,7 @@
if (library->exports.count != executable_params->pipeline_layout_count) {
return iree_make_status(IREE_STATUS_FAILED_PRECONDITION,
"executable provides %u entry points but caller "
- "provided %zu; must match",
+ "provided %" PRIhsz "; must match",
library->exports.count,
executable_params->pipeline_layout_count);
}
@@ -34,7 +34,7 @@
if (library->constants.count != executable_params->constant_count) {
return iree_make_status(IREE_STATUS_FAILED_PRECONDITION,
"executable requires %u constants but caller "
- "provided %zu; must match",
+ "provided %" PRIhsz "; must match",
library->constants.count,
executable_params->constant_count);
}
diff --git a/runtime/src/iree/hal/local/executable_plugin.h b/runtime/src/iree/hal/local/executable_plugin.h
index 30f03a3..12d13b6 100644
--- a/runtime/src/iree/hal/local/executable_plugin.h
+++ b/runtime/src/iree/hal/local/executable_plugin.h
@@ -120,6 +120,13 @@
IREE_HAL_EXECUTABLE_PLUGIN_SANITIZER_NONE
#endif // !IREE_HAL_EXECUTABLE_PLUGIN_SANITIZER_KIND
+#if !defined(IREE_HOST_SIZE_T)
+#define IREE_HOST_SIZE_T size_t
+#endif // !IREE_HOST_SIZE_T
+
+// Size, in bytes, of a buffer on the local host.
+typedef IREE_HOST_SIZE_T iree_host_size_t;
+
//===----------------------------------------------------------------------===//
// Versioning and interface querying
//===----------------------------------------------------------------------===//
@@ -276,7 +283,7 @@
} iree_hal_executable_plugin_allocator_command_t;
typedef struct iree_hal_executable_plugin_allocator_alloc_params_t {
- size_t byte_length;
+ iree_host_size_t byte_length;
} iree_hal_executable_plugin_allocator_alloc_params_t;
typedef iree_hal_executable_plugin_status_t (
@@ -291,8 +298,8 @@
static inline iree_hal_executable_plugin_status_t
iree_hal_executable_plugin_allocator_malloc(
- iree_hal_executable_plugin_allocator_t allocator, size_t byte_length,
- void** inout_ptr) {
+ iree_hal_executable_plugin_allocator_t allocator,
+ iree_host_size_t byte_length, void** inout_ptr) {
iree_hal_executable_plugin_allocator_alloc_params_t params = {byte_length};
return allocator.ctl(allocator.self,
IREE_HAL_EXECUTABLE_PLUGIN_ALLOCATOR_COMMAND_MALLOC,
@@ -316,7 +323,7 @@
// characters) must be used.
typedef struct iree_hal_executable_plugin_string_view_t {
const char* data;
- size_t size;
+ iree_host_size_t size;
} iree_hal_executable_plugin_string_view_t;
// iree_string_pair_t-compatible type.
diff --git a/runtime/src/iree/hal/local/executable_plugin_manager.c b/runtime/src/iree/hal/local/executable_plugin_manager.c
index aae139a..6d41c76 100644
--- a/runtime/src/iree/hal/local/executable_plugin_manager.c
+++ b/runtime/src/iree/hal/local/executable_plugin_manager.c
@@ -563,11 +563,11 @@
iree_string_builder_append_cstring(&builder, symbol_names[i]));
++missing_count;
}
- status =
- iree_make_status(IREE_STATUS_NOT_FOUND,
- "missing %zu required executable imports: [%.*s]",
- missing_count, (int)iree_string_builder_size(&builder),
- iree_string_builder_buffer(&builder));
+ status = iree_make_status(
+ IREE_STATUS_NOT_FOUND,
+ "missing %" PRIhsz " required executable imports: [%.*s]",
+ missing_count, (int)iree_string_builder_size(&builder),
+ iree_string_builder_buffer(&builder));
iree_string_builder_deinitialize(&builder);
#else
status = iree_status_from_code(IREE_STATUS_NOT_FOUND);
diff --git a/runtime/src/iree/hal/local/inline_command_buffer.c b/runtime/src/iree/hal/local/inline_command_buffer.c
index cbcf7a0..0f5071a 100644
--- a/runtime/src/iree/hal/local/inline_command_buffer.c
+++ b/runtime/src/iree/hal/local/inline_command_buffer.c
@@ -376,7 +376,8 @@
if (IREE_UNLIKELY(offset + values_length >=
sizeof(command_buffer->state.push_constants))) {
return iree_make_status(IREE_STATUS_INVALID_ARGUMENT,
- "push constant range %zu (length=%zu) out of range",
+ "push constant range %" PRIhsz " (length=%" PRIhsz
+ ") out of range",
offset, values_length);
}
diff --git a/runtime/src/iree/hal/local/loaders/vmvx_module_loader.c b/runtime/src/iree/hal/local/loaders/vmvx_module_loader.c
index bfb5441..e83efd3 100644
--- a/runtime/src/iree/hal/local/loaders/vmvx_module_loader.c
+++ b/runtime/src/iree/hal/local/loaders/vmvx_module_loader.c
@@ -233,8 +233,9 @@
if (executable_params->pipeline_layout_count > 0 &&
entry_count != executable_params->pipeline_layout_count) {
return iree_make_status(IREE_STATUS_FAILED_PRECONDITION,
- "executable provides %zu entry points but caller "
- "provided %zu; must match",
+ "executable provides %" PRIhsz
+ " entry points but caller "
+ "provided %" PRIhsz "; must match",
entry_count,
executable_params->pipeline_layout_count);
}
diff --git a/runtime/src/iree/hal/local/local_pipeline_layout.c b/runtime/src/iree/hal/local/local_pipeline_layout.c
index 012bf88..d1b3cf6 100644
--- a/runtime/src/iree/hal/local/local_pipeline_layout.c
+++ b/runtime/src/iree/hal/local/local_pipeline_layout.c
@@ -34,9 +34,10 @@
IREE_ASSERT_ARGUMENT(out_descriptor_set_layout);
*out_descriptor_set_layout = NULL;
if (binding_count > IREE_HAL_LOCAL_MAX_DESCRIPTOR_BINDING_COUNT) {
- return iree_make_status(
- IREE_STATUS_INVALID_ARGUMENT, "binding count %zu over the limit of %d",
- binding_count, IREE_HAL_LOCAL_MAX_DESCRIPTOR_BINDING_COUNT);
+ return iree_make_status(IREE_STATUS_INVALID_ARGUMENT,
+ "binding count %" PRIhsz " over the limit of %d",
+ binding_count,
+ IREE_HAL_LOCAL_MAX_DESCRIPTOR_BINDING_COUNT);
}
IREE_TRACE_ZONE_BEGIN(z0);
@@ -101,15 +102,15 @@
*out_pipeline_layout = NULL;
if (set_layout_count > IREE_HAL_LOCAL_MAX_DESCRIPTOR_SET_COUNT) {
return iree_make_status(IREE_STATUS_INVALID_ARGUMENT,
- "set layout count %zu over the limit of %d",
+ "set layout count %" PRIhsz " over the limit of %d",
set_layout_count,
IREE_HAL_LOCAL_MAX_DESCRIPTOR_SET_COUNT);
}
if (push_constants > IREE_HAL_LOCAL_MAX_PUSH_CONSTANT_COUNT) {
- return iree_make_status(IREE_STATUS_INVALID_ARGUMENT,
- "push constant count %zu over the limit of %d",
- push_constants,
- IREE_HAL_LOCAL_MAX_PUSH_CONSTANT_COUNT);
+ return iree_make_status(
+ IREE_STATUS_INVALID_ARGUMENT,
+ "push constant count %" PRIhsz " over the limit of %d", push_constants,
+ IREE_HAL_LOCAL_MAX_PUSH_CONSTANT_COUNT);
}
IREE_TRACE_ZONE_BEGIN(z0);
diff --git a/runtime/src/iree/hal/string_util.c b/runtime/src/iree/hal/string_util.c
index 160ed73..c3420da 100644
--- a/runtime/src/iree/hal/string_util.c
+++ b/runtime/src/iree/hal/string_util.c
@@ -51,20 +51,20 @@
int32_t parsed_value = 0;
if (!iree_string_view_atoi_int32(lhs, &parsed_value) ||
parsed_value < 0) {
- return iree_make_status(IREE_STATUS_INVALID_ARGUMENT,
- "shape[%zu] invalid value '%.*s' of '%.*s'",
- dim_index, (int)lhs.size, lhs.data,
- (int)value.size, value.data);
+ return iree_make_status(
+ IREE_STATUS_INVALID_ARGUMENT,
+ "shape[%" PRIhsz "] invalid value '%.*s' of '%.*s'", dim_index,
+ (int)lhs.size, lhs.data, (int)value.size, value.data);
}
dim_value = parsed_value;
} else {
int64_t parsed_value = 0;
if (!iree_string_view_atoi_int64(lhs, &parsed_value) ||
parsed_value < 0) {
- return iree_make_status(IREE_STATUS_INVALID_ARGUMENT,
- "shape[%zu] invalid value '%.*s' of '%.*s'",
- dim_index, (int)lhs.size, lhs.data,
- (int)value.size, value.data);
+ return iree_make_status(
+ IREE_STATUS_INVALID_ARGUMENT,
+ "shape[%" PRIhsz "] invalid value '%.*s' of '%.*s'", dim_index,
+ (int)lhs.size, lhs.data, (int)value.size, value.data);
}
dim_value = parsed_value;
}
@@ -93,7 +93,7 @@
(i < shape_rank - 1) ? "%" PRIdim "x" : "%" PRIdim, shape[i]);
if (IREE_UNLIKELY(n < 0)) {
return iree_make_status(IREE_STATUS_FAILED_PRECONDITION,
- "snprintf failed to write dimension %zu", i);
+ "snprintf failed to write dimension %" PRIhsz, i);
} else if (buffer && n >= buffer_capacity - buffer_length) {
buffer = NULL;
}
@@ -389,7 +389,7 @@
if (data_str.size != element_size * 2) {
return iree_make_status(IREE_STATUS_INVALID_ARGUMENT,
"binary hex element count mismatch: buffer "
- "length=%zu < expected=%zu",
+ "length=%" PRIhsz " < expected=%" PRIhsz,
data_str.size, element_size * 2);
}
iree_hal_hex_string_to_bytes(data_str.data, out_data, element_size);
@@ -404,10 +404,10 @@
iree_host_size_t element_size =
iree_hal_element_dense_byte_count(element_type);
if (data_ptr.data_length < element_size) {
- return iree_make_status(
- IREE_STATUS_INVALID_ARGUMENT,
- "output data buffer overflow: data_length=%zu < element_size=%zu",
- data_ptr.data_length, element_size);
+ return iree_make_status(IREE_STATUS_INVALID_ARGUMENT,
+ "output data buffer overflow: data_length=%" PRIhsz
+ " < element_size=%" PRIhsz,
+ data_ptr.data_length, element_size);
}
return iree_hal_parse_element_unsafe(data_str, element_type, data_ptr.data);
}
@@ -446,10 +446,10 @@
iree_host_size_t element_size =
iree_hal_element_dense_byte_count(element_type);
if (data.data_length < element_size) {
- return iree_make_status(
- IREE_STATUS_OUT_OF_RANGE,
- "data buffer underflow: data_length=%zu < element_size=%zu",
- data.data_length, element_size);
+ return iree_make_status(IREE_STATUS_OUT_OF_RANGE,
+ "data buffer underflow: data_length=%" PRIhsz
+ " < element_size=%" PRIhsz,
+ data.data_length, element_size);
}
int n = 0;
switch (element_type) {
@@ -532,9 +532,9 @@
memset(data_ptr.data, 0, data_ptr.data_length);
return iree_ok_status();
}
- size_t src_i = 0;
- size_t dst_i = 0;
- size_t token_start = IREE_STRING_VIEW_NPOS;
+ iree_host_size_t src_i = 0;
+ iree_host_size_t dst_i = 0;
+ iree_host_size_t token_start = IREE_STRING_VIEW_NPOS;
while (src_i < data_str.size) {
char c = data_str.data[src_i++];
bool is_separator = isspace(c) || c == ',' || c == '[' || c == ']';
@@ -549,7 +549,8 @@
if (dst_i >= element_capacity) {
return iree_make_status(
IREE_STATUS_OUT_OF_RANGE,
- "output data buffer overflow: element_capacity=%zu < dst_i=%zu+",
+ "output data buffer overflow: element_capacity=%" PRIhsz
+ " < dst_i=%" PRIhsz "+",
element_capacity, dst_i);
}
IREE_RETURN_IF_ERROR(iree_hal_parse_element_unsafe(
@@ -561,10 +562,10 @@
}
if (token_start != IREE_STRING_VIEW_NPOS) {
if (dst_i >= element_capacity) {
- return iree_make_status(
- IREE_STATUS_OUT_OF_RANGE,
- "output data overflow: element_capacity=%zu < dst_i=%zu",
- element_capacity, dst_i);
+ return iree_make_status(IREE_STATUS_OUT_OF_RANGE,
+ "output data overflow: element_capacity=%" PRIhsz
+ " < dst_i=%" PRIhsz,
+ element_capacity, dst_i);
}
IREE_RETURN_IF_ERROR(iree_hal_parse_element_unsafe(
iree_make_string_view(data_str.data + token_start,
@@ -579,10 +580,10 @@
memcpy(p, data_ptr.data, element_size);
}
} else if (dst_i < element_capacity) {
- return iree_make_status(
- IREE_STATUS_OUT_OF_RANGE,
- "input data string underflow: dst_i=%zu < element_capacity=%zu", dst_i,
- element_capacity);
+ return iree_make_status(IREE_STATUS_OUT_OF_RANGE,
+ "input data string underflow: dst_i=%" PRIhsz
+ " < element_capacity=%" PRIhsz,
+ dst_i, element_capacity);
}
return iree_ok_status();
}
@@ -623,7 +624,7 @@
if (data.data_length < dim_stride * shape[0]) {
return iree_make_status(
IREE_STATUS_OUT_OF_RANGE,
- "input data underflow: data_length=%zu < expected=%zu",
+ "input data underflow: data_length=%" PRIhsz " < expected=%" PRIhsz,
data.data_length, (iree_host_size_t)(dim_stride * shape[0]));
}
iree_const_byte_span_t subdata;
@@ -654,7 +655,7 @@
if (data.data_length < max_count * element_stride) {
return iree_make_status(
IREE_STATUS_OUT_OF_RANGE,
- "input data underflow; data_length=%zu < expected=%zu",
+ "input data underflow; data_length=%" PRIhsz " < expected=%" PRIhsz,
data.data_length, (iree_host_size_t)(max_count * element_stride));
}
*max_element_count -= max_count;
diff --git a/runtime/src/iree/hal/string_util_test.cc b/runtime/src/iree/hal/string_util_test.cc
index 53e7e00..88d4458 100644
--- a/runtime/src/iree/hal/string_util_test.cc
+++ b/runtime/src/iree/hal/string_util_test.cc
@@ -36,9 +36,9 @@
iree_host_size_t actual_rank = 0;
iree_status_t status = iree_ok_status();
do {
- status =
- iree_hal_parse_shape(iree_string_view_t{value.data(), value.size()},
- shape.size(), &actual_rank, shape.data());
+ status = iree_hal_parse_shape(
+ iree_string_view_t{value.data(), (iree_host_size_t)value.size()},
+ shape.size(), &actual_rank, shape.data());
shape.resize(actual_rank);
} while (iree_status_is_out_of_range(status));
IREE_RETURN_IF_ERROR(std::move(status));
@@ -65,7 +65,8 @@
StatusOr<iree_hal_element_type_t> ParseElementType(const std::string& value) {
iree_hal_element_type_t element_type = IREE_HAL_ELEMENT_TYPE_NONE;
iree_status_t status = iree_hal_parse_element_type(
- iree_string_view_t{value.data(), value.size()}, &element_type);
+ iree_string_view_t{value.data(), (iree_host_size_t)value.size()},
+ &element_type);
IREE_RETURN_IF_ERROR(status, "Failed to parse element type '%.*s'",
(int)value.size(), value.data());
return element_type;
@@ -106,8 +107,8 @@
iree_status_t status = iree_ok_status();
do {
status = iree_hal_parse_shape_and_element_type(
- iree_string_view_t{value.data(), value.size()}, shape.size(),
- &actual_rank, shape.data(), &element_type);
+ iree_string_view_t{value.data(), (iree_host_size_t)value.size()},
+ shape.size(), &actual_rank, shape.data(), &element_type);
shape.resize(actual_rank);
} while (iree_status_is_out_of_range(status));
IREE_RETURN_IF_ERROR(std::move(status));
@@ -123,9 +124,11 @@
iree_hal_element_type_t element_type,
iree::span<T> buffer) {
return iree_hal_parse_element(
- iree_string_view_t{value.data(), value.size()}, element_type,
- iree_byte_span_t{reinterpret_cast<uint8_t*>(buffer.data()),
- buffer.size() * sizeof(T)});
+ iree_string_view_t{value.data(), (iree_host_size_t)value.size()},
+ element_type,
+ iree_byte_span_t{
+ reinterpret_cast<uint8_t*>(buffer.data()),
+ static_cast<iree_host_size_t>(buffer.size() * sizeof(T))});
}
// Converts a single element of |element_type| to a string.
@@ -157,9 +160,11 @@
iree::span<T> buffer) {
IREE_RETURN_IF_ERROR(
iree_hal_parse_buffer_elements(
- iree_string_view_t{value.data(), value.size()}, element_type,
- iree_byte_span_t{reinterpret_cast<uint8_t*>(buffer.data()),
- buffer.size() * sizeof(T)}),
+ iree_string_view_t{value.data(), (iree_host_size_t)value.size()},
+ element_type,
+ iree_byte_span_t{
+ reinterpret_cast<uint8_t*>(buffer.data()),
+ static_cast<iree_host_size_t>(buffer.size() * sizeof(T))}),
"failed to parse buffer elements '%.*s'",
iree_min(256, (int)value.size()), value.data());
return OkStatus();
@@ -182,7 +187,7 @@
iree_host_size_t actual_length = 0;
status = iree_hal_format_buffer_elements(
iree_const_byte_span_t{reinterpret_cast<const uint8_t*>(data.data()),
- data.size() * sizeof(T)},
+ (iree_host_size_t)(data.size() * sizeof(T))},
shape.size(), shape.data(), element_type, max_element_count,
result.size() + 1, &result[0], &actual_length);
result.resize(actual_length);
@@ -513,8 +518,8 @@
Allocator allocator) {
BufferView buffer_view;
iree_status_t status = iree_hal_buffer_view_parse(
- iree_string_view_t{value.data(), value.size()}, allocator,
- &buffer_view);
+ iree_string_view_t{value.data(), (iree_host_size_t)value.size()},
+ allocator, &buffer_view);
IREE_RETURN_IF_ERROR(std::move(status));
return std::move(buffer_view);
}
diff --git a/runtime/src/iree/modules/hal/utils/buffer_diagnostics.c b/runtime/src/iree/modules/hal/utils/buffer_diagnostics.c
index 427df99..cd28525 100644
--- a/runtime/src/iree/modules/hal/utils/buffer_diagnostics.c
+++ b/runtime/src/iree/modules/hal/utils/buffer_diagnostics.c
@@ -271,8 +271,8 @@
// Query total length (excluding NUL terminator).
iree_host_size_t result_length = 0;
- iree_status_t status = iree_hal_buffer_view_format(buffer_view, SIZE_MAX, 0,
- NULL, &result_length);
+ iree_status_t status = iree_hal_buffer_view_format(
+ buffer_view, IREE_HOST_SIZE_MAX, 0, NULL, &result_length);
if (!iree_status_is_out_of_range(status)) {
return status;
}
@@ -282,8 +282,9 @@
char* result_str = NULL;
IREE_RETURN_IF_ERROR(iree_allocator_malloc(host_allocator, result_length,
(void**)&result_str));
- status = iree_hal_buffer_view_format(buffer_view, SIZE_MAX, result_length,
- result_str, &result_length);
+ status =
+ iree_hal_buffer_view_format(buffer_view, IREE_HOST_SIZE_MAX,
+ result_length, result_str, &result_length);
if (iree_status_is_ok(status)) {
fprintf(stderr, "%.*s\n", (int)result_length, result_str);
}
diff --git a/runtime/src/iree/task/executor.c b/runtime/src/iree/task/executor.c
index b47af2e..5c7f989 100644
--- a/runtime/src/iree/task/executor.c
+++ b/runtime/src/iree/task/executor.c
@@ -35,10 +35,10 @@
iree_task_executor_t** out_executor) {
iree_host_size_t worker_count = iree_task_topology_group_count(topology);
if (worker_count > IREE_TASK_EXECUTOR_MAX_WORKER_COUNT) {
- return iree_make_status(
- IREE_STATUS_RESOURCE_EXHAUSTED,
- "requested %zu workers but a maximum of %d is allowed", worker_count,
- IREE_TASK_EXECUTOR_MAX_WORKER_COUNT);
+ return iree_make_status(IREE_STATUS_RESOURCE_EXHAUSTED,
+ "requested %" PRIhsz
+ " workers but a maximum of %d is allowed",
+ worker_count, IREE_TASK_EXECUTOR_MAX_WORKER_COUNT);
}
// TODO(benvanik): support a threadless mode where we have one dummy worker
diff --git a/runtime/src/iree/task/task.c b/runtime/src/iree/task/task.c
index 1707640..6af1157 100644
--- a/runtime/src/iree/task/task.c
+++ b/runtime/src/iree/task/task.c
@@ -729,7 +729,7 @@
&dispatch_task->status,
iree_make_status(IREE_STATUS_RESOURCE_EXHAUSTED,
"dispatch requires %ub of local memory but only "
- "%zub is available per-worker",
+ "%" PRIhsz "b is available per-worker",
dispatch_task->local_memory_size,
worker_local_memory.data_length));
iree_task_retire(&task->header, pending_submission, iree_ok_status());
diff --git a/runtime/src/iree/tooling/comparison.cc b/runtime/src/iree/tooling/comparison.cc
index 75a15fd..65aab55 100644
--- a/runtime/src/iree/tooling/comparison.cc
+++ b/runtime/src/iree/tooling/comparison.cc
@@ -234,7 +234,9 @@
if (iree_vm_list_size(expected_list) != iree_vm_list_size(actual_list)) {
IREE_CHECK_OK(iree_string_builder_append_format(
- builder, "[FAILED] expected %zu list elements but %zu provided\n",
+ builder,
+ "[FAILED] expected %" PRIhsz " list elements but %" PRIhsz
+ " provided\n",
iree_vm_list_size(expected_list), iree_vm_list_size(actual_list)));
return false;
}
diff --git a/runtime/src/iree/tooling/context_util.c b/runtime/src/iree/tooling/context_util.c
index 25b2b43..77c1c2f 100644
--- a/runtime/src/iree/tooling/context_util.c
+++ b/runtime/src/iree/tooling/context_util.c
@@ -107,8 +107,9 @@
iree_host_size_t new_count = list->count + FLAG_module_list().count;
if (new_count > list->capacity) {
return iree_make_status(IREE_STATUS_RESOURCE_EXHAUSTED,
- "too many modules; currently only %zu are "
- "supported but at least %zu are requested",
+ "too many modules; currently only %" PRIhsz
+ " are supported but at least %" PRIhsz
+ " are requested",
list->capacity, new_count);
}
IREE_TRACE_ZONE_BEGIN(z0);
@@ -495,7 +496,7 @@
IREE_RETURN_IF_ERROR(
iree_vm_module_lookup_function_by_ordinal(
module, IREE_VM_FUNCTION_LINKAGE_EXPORT, i, &function),
- "looking up function export %zu", i);
+ "looking up function export %" PRIhsz, i);
iree_string_view_t function_name = iree_vm_function_name(&function);
if (iree_string_view_starts_with(function_name,
iree_make_cstring_view("__")) ||
diff --git a/runtime/src/iree/tooling/numpy_io.c b/runtime/src/iree/tooling/numpy_io.c
index 18b4be7..335b2af 100644
--- a/runtime/src/iree/tooling/numpy_io.c
+++ b/runtime/src/iree/tooling/numpy_io.c
@@ -140,8 +140,7 @@
iree_string_view_t* dict, iree_string_view_t* out_key,
iree_string_view_t* out_value) {
// Split `'key':` from the remainder of the string.
- if (iree_string_view_split(*dict, ':', out_key, dict) ==
- IREE_STRING_VIEW_NPOS) {
+ if (iree_string_view_split(*dict, ':', out_key, dict) == -1) {
return iree_make_status(IREE_STATUS_INVALID_ARGUMENT,
"malformed header dict");
}
diff --git a/runtime/src/iree/tooling/trace_replay.c b/runtime/src/iree/tooling/trace_replay.c
index 98b55e0..8e96e82 100644
--- a/runtime/src/iree/tooling/trace_replay.c
+++ b/runtime/src/iree/tooling/trace_replay.c
@@ -756,7 +756,7 @@
}
if (shape_rank >= shape_capacity) {
return iree_make_status(IREE_STATUS_OUT_OF_RANGE,
- "(%zu): shape rank overflow (>%zu)",
+ "(%zu): shape rank overflow (>%" PRIhsz ")",
shape_node->start_mark.line, shape_capacity);
}
shape[shape_rank++] = (iree_hal_dim_t)dim;
diff --git a/runtime/src/iree/tooling/vm_util.c b/runtime/src/iree/tooling/vm_util.c
index fec51a6..f9c2a08 100644
--- a/runtime/src/iree/tooling/vm_util.c
+++ b/runtime/src/iree/tooling/vm_util.c
@@ -76,7 +76,8 @@
mapping->contents.data_length, read_params->file);
if (bytes_read != mapping->contents.data_length) {
return iree_make_status(IREE_STATUS_OUT_OF_RANGE,
- "file contents truncated; expected %zu bytes "
+ "file contents truncated; expected %" PRIhsz
+ " bytes "
"based on buffer view size",
mapping->contents.data_length);
}
@@ -102,9 +103,10 @@
!iree_status_is_out_of_range(shape_result)) {
return shape_result;
} else if (shape_rank > 128) {
- return iree_make_status(
- IREE_STATUS_RESOURCE_EXHAUSTED,
- "a shape rank of %zu is just a little bit excessive, eh?", shape_rank);
+ return iree_make_status(IREE_STATUS_RESOURCE_EXHAUSTED,
+ "a shape rank of %" PRIhsz
+ " is just a little bit excessive, eh?",
+ shape_rank);
}
iree_status_ignore(shape_result);
iree_hal_dim_t* shape =
@@ -403,7 +405,7 @@
iree_vm_variant_t variant = iree_vm_variant_empty();
IREE_RETURN_AND_END_ZONE_IF_ERROR(
z0, iree_vm_list_get_variant_assign(list, i, &variant),
- "variant %zu not present", i);
+ "variant %" PRIhsz " not present", i);
iree_string_builder_append_format(
builder, "%.*s[%" PRIhsz "]: ", (int)list_name.size, list_name.data, i);
IREE_RETURN_AND_END_ZONE_IF_ERROR(
diff --git a/runtime/src/iree/vm/buffer.c b/runtime/src/iree/vm/buffer.c
index e1f0559..f5c6dc9 100644
--- a/runtime/src/iree/vm/buffer.c
+++ b/runtime/src/iree/vm/buffer.c
@@ -24,11 +24,12 @@
length &= ~(alignment - 1);
const iree_host_size_t end = offset + length;
if (IREE_UNLIKELY(end > buffer->data.data_length)) {
- return iree_make_status(IREE_STATUS_OUT_OF_RANGE,
- "out-of-bounds access detected (offset=%zu, "
- "length=%zu, alignment=%zu, buffer length=%zu)",
- offset, length, alignment,
- buffer->data.data_length);
+ return iree_make_status(
+ IREE_STATUS_OUT_OF_RANGE,
+ "out-of-bounds access detected (offset=%" PRIhsz
+ ", "
+ "length=%" PRIhsz ", alignment=%" PRIhsz ", buffer length=%" PRIhsz ")",
+ offset, length, alignment, buffer->data.data_length);
}
*out_data = buffer->data.data + offset;
*out_data_length = length;
diff --git a/runtime/src/iree/vm/buffer.h b/runtime/src/iree/vm/buffer.h
index b065467..cdbb580 100644
--- a/runtime/src/iree/vm/buffer.h
+++ b/runtime/src/iree/vm/buffer.h
@@ -207,21 +207,22 @@
// const float* IREE_RESTRICT buffer_ptr = NULL;
// iree_vm_buffer_check_ro(buffer, offset, 4, float, buffer_ptr);
// process(buffer_ptr[0], buffer_ptr[1], buffer_ptr[2], buffer_ptr[3]);
-#define iree_vm_buffer_check_ro(buffer, element_offset, element_length, \
- element_type, out_buffer_ptr) \
- { \
- const iree_host_size_t end = \
- ((element_offset) + (element_length)) * sizeof(element_type); \
- if (IREE_UNLIKELY(end > buffer->data.data_length)) { \
- return iree_make_status(IREE_STATUS_OUT_OF_RANGE, \
- "out-of-bounds access detected (offset=%zu, " \
- "length=%zu, alignment=%zu, buffer length=%zu)", \
- (element_offset) * sizeof(element_type), \
- (element_length) * sizeof(element_type), \
- sizeof(element_type), buffer->data.data_length); \
- } \
- out_buffer_ptr = \
- (const element_type*)buffer->data.data + (element_offset); \
+#define iree_vm_buffer_check_ro(buffer, element_offset, element_length, \
+ element_type, out_buffer_ptr) \
+ { \
+ const iree_host_size_t end = \
+ ((element_offset) + (element_length)) * sizeof(element_type); \
+ if (IREE_UNLIKELY(end > buffer->data.data_length)) { \
+ return iree_make_status( \
+ IREE_STATUS_OUT_OF_RANGE, \
+ "out-of-bounds access detected (offset=%zu, length=%zu, " \
+ "alignment=%zu, buffer length=%" PRIhsz ")", \
+ (element_offset) * sizeof(element_type), \
+ (element_length) * sizeof(element_type), sizeof(element_type), \
+ buffer->data.data_length); \
+ } \
+ out_buffer_ptr = \
+ (const element_type*)buffer->data.data + (element_offset); \
}
// Low-level helper for accessing a typed view of a buffer for write access.
@@ -232,26 +233,27 @@
// float* IREE_RESTRICT buffer_ptr = NULL;
// iree_vm_buffer_check_rw(buffer, offset, 1, float, buffer_ptr);
// buffer_ptr[0] = 1.0f;
-#define iree_vm_buffer_check_rw(buffer, element_offset, element_length, \
- element_type, out_buffer_ptr) \
- { \
- if (IREE_UNLIKELY(!iree_all_bits_set(buffer->access, \
- IREE_VM_BUFFER_ACCESS_MUTABLE))) { \
- return iree_make_status( \
- IREE_STATUS_PERMISSION_DENIED, \
- "buffer is read-only and cannot be mapped for mutation"); \
- } \
- const iree_host_size_t end = \
- ((element_offset) + (element_length)) * sizeof(element_type); \
- if (IREE_UNLIKELY(end > buffer->data.data_length)) { \
- return iree_make_status(IREE_STATUS_OUT_OF_RANGE, \
- "out-of-bounds access detected (offset=%zu, " \
- "length=%zu, alignment=%zu, buffer length=%zu)", \
- (element_offset) * sizeof(element_type), \
- (element_length) * sizeof(element_type), \
- sizeof(element_type), buffer->data.data_length); \
- } \
- out_buffer_ptr = (element_type*)buffer->data.data + (element_offset); \
+#define iree_vm_buffer_check_rw(buffer, element_offset, element_length, \
+ element_type, out_buffer_ptr) \
+ { \
+ if (IREE_UNLIKELY(!iree_all_bits_set(buffer->access, \
+ IREE_VM_BUFFER_ACCESS_MUTABLE))) { \
+ return iree_make_status( \
+ IREE_STATUS_PERMISSION_DENIED, \
+ "buffer is read-only and cannot be mapped for mutation"); \
+ } \
+ const iree_host_size_t end = \
+ ((element_offset) + (element_length)) * sizeof(element_type); \
+ if (IREE_UNLIKELY(end > buffer->data.data_length)) { \
+ return iree_make_status( \
+ IREE_STATUS_OUT_OF_RANGE, \
+ "out-of-bounds access detected (offset=%zu, length=%zu, " \
+ "alignment=%zu, buffer length=%" PRIhsz ")", \
+ (element_offset) * sizeof(element_type), \
+ (element_length) * sizeof(element_type), sizeof(element_type), \
+ buffer->data.data_length); \
+ } \
+ out_buffer_ptr = (element_type*)buffer->data.data + (element_offset); \
}
// Returns the a string view referencing the given |value| buffer.
diff --git a/runtime/src/iree/vm/bytecode/archive.c b/runtime/src/iree/vm/bytecode/archive.c
index 6ee7cdc..1348e2d 100644
--- a/runtime/src/iree/vm/bytecode/archive.c
+++ b/runtime/src/iree/vm/bytecode/archive.c
@@ -101,7 +101,8 @@
if (!module_contents.data || module_contents.data_length < 16) {
return iree_make_status(
IREE_STATUS_INVALID_ARGUMENT,
- "FlatBuffer data is not present or less than 16 bytes (%zu total)",
+ "FlatBuffer data is not present or less than 16 bytes (%" PRIhsz
+ " total)",
module_contents.data_length);
}
diff --git a/runtime/src/iree/vm/bytecode/dispatch.c b/runtime/src/iree/vm/bytecode/dispatch.c
index a15aea2..81b773b 100644
--- a/runtime/src/iree/vm/bytecode/dispatch.c
+++ b/runtime/src/iree/vm/bytecode/dispatch.c
@@ -710,8 +710,8 @@
module_state->rwdata_storage.data_length)) {
return iree_make_status(
IREE_STATUS_OUT_OF_RANGE,
- "global byte_offset out of range: %d (rwdata=%zu)", byte_offset,
- module_state->rwdata_storage.data_length);
+ "global byte_offset out of range: %d (rwdata=%" PRIhsz ")",
+ byte_offset, module_state->rwdata_storage.data_length);
}
int32_t* value = VM_DecResultRegI32("value");
const int32_t global_value =
@@ -725,8 +725,8 @@
module_state->rwdata_storage.data_length)) {
return iree_make_status(
IREE_STATUS_OUT_OF_RANGE,
- "global byte_offset out of range: %d (rwdata=%zu)", byte_offset,
- module_state->rwdata_storage.data_length);
+ "global byte_offset out of range: %d (rwdata=%" PRIhsz ")",
+ byte_offset, module_state->rwdata_storage.data_length);
}
int32_t value = VM_DecOperandRegI32("value");
vm_global_store_i32(module_state->rwdata_storage.data, byte_offset,
@@ -756,8 +756,8 @@
module_state->rwdata_storage.data_length)) {
return iree_make_status(
IREE_STATUS_OUT_OF_RANGE,
- "global byte_offset out of range: %d (rwdata=%zu)", byte_offset,
- module_state->rwdata_storage.data_length);
+ "global byte_offset out of range: %d (rwdata=%" PRIhsz ")",
+ byte_offset, module_state->rwdata_storage.data_length);
}
int64_t* value = VM_DecResultRegI64("value");
const int64_t global_value =
@@ -771,8 +771,8 @@
module_state->rwdata_storage.data_length)) {
return iree_make_status(
IREE_STATUS_OUT_OF_RANGE,
- "global byte_offset out of range: %d (rwdata=%zu)", byte_offset,
- module_state->rwdata_storage.data_length);
+ "global byte_offset out of range: %d (rwdata=%" PRIhsz ")",
+ byte_offset, module_state->rwdata_storage.data_length);
}
int64_t value = VM_DecOperandRegI64("value");
vm_global_store_i64(module_state->rwdata_storage.data, byte_offset,
@@ -807,7 +807,7 @@
if (IREE_UNLIKELY(global >= module_state->global_ref_count)) {
return iree_make_status(
IREE_STATUS_OUT_OF_RANGE,
- "global ref ordinal out of range: %d (table=%zu)", global,
+ "global ref ordinal out of range: %d (table=%" PRIhsz ")", global,
module_state->global_ref_count);
}
const iree_vm_type_def_t type_def = VM_DecTypeOf("value");
@@ -824,7 +824,7 @@
if (IREE_UNLIKELY(global >= module_state->global_ref_count)) {
return iree_make_status(
IREE_STATUS_OUT_OF_RANGE,
- "global ref ordinal out of range: %d (table=%zu)", global,
+ "global ref ordinal out of range: %d (table=%" PRIhsz ")", global,
module_state->global_ref_count);
}
const iree_vm_type_def_t type_def = VM_DecTypeOf("value");
@@ -1852,8 +1852,8 @@
module_state->rwdata_storage.data_length)) {
return iree_make_status(
IREE_STATUS_OUT_OF_RANGE,
- "global byte_offset out of range: %d (rwdata=%zu)", byte_offset,
- module_state->rwdata_storage.data_length);
+ "global byte_offset out of range: %d (rwdata=%" PRIhsz ")",
+ byte_offset, module_state->rwdata_storage.data_length);
}
float* value = VM_DecResultRegF32("value");
const float global_value =
@@ -1867,8 +1867,8 @@
module_state->rwdata_storage.data_length)) {
return iree_make_status(
IREE_STATUS_OUT_OF_RANGE,
- "global byte_offset out of range: %d (rwdata=%zu)", byte_offset,
- module_state->rwdata_storage.data_length);
+ "global byte_offset out of range: %d (rwdata=%" PRIhsz ")",
+ byte_offset, module_state->rwdata_storage.data_length);
}
float value = VM_DecOperandRegF32("value");
vm_global_store_f32(module_state->rwdata_storage.data, byte_offset,
diff --git a/runtime/src/iree/vm/bytecode/dispatch_async_test.cc b/runtime/src/iree/vm/bytecode/dispatch_async_test.cc
index f2e2ccf..bdf4525 100644
--- a/runtime/src/iree/vm/bytecode/dispatch_async_test.cc
+++ b/runtime/src/iree/vm/bytecode/dispatch_async_test.cc
@@ -36,7 +36,7 @@
IREE_CHECK_OK(iree_vm_bytecode_module_create(
instance_,
iree_const_byte_span_t{reinterpret_cast<const uint8_t*>(file->data),
- file->size},
+ static_cast<iree_host_size_t>(file->size)},
iree_allocator_null(), iree_allocator_system(), &bytecode_module_));
std::vector<iree_vm_module_t*> modules = {bytecode_module_};
diff --git a/runtime/src/iree/vm/bytecode/dispatch_test.cc b/runtime/src/iree/vm/bytecode/dispatch_test.cc
index cdab0e5..88d57a6 100644
--- a/runtime/src/iree/vm/bytecode/dispatch_test.cc
+++ b/runtime/src/iree/vm/bytecode/dispatch_test.cc
@@ -49,7 +49,7 @@
instance,
iree_const_byte_span_t{
reinterpret_cast<const uint8_t*>(module_file.data),
- module_file.size},
+ static_cast<iree_host_size_t>(module_file.size)},
iree_allocator_null(), iree_allocator_system(), &module));
iree_vm_module_signature_t signature = iree_vm_module_signature(module);
test_params.reserve(test_params.size() + signature.export_function_count);
@@ -83,7 +83,7 @@
instance_,
iree_const_byte_span_t{
reinterpret_cast<const uint8_t*>(test_params.module_file.data),
- test_params.module_file.size},
+ static_cast<iree_host_size_t>(test_params.module_file.size)},
iree_allocator_null(), iree_allocator_system(), &bytecode_module_));
std::vector<iree_vm_module_t*> modules = {bytecode_module_};
diff --git a/runtime/src/iree/vm/bytecode/module.c b/runtime/src/iree/vm/bytecode/module.c
index 97694d7..251cf85 100644
--- a/runtime/src/iree/vm/bytecode/module.c
+++ b/runtime/src/iree/vm/bytecode/module.c
@@ -113,10 +113,10 @@
// Look up the internal ordinal index of this export in the function table.
iree_vm_ExportFunctionDef_vec_t exported_functions =
iree_vm_BytecodeModuleDef_exported_functions(module->def);
- IREE_ASSERT_LT(ordinal,
- iree_vm_ExportFunctionDef_vec_len(exported_functions),
- "export ordinal out of range (0 < %zu < %zu)", ordinal,
- iree_vm_ExportFunctionDef_vec_len(exported_functions));
+ IREE_ASSERT_LT(
+ ordinal, iree_vm_ExportFunctionDef_vec_len(exported_functions),
+ "export ordinal out of range (0 < %" PRIhsz " < %" PRIhsz ")", ordinal,
+ iree_vm_ExportFunctionDef_vec_len(exported_functions));
iree_vm_ExportFunctionDef_table_t function_def =
iree_vm_ExportFunctionDef_vec_at(exported_functions, function.ordinal);
ordinal = iree_vm_ExportFunctionDef_internal_ordinal(function_def);
@@ -131,10 +131,10 @@
}
if (ordinal >= module->function_descriptor_count) {
- return iree_make_status(IREE_STATUS_INVALID_ARGUMENT,
- "function ordinal out of range (0 < %u < %zu)",
- function.ordinal,
- module->function_descriptor_count);
+ return iree_make_status(
+ IREE_STATUS_INVALID_ARGUMENT,
+ "function ordinal out of range (0 < %u < %" PRIhsz ")",
+ function.ordinal, module->function_descriptor_count);
}
*out_ordinal = ordinal;
@@ -331,7 +331,7 @@
if (ordinal >= iree_vm_ImportFunctionDef_vec_len(imported_functions)) {
return iree_make_status(
IREE_STATUS_INVALID_ARGUMENT,
- "import ordinal out of range (0 < %zu < %zu)", ordinal,
+ "import ordinal out of range (0 < %" PRIhsz " < %zu)", ordinal,
iree_vm_ImportFunctionDef_vec_len(imported_functions));
}
iree_vm_ImportFunctionDef_table_t import_def =
@@ -348,7 +348,7 @@
if (ordinal >= iree_vm_ExportFunctionDef_vec_len(exported_functions)) {
return iree_make_status(
IREE_STATUS_INVALID_ARGUMENT,
- "export ordinal out of range (0 < %zu < %zu)", ordinal,
+ "export ordinal out of range (0 < %" PRIhsz " < %zu)", ordinal,
iree_vm_ExportFunctionDef_vec_len(exported_functions));
}
iree_vm_ExportFunctionDef_table_t export_def =
@@ -414,9 +414,10 @@
function_signatures,
iree_vm_ExportFunctionDef_internal_ordinal(function_def));
if (!signature_def) {
- return iree_make_status(
- IREE_STATUS_NOT_FOUND,
- "reflection attribute at index %zu not found; no signature", index);
+ return iree_make_status(IREE_STATUS_NOT_FOUND,
+ "reflection attribute at index %" PRIhsz
+ " not found; no signature",
+ index);
}
iree_vm_AttrDef_vec_t attrs =
iree_vm_FunctionSignatureDef_attrs(signature_def);
@@ -693,7 +694,8 @@
(iree_vm_bytecode_module_state_t*)module_state;
if (ordinal >= state->import_count) {
return iree_make_status(IREE_STATUS_INVALID_ARGUMENT,
- "import ordinal out of range (0 < %zu < %zu)",
+ "import ordinal out of range (0 < %" PRIhsz
+ " < %" PRIhsz ")",
ordinal, state->import_count);
}
@@ -719,7 +721,7 @@
import->results, /*segment_size_list=*/NULL, &result_buffer_size));
if (argument_buffer_size > 16 * 1024 || result_buffer_size > 16 * 1024) {
return iree_make_status(IREE_STATUS_INVALID_ARGUMENT,
- "ABI marshaling buffer overflow on import %zu",
+ "ABI marshaling buffer overflow on import %" PRIhsz,
ordinal);
}
import->argument_buffer_size = (uint16_t)argument_buffer_size;
diff --git a/runtime/src/iree/vm/bytecode/module_benchmark.cc b/runtime/src/iree/vm/bytecode/module_benchmark.cc
index 6d6805e..9e718be 100644
--- a/runtime/src/iree/vm/bytecode/module_benchmark.cc
+++ b/runtime/src/iree/vm/bytecode/module_benchmark.cc
@@ -90,7 +90,7 @@
instance,
iree_const_byte_span_t{
reinterpret_cast<const uint8_t*>(module_file_toc->data),
- module_file_toc->size},
+ static_cast<iree_host_size_t>(module_file_toc->size)},
iree_allocator_null(), iree_allocator_system(), &bytecode_module));
std::array<iree_vm_module_t*, 2> modules = {import_module, bytecode_module};
@@ -146,7 +146,7 @@
instance,
iree_const_byte_span_t{
reinterpret_cast<const uint8_t*>(module_file_toc->data),
- module_file_toc->size},
+ static_cast<iree_host_size_t>(module_file_toc->size)},
iree_allocator_null(), iree_allocator_system(), &module));
// Just testing creation and verification here!
@@ -171,7 +171,7 @@
instance,
iree_const_byte_span_t{
reinterpret_cast<const uint8_t*>(module_file_toc->data),
- module_file_toc->size},
+ static_cast<iree_host_size_t>(module_file_toc->size)},
iree_allocator_null(), iree_allocator_system(), &module));
while (state.KeepRunning()) {
@@ -203,7 +203,7 @@
instance,
iree_const_byte_span_t{
reinterpret_cast<const uint8_t*>(module_file_toc->data),
- module_file_toc->size},
+ static_cast<iree_host_size_t>(module_file_toc->size)},
iree_allocator_null(), iree_allocator_system(), &module));
iree_vm_module_state_t* module_state;
diff --git a/runtime/src/iree/vm/bytecode/module_size_benchmark.cc b/runtime/src/iree/vm/bytecode/module_size_benchmark.cc
index 7449173..9a8d8e9 100644
--- a/runtime/src/iree/vm/bytecode/module_size_benchmark.cc
+++ b/runtime/src/iree/vm/bytecode/module_size_benchmark.cc
@@ -21,7 +21,7 @@
instance,
iree_const_byte_span_t{
reinterpret_cast<const uint8_t*>(module_file_toc->data),
- module_file_toc->size},
+ static_cast<iree_host_size_t>(module_file_toc->size)},
iree_allocator_null(), iree_allocator_system(), &module);
iree_vm_context_t* context = nullptr;
diff --git a/runtime/src/iree/vm/bytecode/module_test.cc b/runtime/src/iree/vm/bytecode/module_test.cc
index f0af597..4381de3 100644
--- a/runtime/src/iree/vm/bytecode/module_test.cc
+++ b/runtime/src/iree/vm/bytecode/module_test.cc
@@ -118,7 +118,7 @@
instance_,
iree_const_byte_span_t{
reinterpret_cast<const uint8_t*>(module_file_toc->data),
- module_file_toc->size},
+ static_cast<iree_host_size_t>(module_file_toc->size)},
iree_allocator_null(), iree_allocator_system(), &bytecode_module_));
std::vector<iree_vm_module_t*> modules = {bytecode_module_};
diff --git a/runtime/src/iree/vm/bytecode/verifier.c b/runtime/src/iree/vm/bytecode/verifier.c
index f14a1f5..2b6055d 100644
--- a/runtime/src/iree/vm/bytecode/verifier.c
+++ b/runtime/src/iree/vm/bytecode/verifier.c
@@ -158,8 +158,8 @@
iree_vm_FunctionDescriptor_vec_len(function_descriptors)) {
return iree_make_status(
IREE_STATUS_INVALID_ARGUMENT,
- "exports[%zu] internal_ordinal out of bounds (0 < %zu < %zu)", i,
- internal_ordinal,
+ "exports[%zu] internal_ordinal out of bounds (0 < %" PRIhsz " < %zu)",
+ i, internal_ordinal,
iree_vm_FunctionDescriptor_vec_len(function_descriptors));
}
}
@@ -205,7 +205,7 @@
flatbuffers_uint8_vec_len(bytecode_data)) {
return iree_make_status(IREE_STATUS_INVALID_ARGUMENT,
"functions[%zu] descriptor bytecode span out of "
- "range (0 < %d < %" PRIhsz ")",
+ "range (0 < %d < %zu)",
i, function_descriptor->bytecode_offset,
flatbuffers_uint8_vec_len(bytecode_data));
}
@@ -557,37 +557,40 @@
verify_state->function_descriptors)); \
}
#define VM_VerifyGlobalAttr(name) VM_VerifyConstI32(name)
-#define VM_VerifyRwdataOffset(name, access_length) \
- if (IREE_UNLIKELY(((name) + (access_length)) > \
- verify_state->rwdata_storage_size)) { \
- return iree_make_status( \
- IREE_STATUS_OUT_OF_RANGE, \
- "global byte_offset out of range: %d (rwdata=%zu)", (name), \
- verify_state->rwdata_storage_size); \
+#define VM_VerifyRwdataOffset(name, access_length) \
+ if (IREE_UNLIKELY(((name) + (access_length)) > \
+ verify_state->rwdata_storage_size)) { \
+ return iree_make_status( \
+ IREE_STATUS_OUT_OF_RANGE, \
+ "global byte_offset out of range: %d (rwdata=%" PRIhsz ")", (name), \
+ verify_state->rwdata_storage_size); \
}
-#define VM_VerifyGlobalRefOrdinal(name) \
- if (IREE_UNLIKELY((name) >= verify_state->global_ref_count)) { \
- return iree_make_status(IREE_STATUS_OUT_OF_RANGE, \
- "global ref ordinal out of range: %d (table=%zu)", \
- (name), verify_state->global_ref_count); \
+#define VM_VerifyGlobalRefOrdinal(name) \
+ if (IREE_UNLIKELY((name) >= verify_state->global_ref_count)) { \
+ return iree_make_status( \
+ IREE_STATUS_OUT_OF_RANGE, \
+ "global ref ordinal out of range: %d (table=%" PRIhsz ")", (name), \
+ verify_state->global_ref_count); \
}
#define VM_VerifyRodataAttr(name) VM_VerifyConstI32(name)
-#define VM_VerifyRodataOrdinal(name) \
- if (IREE_UNLIKELY((name) >= verify_state->rodata_ref_count)) { \
- return iree_make_status(IREE_STATUS_OUT_OF_RANGE, \
- "rodata ref ordinal out of range: %d (table=%zu)", \
- (name), verify_state->rodata_ref_count); \
+#define VM_VerifyRodataOrdinal(name) \
+ if (IREE_UNLIKELY((name) >= verify_state->rodata_ref_count)) { \
+ return iree_make_status( \
+ IREE_STATUS_OUT_OF_RANGE, \
+ "rodata ref ordinal out of range: %d (table=%" PRIhsz ")", (name), \
+ verify_state->rodata_ref_count); \
}
-#define VM_VerifyType(name) \
- IREE_VM_VERIFY_PC_RANGE(pc + 4, max_pc); \
- uint32_t name##_id = OP_I32(0); \
- if (IREE_UNLIKELY(name##_id >= module->type_count)) { \
- return iree_make_status(IREE_STATUS_OUT_OF_RANGE, \
- "type id ordinal out of range: %d (table=%zu)", \
- name##_id, module->type_count); \
- } \
- const iree_vm_type_def_t* name = &module->type_table[name##_id]; \
- (void)(name); \
+#define VM_VerifyType(name) \
+ IREE_VM_VERIFY_PC_RANGE(pc + 4, max_pc); \
+ uint32_t name##_id = OP_I32(0); \
+ if (IREE_UNLIKELY(name##_id >= module->type_count)) { \
+ return iree_make_status(IREE_STATUS_OUT_OF_RANGE, \
+ "type id ordinal out of range: %d (table=%" PRIhsz \
+ ")", \
+ name##_id, module->type_count); \
+ } \
+ const iree_vm_type_def_t* name = &module->type_table[name##_id]; \
+ (void)(name); \
pc += 4;
#define VM_VerifyTypeOf(name) VM_VerifyType(name)
#define VM_VerifyIntAttr32(name) VM_VerifyConstI32(name)
diff --git a/runtime/src/iree/vm/context.c b/runtime/src/iree/vm/context.c
index e4b11ce..34793d5 100644
--- a/runtime/src/iree/vm/context.c
+++ b/runtime/src/iree/vm/context.c
@@ -427,7 +427,7 @@
for (iree_host_size_t i = 0; i < module_count; ++i) {
if (!modules[i]) {
return iree_make_status(IREE_STATUS_INVALID_ARGUMENT,
- "modules[%zu] is null", i);
+ "modules[%" PRIhsz "] is null", i);
}
}
if (!module_count) return iree_ok_status();
diff --git a/runtime/src/iree/vm/invocation.c b/runtime/src/iree/vm/invocation.c
index b8ac05f..3b1eaea 100644
--- a/runtime/src/iree/vm/invocation.c
+++ b/runtime/src/iree/vm/invocation.c
@@ -88,10 +88,11 @@
}
return iree_ok_status();
} else if (IREE_UNLIKELY(expected_input_count != iree_vm_list_size(inputs))) {
- return iree_make_status(IREE_STATUS_INVALID_ARGUMENT,
- "input list and function mismatch; expected %zu "
- "arguments but passed %zu",
- expected_input_count, iree_vm_list_size(inputs));
+ return iree_make_status(
+ IREE_STATUS_INVALID_ARGUMENT,
+ "input list and function mismatch; expected %" PRIhsz
+ " arguments but passed %" PRIhsz,
+ expected_input_count, iree_vm_list_size(inputs));
}
uint8_t* p = arguments.data;
diff --git a/runtime/src/iree/vm/list.c b/runtime/src/iree/vm/list.c
index 8addf8e..8170557 100644
--- a/runtime/src/iree/vm/list.c
+++ b/runtime/src/iree/vm/list.c
@@ -162,10 +162,10 @@
iree_host_size_t required_storage_size =
storage_offset + iree_host_align(capacity * element_size, 8);
if (storage.data_length < required_storage_size) {
- return iree_make_status(
- IREE_STATUS_OUT_OF_RANGE,
- "storage buffer underflow: provided=%zu < required=%zu",
- storage.data_length, required_storage_size);
+ return iree_make_status(IREE_STATUS_OUT_OF_RANGE,
+ "storage buffer underflow: provided=%" PRIhsz
+ " < required=%" PRIhsz,
+ storage.data_length, required_storage_size);
}
memset(storage.data, 0, required_storage_size);
@@ -623,7 +623,8 @@
iree_vm_value_t* out_value) {
if (i >= list->count) {
return iree_make_status(IREE_STATUS_OUT_OF_RANGE,
- "index %zu out of bounds (%zu)", i, list->count);
+ "index %" PRIhsz " out of bounds (%" PRIhsz ")", i,
+ list->count);
}
uintptr_t element_ptr = (uintptr_t)list->storage + i * list->element_size;
memset(out_value, 0, sizeof(*out_value));
@@ -650,8 +651,9 @@
case IREE_VM_LIST_STORAGE_MODE_VARIANT: {
iree_vm_variant_t* variant = (iree_vm_variant_t*)element_ptr;
if (!iree_vm_type_def_is_value(variant->type)) {
- return iree_make_status(IREE_STATUS_FAILED_PRECONDITION,
- "variant at index %zu is not a value type", i);
+ return iree_make_status(
+ IREE_STATUS_FAILED_PRECONDITION,
+ "variant at index %" PRIhsz " is not a value type", i);
}
out_value->type = iree_vm_type_def_as_value(variant->type);
memcpy(out_value->value_storage, variant->value_storage,
@@ -669,7 +671,8 @@
iree_vm_value_type_t value_type, iree_vm_value_t* out_value) {
if (i >= list->count) {
return iree_make_status(IREE_STATUS_OUT_OF_RANGE,
- "index %zu out of bounds (%zu)", i, list->count);
+ "index %" PRIhsz " out of bounds (%" PRIhsz ")", i,
+ list->count);
}
uintptr_t element_ptr = (uintptr_t)list->storage + i * list->element_size;
iree_vm_value_t value;
@@ -697,8 +700,9 @@
case IREE_VM_LIST_STORAGE_MODE_VARIANT: {
iree_vm_variant_t* variant = (iree_vm_variant_t*)element_ptr;
if (!iree_vm_variant_is_value(*variant)) {
- return iree_make_status(IREE_STATUS_FAILED_PRECONDITION,
- "variant at index %zu is not a value type", i);
+ return iree_make_status(
+ IREE_STATUS_FAILED_PRECONDITION,
+ "variant at index %" PRIhsz " is not a value type", i);
}
value.type = iree_vm_type_def_as_value(variant->type);
memcpy(value.value_storage, variant->value_storage,
@@ -717,7 +721,8 @@
iree_vm_list_t* list, iree_host_size_t i, const iree_vm_value_t* value) {
if (i >= list->count) {
return iree_make_status(IREE_STATUS_OUT_OF_RANGE,
- "index %zu out of bounds (%zu)", i, list->count);
+ "index %" PRIhsz " out of bounds (%" PRIhsz ")", i,
+ list->count);
}
iree_vm_value_type_t target_type;
switch (list->storage_mode) {
@@ -802,7 +807,8 @@
iree_vm_ref_t* out_value) {
if (i >= list->count) {
return iree_make_status(IREE_STATUS_OUT_OF_RANGE,
- "index %zu out of bounds (%zu)", i, list->count);
+ "index %" PRIhsz " out of bounds (%" PRIhsz ")", i,
+ list->count);
}
uintptr_t element_ptr = (uintptr_t)list->storage + i * list->element_size;
switch (list->storage_mode) {
@@ -846,7 +852,8 @@
iree_vm_ref_t* value) {
if (i >= list->count) {
return iree_make_status(IREE_STATUS_OUT_OF_RANGE,
- "index %zu out of bounds (%zu)", i, list->count);
+ "index %" PRIhsz " out of bounds (%" PRIhsz ")", i,
+ list->count);
}
uintptr_t element_ptr = (uintptr_t)list->storage + i * list->element_size;
switch (list->storage_mode) {
@@ -944,7 +951,8 @@
IREE_ASSERT_ARGUMENT(out_variant);
if (i >= list->count) {
return iree_make_status(IREE_STATUS_OUT_OF_RANGE,
- "index %zu out of bounds (%zu)", i, list->count);
+ "index %" PRIhsz " out of bounds (%" PRIhsz ")", i,
+ list->count);
}
iree_vm_variant_reset(out_variant);
uintptr_t element_ptr = (uintptr_t)list->storage + i * list->element_size;
diff --git a/runtime/src/iree/vm/module.c b/runtime/src/iree/vm/module.c
index e2a6e29..088c495 100644
--- a/runtime/src/iree/vm/module.c
+++ b/runtime/src/iree/vm/module.c
@@ -29,7 +29,8 @@
return iree_make_status(IREE_STATUS_UNIMPLEMENTED,
"unsupported cconv version %c", cconv.data[0]);
}
- iree_string_view_t cconv_body = iree_string_view_substr(cconv, 1, INTPTR_MAX);
+ iree_string_view_t cconv_body =
+ iree_string_view_substr(cconv, 1, IREE_HOST_SIZE_MAX);
if (iree_string_view_split(cconv_body, '_', out_arguments, out_results) ==
-1) {
*out_arguments = cconv_body;
diff --git a/runtime/src/iree/vm/native_module.c b/runtime/src/iree/vm/native_module.c
index 09c38cb..282b368 100644
--- a/runtime/src/iree/vm/native_module.c
+++ b/runtime/src/iree/vm/native_module.c
@@ -57,12 +57,12 @@
iree_string_view_t export_name = module_descriptor->exports[i].local_name;
int cmp = iree_string_view_compare(prev_export_name, export_name);
if (IREE_UNLIKELY(cmp >= 0)) {
- return iree_make_status(IREE_STATUS_INVALID_ARGUMENT,
- "module export table is not sorted by name "
- "(export %zu ('%.*s') >= %zu ('%.*s'))",
- i - 1, (int)prev_export_name.size,
- prev_export_name.data, i, (int)export_name.size,
- export_name.data);
+ return iree_make_status(
+ IREE_STATUS_INVALID_ARGUMENT,
+ "module export table is not sorted by name "
+ "(export %" PRIhsz " ('%.*s') >= %" PRIhsz " ('%.*s'))",
+ i - 1, (int)prev_export_name.size, prev_export_name.data, i,
+ (int)export_name.size, export_name.data);
}
}
return iree_ok_status();
@@ -140,7 +140,8 @@
iree_vm_function_signature_t* out_signature) {
if (IREE_UNLIKELY(ordinal >= module->descriptor->import_count)) {
return iree_make_status(IREE_STATUS_INVALID_ARGUMENT,
- "import ordinal out of range (0 < %zu < %zu)",
+ "import ordinal out of range (0 < %" PRIhsz
+ " < %" PRIhsz ")",
ordinal, module->descriptor->import_count);
}
const iree_vm_native_import_descriptor_t* import_descriptor =
@@ -165,7 +166,8 @@
iree_vm_function_signature_t* out_signature) {
if (IREE_UNLIKELY(ordinal >= module->descriptor->export_count)) {
return iree_make_status(IREE_STATUS_INVALID_ARGUMENT,
- "export ordinal out of range (0 < %zu < %zu)",
+ "export ordinal out of range (0 < %" PRIhsz
+ " < %" PRIhsz ")",
ordinal, module->descriptor->export_count);
}
if (out_function) {
@@ -371,7 +373,7 @@
IREE_UNLIKELY(call.function.ordinal >=
module->descriptor->export_count)) {
return iree_make_status(IREE_STATUS_INVALID_ARGUMENT,
- "function ordinal out of bounds: 0 < %u < %zu",
+ "function ordinal out of bounds: 0 < %u < %" PRIhsz,
call.function.ordinal,
module->descriptor->export_count);
}
diff --git a/runtime/src/iree/vm/native_module_cc.h b/runtime/src/iree/vm/native_module_cc.h
index 7db7341..712ffd3 100644
--- a/runtime/src/iree/vm/native_module_cc.h
+++ b/runtime/src/iree/vm/native_module_cc.h
@@ -172,8 +172,9 @@
auto* module = FromModulePointer(self);
if (IREE_UNLIKELY(ordinal > module->dispatch_table_.size())) {
return iree_make_status(IREE_STATUS_INVALID_ARGUMENT,
- "function out of bounds: 0 < %zu < %zu", ordinal,
- module->dispatch_table_.size());
+ "function out of bounds: 0 < %" PRIhsz
+ " < %" PRIhsz,
+ ordinal, module->dispatch_table_.size());
}
const auto& dispatch_function = module->dispatch_table_[ordinal];
if (out_function) {
@@ -254,10 +255,10 @@
auto* module = FromModulePointer(self);
if (IREE_UNLIKELY(call.function.ordinal >=
module->dispatch_table_.size())) {
- return iree_make_status(IREE_STATUS_INVALID_ARGUMENT,
- "function ordinal out of bounds: 0 < %u < %zu",
- call.function.ordinal,
- module->dispatch_table_.size());
+ return iree_make_status(
+ IREE_STATUS_INVALID_ARGUMENT,
+ "function ordinal out of bounds: 0 < %u < %" PRIhsz,
+ call.function.ordinal, module->dispatch_table_.size());
}
const auto& info = module->dispatch_table_[call.function.ordinal];
diff --git a/runtime/src/iree/vm/native_module_packing.h b/runtime/src/iree/vm/native_module_packing.h
index 180a620..a9c1d88 100644
--- a/runtime/src/iree/vm/native_module_packing.h
+++ b/runtime/src/iree/vm/native_module_packing.h
@@ -347,7 +347,8 @@
if (IREE_UNLIKELY(ptr != limit)) {
return iree_make_status(
IREE_STATUS_INVALID_ARGUMENT,
- "argument buffer unpacking failure; consumed %zu of %zu bytes",
+ "argument buffer unpacking failure; consumed %" PRIhsz " of %" PRIhsz
+ " bytes",
(reinterpret_cast<intptr_t>(ptr) -
reinterpret_cast<intptr_t>(storage.data)),
storage.data_length);
diff --git a/runtime/src/iree/vm/stack.c b/runtime/src/iree/vm/stack.c
index 44a6b65..0ca0035 100644
--- a/runtime/src/iree/vm/stack.c
+++ b/runtime/src/iree/vm/stack.c
@@ -195,7 +195,7 @@
if (storage.data_length < IREE_VM_STACK_MIN_SIZE) {
return iree_make_status(
IREE_STATUS_INVALID_ARGUMENT,
- "stack storage under minimum required amount: %zu < %d",
+ "stack storage under minimum required amount: %" PRIhsz " < %d",
storage.data_length, IREE_VM_STACK_MIN_SIZE);
}
diff --git a/runtime/src/iree/vm/test/emitc/module_test.cc b/runtime/src/iree/vm/test/emitc/module_test.cc
index bb85530..fd73e30 100644
--- a/runtime/src/iree/vm/test/emitc/module_test.cc
+++ b/runtime/src/iree/vm/test/emitc/module_test.cc
@@ -144,7 +144,8 @@
iree_vm_function_t function;
IREE_CHECK_OK(iree_vm_context_resolve_function(
context_,
- iree_string_view_t{qualified_name.data(), qualified_name.size()},
+ iree_string_view_t{qualified_name.data(), static_cast<iree_host_size_t>(
+ qualified_name.size())},
&function));
return iree_vm_invoke(context_, function, IREE_VM_INVOCATION_FLAG_NONE,
diff --git a/samples/custom_module/basic/module.cc b/samples/custom_module/basic/module.cc
index 727c48a..e81a0be 100644
--- a/samples/custom_module/basic/module.cc
+++ b/samples/custom_module/basic/module.cc
@@ -127,8 +127,9 @@
// Passed in refs may be null.
return iree_make_status(IREE_STATUS_INVALID_ARGUMENT, "null string arg");
}
- fprintf(stdout, "LENGTH %.*s = %zu\n", static_cast<int>(string->value.size),
- string->value.data, string->value.size);
+ fprintf(stdout, "LENGTH %.*s = %" PRIhsz "\n",
+ static_cast<int>(string->value.size), string->value.data,
+ string->value.size);
fflush(stdout);
return static_cast<int64_t>(string->value.size);
}
diff --git a/tools/iree-benchmark-module-main.cc b/tools/iree-benchmark-module-main.cc
index 8fc5860..9effc33 100644
--- a/tools/iree-benchmark-module-main.cc
+++ b/tools/iree-benchmark-module-main.cc
@@ -485,7 +485,8 @@
iree_vm_function_t function;
IREE_RETURN_IF_ERROR(iree_vm_module_lookup_function_by_name(
main_module, IREE_VM_FUNCTION_LINKAGE_EXPORT,
- iree_string_view_t{function_name.data(), function_name.size()},
+ iree_string_view_t{function_name.data(),
+ (iree_host_size_t)function_name.size()},
&function));
IREE_CHECK_OK(iree_tooling_parse_to_variant_list(
diff --git a/tools/iree-check-module-main.cc b/tools/iree-check-module-main.cc
index 74eb840..baa1d33 100644
--- a/tools/iree-check-module-main.cc
+++ b/tools/iree-check-module-main.cc
@@ -103,7 +103,7 @@
IREE_RETURN_IF_ERROR(
iree_vm_module_lookup_function_by_ordinal(
main_module, IREE_VM_FUNCTION_LINKAGE_EXPORT, ordinal, &function),
- "looking up function export %zu", ordinal);
+ "looking up function export %" PRIhsz, ordinal);
iree_string_view_t function_name = iree_vm_function_name(&function);
if (iree_string_view_starts_with(function_name,
diff --git a/tools/iree-dump-module-main.c b/tools/iree-dump-module-main.c
index 7c83932..1fc8b01 100644
--- a/tools/iree-dump-module-main.c
+++ b/tools/iree-dump-module-main.c
@@ -445,7 +445,8 @@
fprintf(stdout, "\n");
}
- fprintf(stdout, "FlatBuffer: %zu bytes\n", flatbuffer_contents.data_length);
+ fprintf(stdout, "FlatBuffer: %" PRIhsz " bytes\n",
+ flatbuffer_contents.data_length);
if (iree_vm_BytecodeModuleDef_bytecode_data_is_present(module_def)) {
flatbuffers_uint8_vec_t bytecode_data =
iree_vm_BytecodeModuleDef_bytecode_data(module_def);
diff --git a/tools/iree-e2e-matmul-test.c b/tools/iree-e2e-matmul-test.c
index 377f7ba..1f4b0e3 100644
--- a/tools/iree-e2e-matmul-test.c
+++ b/tools/iree-e2e-matmul-test.c
@@ -168,7 +168,7 @@
IREE_RETURN_IF_ERROR(iree_vm_list_get_variant_assign(list, i, &variant));
if (!iree_vm_variant_is_ref(variant)) {
return iree_make_status(IREE_STATUS_INVALID_ARGUMENT,
- "expected list item %zu to be a ref", i);
+ "expected list item %" PRIhsz " to be a ref", i);
}
return iree_hal_buffer_view_check_deref(variant.ref, out_value);
}
@@ -405,7 +405,8 @@
if (shape_rank != 2) {
return iree_make_status(
IREE_STATUS_INVALID_ARGUMENT,
- "expected a matrix (2D tensor) shape, got a %zu-dimensional shape",
+ "expected a matrix (2D tensor) shape, got a %" PRIhsz
+ "-dimensional shape",
shape_rank);
}
dims[0] = iree_hal_buffer_view_shape_dim(buffer_view, 0);
diff --git a/tools/iree-fatelf.c b/tools/iree-fatelf.c
index 11399e1..2f3aa9b 100644
--- a/tools/iree-fatelf.c
+++ b/tools/iree-fatelf.c
@@ -139,10 +139,10 @@
*out_elf_class = 0;
if (elf_data.data_length < sizeof(iree_elf32_ehdr_t)) {
- return iree_make_status(
- IREE_STATUS_FAILED_PRECONDITION,
- "ELF data provided (%zu) is smaller than ehdr (%zu)",
- elf_data.data_length, sizeof(iree_elf32_ehdr_t));
+ return iree_make_status(IREE_STATUS_FAILED_PRECONDITION,
+ "ELF data provided (%" PRIhsz
+ ") is smaller than ehdr (%zu)",
+ elf_data.data_length, sizeof(iree_elf32_ehdr_t));
}
// The fields we're checking are the same in both 32 and 64 classes so we just