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

Stephen McGruer stephen.mcgruer at gmail.com
Thu Dec 20 05:33:38 PST 2012


Ah, sorry, I failed to pay attention to the protection level.

Your way should work, although you could also consider checking if
BB->begin() points to the same thing as BB->getTerminator() - if so, the
terminator instruction is the first instruction (if you want to ignore PHI
nodes for this case, could compare BB->getFirstNonPHI() to
BB->getTerminator().) Personal choice really, I think.

Stephen


On 20 December 2012 12:16, Alexandru Ionut Diaconescu <
alexandruionutdiaconescu at gmail.com> wrote:

> I solved by checking
>
> if(BB->size()>1)
>
> Thank you all for the help !
>
> Now debugging the next segfault.
>
>
> On Thu, Dec 20, 2012 at 12:59 PM, Alexandru Ionut Diaconescu <
> alexandruionutdiaconescu at gmail.com> wrote:
>
>> getPrevNode<http://llvm.org/docs/doxygen/html/classllvm_1_1ilist__node.html#a77b897207ef0a1ae95c404695aed9a4b>()
>>  Get the previous node, or 0 for the list head. I don't see any method
>> like hasPrevNode.
>> It can be a weird problem because "current->getPrevNode()" is indicating
>> to "current" itself (the problem appears for the BB with only one element)?
>>
>>
>>
>>
>>
>> On Thu, Dec 20, 2012 at 12:42 PM, Alexandru Ionut Diaconescu <
>> alexandruionutdiaconescu at gmail.com> wrote:
>>
>>> Hello,
>>>
>>> Thank you for your answer. If I want to use
>>>
>>> then I have
>>>
>>> error: ‘NodeTy* llvm::ilist_half_node<NodeTy>::getPrev() [with NodeTy =
>>> llvm::Instruction]’ is protected
>>> error: ‘llvm::ilist_half_node<llvm::Instruction>’ is not an accessible
>>> base of ‘llvm::Instruction’
>>>
>>> Do you know any other method to access the previous instruction of a
>>> terminator instruction? PS: back() is not an option.
>>>
>>> On Thu, Dec 20, 2012 at 12:06 PM, Stephen McGruer <
>>> stephen.mcgruer at gmail.com> wrote:
>>>
>>>> current->getPrev()
>>>
>>>
>>>
>>>
>>> --
>>> Best regards,
>>> Alexandru Ionut Diaconescu
>>>
>>
>>
>>
>> --
>> Best regards,
>> Alexandru Ionut Diaconescu
>>
>
>
>
> --
> Best regards,
> Alexandru Ionut Diaconescu
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20121220/5082662d/attachment.html>


More information about the llvm-dev mailing list