[LLVMbugs] [Bug 5337] New: findDbgDeclare() fails to find a proper DbgDeclareInst.

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Wed Oct 28 18:23:29 PDT 2009


http://llvm.org/bugs/show_bug.cgi?id=5337

           Summary: findDbgDeclare() fails to find a proper DbgDeclareInst.
           Product: libraries
           Version: 2.6
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: trivial
          Priority: P2
         Component: Core LLVM classes
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: sunae.seo at gmail.com
                CC: llvmbugs at cs.uiuc.edu


Hello, all.

I found something strange in Debuginfo.cpp/findDbgDeclare() function.
(which is in %LLVMSRC/lib/Analysis/)

FindDbgDeclare(Instruction* V) finds the source-level variable declaration of
V.
But in my simple piece of code, it fails to find the name "LoopCount"
because of casting operation:

  for (LoopCount=0; ...; LoopCount++) {
    foo((void*) &LoopCount);
  }

FindDbgDeclare(Instruction* V) function iterates over V->UseList, finds
the *first* BitCastInst user, and completes its search. But for the above code,
clang generates two BitCastInst users for LoopCount. One is for casting
operation, and the other is for argument of @llvm.dbg.declare().
FindDbgDeclare() function fails to find the proper DbgDeclareInst, because
it is accessible by the *second* BitCastInst user (i.e., the argument of
@llvm.dbg.declare()).

I fixed this problem by modifying findDbgDeclare() code:

/// Before fixing:
      for (Value::use_const_iterator I = V->use_begin(), E =V->use_end();
            I != E; ++I)
        if (isa<BitCastInst>(I))
          return findDbgDeclare(*I, false);

/// After fixing:
      for (Value::use_const_iterator I = V->use_begin(), E =V->use_end();
            I != E; ++I) {
        if (isa<BitCastInst>(I)) {
          const DbgDeclareInst *DDI = findDbgDeclare(*I, false);
          if (DDI) return DDI;
        }

I do not know whether it is a known bug or not. But I think it is worth
to report.


-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list