https://github.com/NagyDonat approved this pull request. LGTM, this is a straightforward bugfix. The other, more general changes also sound good, but I don't think that they should block merging this. https://github.com/llvm/llvm-project/pull/170887