[llvm] [DLCov][NFC] Annotate intentionally-blank DebugLocs in existing code (PR #136192)

Stephen Tozer via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 29 12:21:26 PDT 2025


================
@@ -1527,6 +1527,7 @@ bool IndVarSimplify::canonicalizeExitCondition(Loop *L) {
       auto *NewRHS = CastInst::Create(
           Instruction::Trunc, RHS, LHSOp->getType(), "",
           L->getLoopPreheader()->getTerminator()->getIterator());
+      NewRHS->setDebugLoc(DebugLoc::getDropped());
----------------
SLTozer wrote:

There are docs on the "How to update debug info" page and in lighter detail in DebugLoc.h, added by the previous patch in the stack. In this particular case, I didn't immediately recall the rationale - meaning this should have a comment. I believe in this case though, `NewRHS` is a sub-operation of `ICmp`, where `ICmp` is an instruction in the loop and `NewRHS` is inserted into the loop-header (to hoist work out of the loop). Given this, `NewRHS` should have `ICmp`'s DebugLoc, but since it is hoisted past a conditional branch it must be dropped, hence we just assign a "dropped" DebugLoc to the new instruction here.

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


More information about the llvm-commits mailing list