This patch fixes the issue observed at https://bugs.chromium.org/p/chromium/issues/detail?id=1224338, mentioned in D91722.
The above issue occurs in CodeGenPrepare::fixupDbgValue, where we attempt to update the location operands of a dbg.value. The error occurs when the dbg.value uses a DIArgList that contains the same value multiple times; currently the update is performed by iterating over the location operands, and updating them within that loop by calling replaceVariableLocationOp, which invalidates the iterator; specifically, it continues to point to the old list of values, and so the loop attempts to replace the same value again when it isn't present in the list anymore, resulting in the observed error.
This has been fixed by first collecting the dbg.value's location operands into a set and then iterating over that, ensuring that we don't invalidate our loop iterator or attempt to replace a non-existing operand. Upon investigating, I discovered that the same issue exists in HWAddressSanitizer::sanitizeFunction, and have added the same fix as part of this patch.