[llvm] [offload] Fix kernel record/replay and add extensible mechanism (PR #190588)
Konstantinos Parasyris via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 9 16:45:51 PDT 2026
================
@@ -313,6 +317,45 @@ struct DynBlockMemConfTy {
void *FallbackPtr = nullptr;
};
+/// Tracker of virtual memory address reservations.
+template <typename HandleTy> class VMemTrackerTy {
+ struct EntryTy {
+ uint64_t Size;
+ HandleTy Handle;
+ };
+
+ /// Map of virtual memory address reservations.
+ DenseMap<void *, EntryTy> VMemMap;
+
+ /// Mutex for safe access to the map.
+ std::mutex Mutex;
+
+public:
+ /// Register a new virtual address reservation.
+ Error registerReservation(void *VAddr, uint64_t Size, HandleTy Handle) {
+ std::lock_guard<std::mutex> Lock(Mutex);
+ auto It = VMemMap.find(VAddr);
+ if (It != VMemMap.end())
+ return Plugin::error(error::ErrorCode::INVALID_ARGUMENT,
+ "virtual address already reserved");
+ VMemMap[VAddr] = {Size, Handle};
+ return Plugin::success();
+ }
+
+ /// Unregister a virtual address reservation and return its information.
+ Expected<std::pair<uint64_t, HandleTy>> unregisterReservation(void *VAddr) {
+ std::lock_guard<std::mutex> Lock(Mutex);
+ auto It = VMemMap.find(VAddr);
+ if (It == VMemMap.end())
+ return Plugin::error(error::ErrorCode::INVALID_ARGUMENT,
----------------
koparasy wrote:
On Mneme, were we track all allocations through LD_PRELOAD, there are invocations that free nullptr, hip allows that, and being extremely defensive here may lead to errors that are not expected.
https://github.com/llvm/llvm-project/pull/190588
More information about the llvm-commits
mailing list