[LLVMdev] LLVM segmentation fault / need use Instruction instead of Instruction*

Alexandru Ionut Diaconescu alexandruionutdiaconescu at gmail.com
Wed Dec 19 08:19:05 PST 2012


Hello everyone,

I have a segmentation fault while running an LLVM pass. I need to use
BBterminators array outside the iterating "for" loop for basic blocks. It
seems that LLVM does not protect the addresses ( note: TerminatorInst
*BasicBlock::getTerminator() ) when iterating through the loop, so I need
to keep in BBterminators "Instruction" type elements, not "Instruction* ".
How can I copy entire Instructions into BBterminators?


    for (Function::iterator II = F.begin(), EE = F.end(); II != EE; ++II,
++ii)
{
     ....... // not relevant code  ;

    BasicBlock* BB=(dyn_cast<BasicBlock>(II));

    if (BB->getTerminator())
    {
        Instruction* current = BB->getTerminator();

        Instruction* previous = current->getPrevNode();

        if (current->getOpcode()==Instruction::Br)
        {

            BBterminators[ii]=current;
...// not relevant code

where Instruction** BBterminators = new Instruction*[100];

Thank you a lot !
Alex


-- 
Best regards,
Alexandru Ionut Diaconescu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20121219/99ccf5e4/attachment.html>


More information about the llvm-dev mailing list