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.
clang-format: please reformat the code
- // if there are multiple instructions to hoist, we should conservatively drop the debug location: according to the LLVM debug information update guide, if multiple identical instructions are hoisted into a predecessor block, the debug information should not be preserved. - if(InstructionsToHoist.size() > 1){ + // if there are multiple instructions to hoist, we should conservatively + // drop the debug location: according to the LLVM debug information update + // guide, if multiple identical instructions are hoisted into a + // predecessor block, the debug information should not be preserved. + if (InstructionsToHoist.size() > 1) {