[PATCH] D159485: [DebugInfo][RemoveDIs] Use getStableDebugLoc when picking IRBuilder source locations

Augie Fackler via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 13 09:40:43 PDT 2023


durin42 added inline comments.


================
Comment at: llvm/include/llvm/IR/IRBuilder.h:200
     if (IP != TheBB->end())
-      SetCurrentDebugLocation(IP->getDebugLoc());
+      SetCurrentDebugLocation(IP->getStableDebugLoc());
   }
----------------
jmorse wrote:
> durin42 wrote:
> > The crash I'm seeing is on this line, I can give you the stack trace if you want to look in parallel with my investigation.
> Rather than the stack, the contents of the block would be super-useful -- if you can attach an interactive debugger before the crash, then when the crash occurs, running:
>     call IP->dump()
>     call IP->getParent()->dump()
> Will print all the relevant information to the terminal / output
How does this as a follow-up look to you?

```
diff --git a/llvm/lib/IR/Instruction.cpp b/llvm/lib/IR/Instruction.cpp
index 6b0348f8f691..37cce7729741 100644
--- a/llvm/lib/IR/Instruction.cpp
+++ b/llvm/lib/IR/Instruction.cpp
@@ -886,8 +886,11 @@ Instruction::getPrevNonDebugInstruction(bool SkipPseudoOp) const {
 }

 const DebugLoc &Instruction::getStableDebugLoc() const {
-  if (isa<DbgInfoIntrinsic>(this))
-    return getNextNonDebugInstruction()->getDebugLoc();
+  if (isa<DbgInfoIntrinsic>(this)) {
+    const Instruction* next = getNextNonDebugInstruction();
+    if (next)
+      return next->getDebugLoc();
+  }
   return getDebugLoc();
 }
```


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D159485/new/

https://reviews.llvm.org/D159485



More information about the llvm-commits mailing list