Skip to content

Commit 61cb963

Browse files
authored
Fix use after free in CombineTMEMLoadAndStore (#6433)
The patch fixes use-after-free error in the recently introduced HoistTMEMAlloc.cpp which was detected by the asan build. We cannot use iterator to the users after erasing the current user of it. The solution is to wrap the iterator with make_early_inc_range.
1 parent a5e485f commit 61cb963

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/Dialect/TritonGPU/Transforms/HoistTMEMAlloc.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ class CombineTMEMLoadAndStore : public OpRewritePattern<ttng::TMEMLoadOp> {
128128
LogicalResult matchAndRewrite(ttng::TMEMLoadOp load,
129129
PatternRewriter &rewriter) const override {
130130
bool foundStore = false;
131-
for (auto user : load->getUsers()) {
131+
for (auto user : llvm::make_early_inc_range(load->getUsers())) {
132132
if (auto store = dyn_cast<ttng::TMEMStoreOp>(user)) {
133133
if (store.getDst() != load.getSrc()) {
134134
continue;

0 commit comments

Comments
 (0)