[LLVMbugs] [Bug 4303] New: llvm.dbg.declare vs -instcombine

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Wed Jun 3 02:09:43 PDT 2009


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

           Summary: llvm.dbg.declare vs -instcombine
           Product: libraries
           Version: trunk
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Core LLVM classes
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: jay.foad at antixlabs.com
                CC: llvmbugs at cs.uiuc.edu


I get a verification failure when I run this test case through -instcombine:

$ cat d.ll
define void @f() {
        %a = alloca {}
        call void @llvm.dbg.declare({}* %a, {}* null)
        ret void
}
declare void @llvm.dbg.declare({}*, {}*)
$ llvm-as -o - d.ll | opt -f -o /dev/null -instcombine
invalid llvm.dbg.declare intrinsic call
        call void @llvm.dbg.declare({ }* null, { }* null)
Broken module found, compilation aborted!
0   opt 0x0844ccc8
Stack dump:
0.      Running pass 'Function Pass Manager' on module '<stdin>'.
1.      Running pass 'Module Verifier' on function '@f'
Aborted

The problem is that -instcombine replaces the alloca with null:

  if (isa<AllocaInst>(AI) && AI.getAllocatedType()->isSized()) {
    // If alloca'ing a zero byte object, replace the alloca with a null
pointer.
    // Note that we only do this for alloca's, because malloc should allocate
    // and return a unique pointer, even for a zero byte allocation.
    if (TD->getTypeAllocSize(AI.getAllocatedType()) == 0)
      return ReplaceInstUsesWith(AI, Constant::getNullValue(AI.getType()));

    // If the alignment is 0 (unspecified), assign it the preferred alignment.
    if (AI.getAlignment() == 0)
      AI.setAlignment(TD->getPrefTypeAlignment(AI.getAllocatedType()));
  }

but -verify asserts that the first arguments to llvm.dbg.declare is non-null:

  case Intrinsic::dbg_declare:  // llvm.dbg.declare
    if (Constant *C = dyn_cast<Constant>(CI.getOperand(1)))
      Assert1(C && !isa<ConstantPointerNull>(C),
              "invalid llvm.dbg.declare intrinsic call", &CI);
    break; 

I don't think -verify should be making ad-hoc checks about debug intrinsics,
because it places too high a burden on optimisation passes to make sure they
don't break these checks. So I would vote for removing that check.


-- 
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