[LLVMbugs] [Bug 5338] New: CloneFunctionInto() fails on function declaration

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Wed Oct 28 18:40:31 PDT 2009


           Summary: CloneFunctionInto() fails on function declaration
           Product: libraries
           Version: 2.6
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: minor
          Priority: P2
         Component: Transformation Utilities
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: markleone at gmail.com
                CC: llvmbugs at cs.uiuc.edu

CloneFunctionInto() tickles an assert failure when it's used to clone a
function declaration:

Assertion failed: (Traits::getNext(NodePtr) != 0 && "Dereferencing end()!"),
function operator typename bidirectional_iterator<NodeTy, ptrdiff_t>::pointer,
file /Users/mleone/Pkgs/llvm-2.6/include/llvm/ADT/ilist.h, line 192.

 in llvm::ilist_iterator<llvm::BasicBlock const>::operator llvm::BasicBlock
const* at ilist.h:192
 in llvm::CloneFunctionInto at CloneFunction.cpp:125
 in llvm::CloneFunction at CloneFunction.cpp:170
 in llvm::CloneFunction at Transforms/Utils/Cloning.h:129

It looks like the last loop needs to be guarded with
"!OldFunc->isDeclaration()", otherwise the begin() iterator is dereferenced:

  for (Function::iterator BB = cast<BasicBlock>(ValueMap[OldFunc->begin()]),
         BE = NewFunc->end(); BB != BE; ++BB)
    // Loop over all instructions, fixing each one as we find it...
    for (BasicBlock::iterator II = BB->begin(); II != BB->end(); ++II)
      RemapInstruction(II, ValueMap);

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