[LLVMdev] LLVM segmentation fault / need use Instruction instead of Instruction*
Stephen McGruer
stephen.mcgruer at gmail.com
Thu Dec 20 03:06:18 PST 2012
I may be mistaken as I just took a quick look, but in ilist_node the
function "getPrevNode()" actually calls a method on the previous node:
NodeTy *getPrevNode() {
NodeTy *Prev = this->getPrev();
// Check for sentinel.
if (!Prev->getNext())
return 0;
return Prev;
}
http://llvm.org/docs/doxygen/html/ilist__node_8h_source.html#l00058
Try checking if current->getPrev() is null before calling
current->getPrevNode().
Stephen
On 20 December 2012 10:42, Alexandru Ionut Diaconescu <
alexandruionutdiaconescu at gmail.com> wrote:
> Hello John,
>
> I was following your procedures and I isolated the problem. The problem
> are represented by the basic blocks with only one element.
>
>
> for (Function::iterator II = F.begin(), EE = F.end(); II != EE; ++II,
> ++ii)
> {
> BasicBlock* BB=II;
>
>
> if (BB->getTerminator())
> {
> Instruction* current = BB->getTerminator();
>
> Instruction* previous;
>
> errs()<<"AAA\n";
> if(*current->getPrevNode()*)
> {
> errs()<<"BBB\n";
> previous = current->getPrevNode();
> ok=1;
> }
>
> if (ok){
> errs()<<"CCC\n";
> ........
>
>
> It does print AAA, but then I have the segfault. So when I am evaluating
> the *current->getPrevNode() *condition, I got the segfault.
> Do you know how can I solve this?
>
> Thank you
> Alex
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20121220/a2ce2291/attachment.html>
More information about the llvm-dev
mailing list