Renaming hal.allocator.wrap.byte_buffer.
Its behavior is the same as hal.allocator.allocate and it wasn't actually
mapping anything so it's better to just call it that. The newer
hal.allocator.map.byte_buffer actually maps (if possible) and is used for
those purposes instead.
diff --git a/compiler/src/iree/compiler/Dialect/HAL/Conversion/HALToVM/ConvertAllocatorOps.cpp b/compiler/src/iree/compiler/Dialect/HAL/Conversion/HALToVM/ConvertAllocatorOps.cpp
index 649b370..b4880a9 100644
--- a/compiler/src/iree/compiler/Dialect/HAL/Conversion/HALToVM/ConvertAllocatorOps.cpp
+++ b/compiler/src/iree/compiler/Dialect/HAL/Conversion/HALToVM/ConvertAllocatorOps.cpp
@@ -13,19 +13,20 @@
 namespace iree_compiler {
 namespace {
 
-class AllocatorMapOpConversion
-    : public OpConversionPattern<IREE::HAL::AllocatorMapOp> {
+class AllocatorAllocateInitializedOpConversion
+    : public OpConversionPattern<IREE::HAL::AllocatorAllocateInitializedOp> {
  public:
-  AllocatorMapOpConversion(TypeConverter &typeConverter, MLIRContext *context,
-                           SymbolTable &importSymbols)
+  AllocatorAllocateInitializedOpConversion(TypeConverter &typeConverter,
+                                           MLIRContext *context,
+                                           SymbolTable &importSymbols)
       : OpConversionPattern(typeConverter, context) {
     importOp = importSymbols.lookup<IREE::VM::ImportOp>(
-        "hal.allocator.wrap.byte_buffer");
+        "hal.allocator.allocate.initialized");
     assert(importOp);
   }
 
   LogicalResult matchAndRewrite(
-      IREE::HAL::AllocatorMapOp op, OpAdaptor adaptor,
+      IREE::HAL::AllocatorAllocateInitializedOp op, OpAdaptor adaptor,
       ConversionPatternRewriter &rewriter) const override {
     auto callOp = rewriter.replaceOpWithNewOp<IREE::VM::CallOp>(
         op, importOp.getName(),
@@ -100,8 +101,8 @@
                                       RewritePatternSet &patterns) {
   patterns.insert<VMImportOpConversion<IREE::HAL::AllocatorAllocateOp>>(
       context, importSymbols, typeConverter, "hal.allocator.allocate");
-  patterns.insert<AllocatorMapOpConversion>(typeConverter, context,
-                                            importSymbols);
+  patterns.insert<AllocatorAllocateInitializedOpConversion>(
+      typeConverter, context, importSymbols);
   patterns.insert<AllocatorTryMapOpConversion>(typeConverter, context,
                                                importSymbols);
 }
diff --git a/compiler/src/iree/compiler/Dialect/HAL/Conversion/HALToVM/test/allocator_ops.mlir b/compiler/src/iree/compiler/Dialect/HAL/Conversion/HALToVM/test/allocator_ops.mlir
index ad99805..1de221d 100644
--- a/compiler/src/iree/compiler/Dialect/HAL/Conversion/HALToVM/test/allocator_ops.mlir
+++ b/compiler/src/iree/compiler/Dialect/HAL/Conversion/HALToVM/test/allocator_ops.mlir
@@ -17,7 +17,7 @@
   %offset = arith.constant 128 : index
   // CHECK-DAG: %[[LENGTH:.+]] = vm.const.i64 256
   %length = arith.constant 256 : index
-  // CHECK: = vm.call @hal.allocator.wrap.byte_buffer(%arg0, %c6, %c3, %arg1, %[[OFFSET]], %[[LENGTH]]) : (!vm.ref<!hal.allocator>, i32, i32, !vm.buffer, i64, i64) -> !vm.ref<!hal.buffer>
-  %buffer = hal.allocator.map<%arg0 : !hal.allocator> source(%arg1 : !util.byte_buffer)[%offset, %length] type("HostVisible|HostCoherent") usage("Transfer") : !hal.buffer
+  // CHECK: = vm.call @hal.allocator.allocate.initialized(%arg0, %c6, %c3, %arg1, %[[OFFSET]], %[[LENGTH]]) : (!vm.ref<!hal.allocator>, i32, i32, !vm.buffer, i64, i64) -> !vm.ref<!hal.buffer>
+  %buffer = hal.allocator.allocate.initialized<%arg0 : !hal.allocator> source(%arg1 : !util.byte_buffer)[%offset, %length] type("HostVisible|HostCoherent") usage("Transfer") : !hal.buffer
   return %buffer : !hal.buffer
 }
diff --git a/compiler/src/iree/compiler/Dialect/HAL/Conversion/StreamToHAL/ConvertStreamToHAL.cpp b/compiler/src/iree/compiler/Dialect/HAL/Conversion/StreamToHAL/ConvertStreamToHAL.cpp
index 220afd1..d08f88e 100644
--- a/compiler/src/iree/compiler/Dialect/HAL/Conversion/StreamToHAL/ConvertStreamToHAL.cpp
+++ b/compiler/src/iree/compiler/Dialect/HAL/Conversion/StreamToHAL/ConvertStreamToHAL.cpp
@@ -318,7 +318,7 @@
     auto bufferUsage = IREE::HAL::BufferUsageBitfield::Mapping |
                        IREE::HAL::BufferUsageBitfield::Transfer;
 
-    rewriter.replaceOpWithNewOp<IREE::HAL::AllocatorMapOp>(
+    rewriter.replaceOpWithNewOp<IREE::HAL::AllocatorAllocateInitializedOp>(
         mapOp, bufferType, allocator, memoryTypes, bufferUsage,
         adaptor.source(), adaptor.source_offset(), adaptor.result_size());
     return success();
diff --git a/compiler/src/iree/compiler/Dialect/HAL/Conversion/StreamToHAL/test/resource_ops.mlir b/compiler/src/iree/compiler/Dialect/HAL/Conversion/StreamToHAL/test/resource_ops.mlir
index cf5a6bd..c7ffb72 100644
--- a/compiler/src/iree/compiler/Dialect/HAL/Conversion/StreamToHAL/test/resource_ops.mlir
+++ b/compiler/src/iree/compiler/Dialect/HAL/Conversion/StreamToHAL/test/resource_ops.mlir
@@ -87,7 +87,7 @@
 func.func @resourceMap(%arg0: !util.byte_buffer) -> !stream.resource<staging> {
   %c0 = arith.constant 0 : index
   %c128 = arith.constant 128 : index
-  // CHECK: %[[MAPPING:.+]] = hal.allocator.map
+  // CHECK: %[[MAPPING:.+]] = hal.allocator.allocate.initialized
   // CHECK-SAME: source(%arg0 : !util.byte_buffer)[%c0, %c128]
   // CHECK-SAME: type("HostVisible|HostCoherent|HostLocal|DeviceVisible")
   // CHECK-SAME: usage("{{.+}}Transfer{{.+}}Mapping{{.+}}") : !hal.buffer
diff --git a/compiler/src/iree/compiler/Dialect/HAL/IR/HALOps.cpp b/compiler/src/iree/compiler/Dialect/HAL/IR/HALOps.cpp
index be166c5..5091c3f 100644
--- a/compiler/src/iree/compiler/Dialect/HAL/IR/HALOps.cpp
+++ b/compiler/src/iree/compiler/Dialect/HAL/IR/HALOps.cpp
@@ -318,17 +318,21 @@
 Value AllocatorAllocateOp::getResultSize(unsigned idx) { return result_size(); }
 
 //===----------------------------------------------------------------------===//
-// hal.allocator.map
+// hal.allocator.allocate.initialized
 //===----------------------------------------------------------------------===//
 
-void AllocatorMapOp::getAsmResultNames(
+void AllocatorAllocateInitializedOp::getAsmResultNames(
     function_ref<void(Value, StringRef)> setNameFn) {
   setNameFn(result(), "mapped");
 }
 
-Value AllocatorMapOp::getOperandSize(unsigned idx) { return {}; }
+Value AllocatorAllocateInitializedOp::getOperandSize(unsigned idx) {
+  return {};
+}
 
-Value AllocatorMapOp::getResultSize(unsigned idx) { return length(); }
+Value AllocatorAllocateInitializedOp::getResultSize(unsigned idx) {
+  return length();
+}
 
 //===----------------------------------------------------------------------===//
 // hal.allocator.try_map
diff --git a/compiler/src/iree/compiler/Dialect/HAL/IR/HALOps.td b/compiler/src/iree/compiler/Dialect/HAL/IR/HALOps.td
index 2c520fa..34b251b 100644
--- a/compiler/src/iree/compiler/Dialect/HAL/IR/HALOps.td
+++ b/compiler/src/iree/compiler/Dialect/HAL/IR/HALOps.td
@@ -215,7 +215,7 @@
   }];
 }
 
-def HAL_AllocatorMapOp : HAL_Op<"allocator.map", [
+def HAL_AllocatorAllocateInitializedOp : HAL_Op<"allocator.allocate.initialized", [
     DeclareOpInterfaceMethods<OpAsmOpInterface, ["getAsmResultNames"]>,
     DeclareOpInterfaceMethods<Util_SizeAwareOp>,
   ]> {
diff --git a/compiler/src/iree/compiler/Dialect/HAL/IR/test/allocator_ops.mlir b/compiler/src/iree/compiler/Dialect/HAL/IR/test/allocator_ops.mlir
index a734225..01407e4 100644
--- a/compiler/src/iree/compiler/Dialect/HAL/IR/test/allocator_ops.mlir
+++ b/compiler/src/iree/compiler/Dialect/HAL/IR/test/allocator_ops.mlir
@@ -23,12 +23,12 @@
   %offset = arith.constant 100 : index
   // CHECK-DAG: %[[LENGTH:.+]] = arith.constant 200
   %length = arith.constant 200 : index
-  //      CHECK: = hal.allocator.map<%[[ALLOCATOR]] : !hal.allocator>
+  //      CHECK: = hal.allocator.allocate.initialized<%[[ALLOCATOR]] : !hal.allocator>
   // CHECK-SAME:   source(%arg1 : !util.byte_buffer)[%[[OFFSET]], %[[LENGTH]]]
   // CHECK-SAME:   type("DeviceVisible|DeviceLocal")
   // CHECK-SAME:   usage("TransferSource|TransferTarget|Transfer")
   // CHECK-SAME:   : !hal.buffer
-  %ref = hal.allocator.map<%allocator : !hal.allocator>
+  %ref = hal.allocator.allocate.initialized<%allocator : !hal.allocator>
                     source(%arg1 : !util.byte_buffer)[%offset, %length]
                     type(DeviceLocal) usage(Transfer) : !hal.buffer
   return
diff --git a/compiler/src/iree/compiler/Dialect/HAL/hal.imports.mlir b/compiler/src/iree/compiler/Dialect/HAL/hal.imports.mlir
index 3162b13..eb4e580 100644
--- a/compiler/src/iree/compiler/Dialect/HAL/hal.imports.mlir
+++ b/compiler/src/iree/compiler/Dialect/HAL/hal.imports.mlir
@@ -28,12 +28,10 @@
   %allocation_size : i64
 ) -> !vm.ref<!hal.buffer>
 
-// Maps a host byte buffer into a device buffer.
-// If try!=0 then returns null if the given memory type cannot be mapped.
-// Host-local+constant requests will always succeed.
-vm.import @allocator.map.byte_buffer(
+// Allocates a buffer from the allocator with an initial value provided by a
+// VM byte buffer.
+vm.import @allocator.allocate.initialized(
   %allocator : !vm.ref<!hal.allocator>,
-  %try : i32,
   %memory_types : i32,
   %buffer_usage : i32,
   %source : !vm.buffer,
@@ -41,11 +39,12 @@
   %length : i64
 ) -> !vm.ref<!hal.buffer>
 
-// TODO(benvanik): remove wrap.
-// Wraps a subrange of a read-only host memory buffer.
-// Host mapping must be supported by the allocator.
-vm.import @allocator.wrap.byte_buffer(
+// Maps a host byte buffer into a device buffer.
+// If try!=0 then returns null if the given memory type cannot be mapped.
+// Host-local+constant requests will always succeed.
+vm.import @allocator.map.byte_buffer(
   %allocator : !vm.ref<!hal.allocator>,
+  %try : i32,
   %memory_types : i32,
   %buffer_usage : i32,
   %source : !vm.buffer,
diff --git a/runtime/src/iree/modules/hal/exports.inl b/runtime/src/iree/modules/hal/exports.inl
index 27803a0..83f905f 100644
--- a/runtime/src/iree/modules/hal/exports.inl
+++ b/runtime/src/iree/modules/hal/exports.inl
@@ -25,8 +25,8 @@
 // clang-format off
 
 EXPORT_FN("allocator.allocate", iree_hal_module_allocator_allocate, riiI, r)
+EXPORT_FN("allocator.allocate.initialized", iree_hal_module_allocator_allocate_initialized, riirII, r)
 EXPORT_FN("allocator.map.byte_buffer", iree_hal_module_allocator_map_byte_buffer, riiirII, r)
-EXPORT_FN("allocator.wrap.byte_buffer", iree_hal_module_allocator_wrap_byte_buffer, riirII, r)
 
 EXPORT_FN("buffer.assert", iree_hal_module_buffer_assert, rrrIii, v)
 EXPORT_FN("buffer.length", iree_hal_module_buffer_length, r, I)
diff --git a/runtime/src/iree/modules/hal/module.c b/runtime/src/iree/modules/hal/module.c
index 41f244d..3e4fb9e 100644
--- a/runtime/src/iree/modules/hal/module.c
+++ b/runtime/src/iree/modules/hal/module.c
@@ -285,6 +285,46 @@
   return iree_ok_status();
 }
 
+IREE_VM_ABI_EXPORT(iree_hal_module_allocator_allocate_initialized,  //
+                   iree_hal_module_state_t,                         //
+                   riirII, r) {
+  iree_hal_allocator_t* allocator = NULL;
+  IREE_RETURN_IF_ERROR(iree_hal_allocator_check_deref(args->r0, &allocator));
+  iree_hal_memory_type_t memory_types = (iree_hal_memory_type_t)args->i1;
+  iree_hal_buffer_usage_t buffer_usage = (iree_hal_buffer_usage_t)args->i2;
+  iree_vm_buffer_t* source = NULL;
+  IREE_RETURN_IF_ERROR(iree_vm_buffer_check_deref(args->r3, &source));
+  iree_device_size_t offset = iree_hal_cast_device_size(args->i4);
+  iree_device_size_t length = iree_hal_cast_device_size(args->i5);
+
+  iree_host_size_t buffer_length = source->data.data_length;
+  if (length == -1) {
+    length = buffer_length;
+  }
+  if (length < 0 || offset < 0 || offset > buffer_length ||
+      offset + length > buffer_length) {
+    return iree_make_status(IREE_STATUS_INVALID_ARGUMENT,
+                            "byte range out of bounds (requested %" PRIdsz
+                            "-%" PRIdsz " of available %" PRIhsz ")",
+                            offset, (offset + length - 1), buffer_length);
+  }
+
+  const iree_hal_buffer_params_t params = {
+      .type = memory_types,
+      .usage = buffer_usage,
+  };
+  iree_hal_buffer_t* buffer = NULL;
+  IREE_RETURN_IF_ERROR(
+      iree_hal_allocator_allocate_buffer(
+          allocator, params, length,
+          iree_make_const_byte_span(source->data.data + offset, length),
+          &buffer),
+      "failed to allocate buffer of length %" PRIdsz, length);
+
+  rets->r0 = iree_hal_buffer_move_ref(buffer);
+  return iree_ok_status();
+}
+
 static void iree_hal_module_mapped_buffer_release(void* user_data,
                                                   iree_hal_buffer_t* buffer) {
   iree_vm_buffer_t* backing_buffer = (iree_vm_buffer_t*)user_data;
@@ -377,47 +417,6 @@
   return status;
 }
 
-// TODO(#7277): drop this method (use map instead) with streams.
-IREE_VM_ABI_EXPORT(iree_hal_module_allocator_wrap_byte_buffer,  //
-                   iree_hal_module_state_t,                     //
-                   riirII, r) {
-  iree_hal_allocator_t* allocator = NULL;
-  IREE_RETURN_IF_ERROR(iree_hal_allocator_check_deref(args->r0, &allocator));
-  iree_hal_memory_type_t memory_types = (iree_hal_memory_type_t)args->i1;
-  iree_hal_buffer_usage_t buffer_usage = (iree_hal_buffer_usage_t)args->i2;
-  iree_vm_buffer_t* source = NULL;
-  IREE_RETURN_IF_ERROR(iree_vm_buffer_check_deref(args->r3, &source));
-  iree_device_size_t offset = iree_hal_cast_device_size(args->i4);
-  iree_device_size_t length = iree_hal_cast_device_size(args->i5);
-
-  iree_host_size_t buffer_length = source->data.data_length;
-  if (length == -1) {
-    length = buffer_length;
-  }
-  if (length < 0 || offset < 0 || offset > buffer_length ||
-      offset + length > buffer_length) {
-    return iree_make_status(IREE_STATUS_INVALID_ARGUMENT,
-                            "byte range out of bounds (requested %" PRIdsz
-                            "-%" PRIdsz " of available %" PRIhsz ")",
-                            offset, (offset + length - 1), buffer_length);
-  }
-
-  const iree_hal_buffer_params_t params = {
-      .type = memory_types,
-      .usage = buffer_usage,
-  };
-  iree_hal_buffer_t* buffer = NULL;
-  IREE_RETURN_IF_ERROR(
-      iree_hal_allocator_allocate_buffer(
-          allocator, params, length,
-          iree_make_const_byte_span(source->data.data + offset, length),
-          &buffer),
-      "failed to allocate buffer of length %" PRIdsz, length);
-
-  rets->r0 = iree_hal_buffer_move_ref(buffer);
-  return iree_ok_status();
-}
-
 //===----------------------------------------------------------------------===//
 // iree_hal_buffer_t
 //===----------------------------------------------------------------------===//