[LLVMdev] moving from llvm 2.6 -> 2.7

aparna kotha kotha.aparna at gmail.com
Wed Sep 15 18:11:40 PDT 2010


Hi All,

We have this piece of code in our system , where we are iteratively remove
functions that were unreachable in the cfg.

In llvm-2.6 func->eraseFromParent() worked but now we want to move to
llvm-2.7 we get a the following assert.

An asserting value handle still pointed to this value!
UNREACHABLE executed at llvm-2.7/lib/VMCore/Value.cpp:
522!

CODE
-----------------------------------------------------------------------------------------------------------------------------------------------
for (uriter = unreachables.begin(); uriter != unreachables.end(); uriter++)
    {
        Function* func = *uriter;

        // make sure that the use is within one of the functions
        // we're going to remove.

        for (Value::use_iterator iter = func->use_begin(); iter !=
func->use_end(); iter++)
        {
            CallInst* pCall = dyn_cast<CallInst>(*iter);
            assert(pCall != NULL);
            Function* callerFunc = pCall->getParent()->getParent();
            assert(unreachables.find(callerFunc) != unreachables.end());
        }
        func->replaceAllUsesWith(UndefValue::get(func->getType()));

        func->eraseFromParent();

    }
---------------------------------------------------------------------------------------------------------------------------------------------------


I am unable to figure out why we see this. Any pointers would be great.




Aparna

Graduate Student , ECE
University of Maryland, College Park
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100915/63d44b58/attachment.html>


More information about the llvm-dev mailing list