It is a proposed patch for the bug presented here: https://bugs.llvm.org/show_bug.cgi?id=49099
In LLVM debug information update guide, "Hoisting identical instructions which appear in several successor blocks into a predecessor block. In this case, there is no single merged instruction. The rule for dropping locations applies."
Here in the code, the hoisted instruction keeps the previous debug location. If there are multiple of the instructions hoisted, then a conservative approach is possibly dropping the debug location.
I also provide a test case here.
If the patch makes sense, can you help commit it? Thanks.
Wording change suggestion above; I think it's clearer to just say "if instructions are hoisted". As I understand the HowToUpdate... document, we drop source locations whenever we move instructions between blocks, no matter how many.
IMO, it's better to not refer to the debug-info-update-guide from source comments -- the comments should only describe the intention / purpose of the code. (This may be a style thing).