[llvm] [DebugInfo][Reassociate] Fix missing debug location drop (PR #95355)

Shan Huang via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 13 18:44:06 PDT 2024


================
@@ -845,6 +845,7 @@ static Value *NegateValue(Value *V, Instruction *BI,
     }
 
     TheNeg->moveBefore(*InsertPt->getParent(), InsertPt);
+    TheNeg->dropLocation();
----------------
Apochens wrote:

Yah, you're right. Actually there are test cases in which `TheNeg` is moved inside its parent block. 10 test cases failed by inserting `assert(false)` right before `moveBefore()`, and 2 of them move `TheNeg` out of the loop to the preheader (causing this misleading debug location) and 8 of them move it just inside one basic block.

If we can decide whether `InsertPt` is dominated or post-dominated by `TheNeg`, like using (Post)DominatorTreeAnalysis, then we could choose to drop the location or not. That's my thought, but adding the (Post) Dominator Analysis here requires a lot modification to the pass.

https://github.com/llvm/llvm-project/pull/95355


More information about the llvm-commits mailing list