Skip to content

Commit b4e7bf1

Browse files
[TLX][AMD] isFedByTDM: switch to pop_back_val worklist idiom
Index-iterate-while-inserting on a SetVector works (Value::getUsers snapshots Operation-level iterators independent of SetVector storage), but it's a non-obvious pattern. Switch to the more idiomatic `pop_back_val` form which makes the value lifetime explicit (no reference into possibly-reallocated storage). DFS instead of BFS order is benign here — the function is a short-circuiting any-exists query over a tree-shaped memdesc graph. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 88f8f7d commit b4e7bf1

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

third_party/tlx/dialect/lib/Transforms/InsertRequireLayout.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,8 +280,9 @@ static Value findMemDescRoot(Value memdesc) {
280280
static bool isFedByTDM(Value memdesc) {
281281
llvm::SetVector<Value> worklist;
282282
worklist.insert(findMemDescRoot(memdesc));
283-
for (size_t i = 0; i < worklist.size(); ++i) {
284-
for (Operation *u : worklist[i].getUsers()) {
283+
while (!worklist.empty()) {
284+
Value v = worklist.pop_back_val();
285+
for (Operation *u : v.getUsers()) {
285286
if (isa<amdgpu::AsyncTDMCopyGlobalToLocalOp>(u))
286287
return true;
287288
if (isa<ttg::MemDescIndexOp, ttg::MemDescReinterpretOp>(u))

0 commit comments

Comments
 (0)