Skip to content

Commit

Permalink
Fix double deallocs
Browse files Browse the repository at this point in the history
Signed-off-by: dchigarev <dmitry.chigarev@intel.com>
  • Loading branch information
dchigarev authored and Longsheng Du committed Sep 6, 2024
1 parent ee45972 commit b320358
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/Transforms/InsertGPUAllocs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,15 @@ class InsertGPUAllocsPass final
use.set(newAlloc.getResult());
}
}

// remove 'memref.dealloc' (it's later replaced with gpu.dealloc)
auto memory = alloc->getResult(0);
for (auto u : memory.getUsers()) {
if (auto dealloc = mlir::dyn_cast<mlir::memref::DeallocOp>(u)) {
dealloc.erase();
}
}

alloc.replaceAllUsesWith(allocResult);
builder.create<mlir::gpu::DeallocOp>(loc, std::nullopt, allocResult);
alloc.erase();
Expand Down

0 comments on commit b320358

Please sign in to comment.