[llvm] [AMDGPU] Prevent hang in SIFoldOperands (PR #82099)

Jay Foad via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 21 02:41:38 PST 2024


jayfoad wrote:

Yes that explanation makes sense, but this problem has already been solved in a different way in the main loop that calls `foldOperand` on each use of a register, in `foldInstOperand`:
```
  SmallVector<MachineOperand *, 4> UsesToProcess;
  for (auto &Use : MRI->use_nodbg_operands(Dst.getReg()))
    UsesToProcess.push_back(&Use);
  for (auto *U : UsesToProcess) {
    MachineInstr *UseMI = U->getParent();
    foldOperand(OpToFold, UseMI, UseMI->getOperandNo(U), FoldList,
                CopiesToReplace);
  }
```
So perhaps we should just copy that solution here? (I.e. copy the uses into a temporary vector, to avoid any problem with the list being mutated while we are iterating over it.)

https://github.com/llvm/llvm-project/pull/82099


More information about the llvm-commits mailing list