[MLIR][Transform] Safely erase transform ops by collecting first (#172016)
Avoids runtime crashes caused by deleting operations inside a walk.
Operations are gathered during the walk and then erased in the correct
dependency order after the walk finishes.
Issue: [#130023](https://github.com/llvm/llvm-project/issues/130023)
---------
Co-authored-by: Milos Poletanovic <mpoletanovic@syrmia.com>
Co-authored-by: Milos Poletanovic <milos.poletanovic@htecgroup.com>