Build `mlir_rocm_runtime` as a standalone runtime library by removing
its last
source-level dependency on LLVM support utilities.
`mlir_rocm_runtime` is intended to be loaded dynamically by tools such
as
`mlir-runner` via `--shared-libs`. However, `add_mlir_library` links
`LLVMSupport` by default unless the target is marked `STANDALONE`. The
ROCm
runtime was previously left on `DISABLE_PCH_REUSE` as a workaround
because
`RocmRuntimeWrappers.cpp` still used `llvm::SmallVector` and
`llvm::ArrayRef`
inside `mgpuMemHostRegisterMemRef`.
This patch replaces that small LLVM ADT use with equivalent plain C++
logic and
marks `mlir_rocm_runtime` `STANDALONE`, matching the CUDA runtime.
## Motivation
This follows the direction from prior upstream changes:
-
[`4edc9e2acf1d`](https://github.com/llvm/llvm-project/commit/4edc9e2acf1d9350ce4da77c93e8869f774a24e2)
/
[D108684](https://reviews.llvm.org/D108684), by Uday Bondhugula, removed
the
same `SmallVector`/`ArrayRef` dependency from CUDA's
`mgpuMemHostRegisterMemRef`, noting that the dependency on `LLVMSupport`
adds
unnecessary complexity for external users linking or loading the
runtime.
-
[`351ae0ca550c`](https://github.com/llvm/llvm-project/commit/351ae0ca550c791b0c504dfb7dcb4fd08480d98b)
/
[#182850](https://github.com/llvm/llvm-project/pull/182850) made several
dlopen-able MLIR runtime libraries `STANDALONE`, including
`mlir_cuda_runtime`, and left `mlir_rocm_runtime` on `DISABLE_PCH_REUSE`
only
because it still depended on `LLVMSupport`.
-
[`78f259fcc14b`](https://github.com/llvm/llvm-project/commit/78f259fcc14bb0a567d45ba394fcde48de2bc299)
/
[#182942](https://github.com/llvm/llvm-project/pull/182942) applied the
same
cleanup pattern to `mlir_levelzero_runtime` by removing a small
remaining LLVM
dependency and marking the runtime `STANDALONE`.
With the remaining LLVM ADT use removed from the ROCm wrapper, the
workaround is
no longer needed.
## Testing
Verified and tested downstream in rocMLIR.
No new upstream test is added. This is a build/linkage cleanup for a
runtime
library that is already exercised by the ROCm integration tests when
`MLIR_ENABLE_ROCM_RUNNER` is enabled.
The rewritten dense-stride computation in `mgpuMemHostRegisterMemRef` is
equivalent to the previous implementation and matches the existing CUDA
runtime
implementation.
## AI Assistance Disclosure
Assisted-by: GPT-5.5
I reviewed the generated content and verified the changes before
submitting,
including testing them downstream in rocMLIR.
---------
Co-authored-by: Cursor <cursoragent@cursor.com>