Skip to content

Commit

Permalink
Fix runtime pointer direct cast (#14592)
Browse files Browse the repository at this point in the history
Add `intptr_t` cast in between `uint64_t` and the `void*` or flatbuffer
pointer types.


To void the `int-to-pointer-cast` and `pointer-to int-cast` warnings
when build with 32-bit system

```
iree/runtime/src/iree/hal/allocator_heap.c:237:13: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
  237 |       ptr = (void*)external_buffer->handle.device_allocation.ptr;
      |             ^

```
```
iree/runtime/src/iree/vm/bytecode/module.c:528:7: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
  528 |       (iree_vm_FunctionSourceMapDef_table_t)data[0];
      |       ^

iree/vm/bytecode/module.c:590:34: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
  590 |   out_source_location->data[0] = (uint64_t)source_map_def;
      |                                  ^

```
  • Loading branch information
hcindyl authored Aug 7, 2023
1 parent b47ed8c commit d5c9283
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion runtime/src/iree/hal/allocator_heap.c
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ static iree_status_t iree_hal_heap_allocator_import_buffer(
ptr = external_buffer->handle.host_allocation.ptr;
break;
case IREE_HAL_EXTERNAL_BUFFER_TYPE_DEVICE_ALLOCATION:
ptr = (void*)external_buffer->handle.device_allocation.ptr;
ptr = (void*)((intptr_t)external_buffer->handle.device_allocation.ptr);
break;
default:
return iree_make_status(IREE_STATUS_UNAVAILABLE,
Expand Down
4 changes: 2 additions & 2 deletions runtime/src/iree/vm/bytecode/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ static iree_status_t iree_vm_bytecode_module_source_location_format(
iree_vm_DebugDatabaseDef_table_t debug_database_def =
(iree_vm_DebugDatabaseDef_table_t)self;
iree_vm_FunctionSourceMapDef_table_t source_map_def =
(iree_vm_FunctionSourceMapDef_table_t)data[0];
(iree_vm_FunctionSourceMapDef_table_t)((intptr_t)data[0]);
iree_vm_BytecodeLocationDef_vec_t locations =
iree_vm_FunctionSourceMapDef_locations(source_map_def);
iree_vm_source_offset_t source_offset = (iree_vm_source_offset_t)data[1];
Expand Down Expand Up @@ -587,7 +587,7 @@ static iree_status_t iree_vm_bytecode_module_resolve_source_location(
// The source location stores the source map and PC and will perform the
// actual lookup within the source map on demand.
out_source_location->self = (void*)debug_database_def;
out_source_location->data[0] = (uint64_t)source_map_def;
out_source_location->data[0] = (uint64_t)((intptr_t)source_map_def);
out_source_location->data[1] = (uint64_t)pc;
out_source_location->format = iree_vm_bytecode_module_source_location_format;
return iree_ok_status();
Expand Down

0 comments on commit d5c9283

Please sign in to comment.