[llvm] [DebugInfo][JumpThreading] Fix missing debug location updates (PR #91581)

Orlando Cazalet-Hyams via llvm-commits llvm-commits at lists.llvm.org
Thu May 9 07:24:03 PDT 2024


================
@@ -1278,9 +1278,12 @@ bool JumpThreadingPass::simplifyPartiallyRedundantLoad(LoadInst *LoadI) {
     // only happen in dead loops.
     if (AvailableVal == LoadI)
       AvailableVal = PoisonValue::get(LoadI->getType());
-    if (AvailableVal->getType() != LoadI->getType())
+    if (AvailableVal->getType() != LoadI->getType()) {
       AvailableVal = CastInst::CreateBitOrPointerCast(
           AvailableVal, LoadI->getType(), "", LoadI->getIterator());
+      if (Instruction *CI = dyn_cast<Instruction>(AvailableVal))
+        CI->setDebugLoc(LoadI->getDebugLoc());
----------------
OCHyams wrote:

That's unfortunate that we have a hole in test coverage here but certainly not unprecedented. Another option could be to use the clang built with that assert to build other codebases, e.g., self-host (build clang again), the llvm-test-suite, or any other codebase you might have access to.

Alternatively, you could try to widen the search, e.g., moving the assert further into common code. If it's inside an `if` at the moment, move it outside the if (or further). When that gives you a test you may be able to modify the IR from that test by hand in order to hit the desired code path.

If you have a go at this and it's not fruitful let me know and I'll have a go at it too.

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


More information about the llvm-commits mailing list