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

Arthur Eubanks via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 14 17:03:56 PDT 2023


aeubanks added inline comments.


================
Comment at: llvm/include/llvm/IR/IRBuilder.h:200
     if (IP != TheBB->end())
-      SetCurrentDebugLocation(IP->getDebugLoc());
+      SetCurrentDebugLocation(IP->getStableDebugLoc());
   }
----------------
durin42 wrote:
> durin42 wrote:
> > 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();
> >  }
> > ```
> Finally got the dump (had to write it to a file in /tmp, sigh):
> 
> ```
>   call void @llvm.dbg.declare(metadata ptr %x, metadata !4697, metadata !DIExpression()), !dbg !4698
> 
> start:
>   call void @llvm.dbg.declare(metadata ptr %x, metadata !562, metadata !DIExpression()), !dbg !563
> 
> ```
the rustc backtrace was trying to create an alloca, is the issue that the dbg intrinsic is getting built before the alloca? so maybe an issue on the rustc side? it's weird that the entry block (I'm assuming based on `start:`) only has a `dbg.declare` without a corresponding alloca already there


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