Verifier Error

Hi,
I tried creating intrinsics which
are to be placeholders for a set of instructions
which
should not be executed by the backend.

I get the following verifier error.

The "indvar.next4" instruction being mentioned in the
step wise debug is
not present in the LLVM IR (i.e IR before application
of my transformation Pass).

As seen below the operands of this instructions
causing the segfault are NULL
pointers. I am quite puzzled where this error is
coming from and would
be thankful for any hints in this regard.

Aditya

P.S :

Error:

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1076469152 (LWP 31487)]
0x0861bf59 in llvm::PATypeHolder::get (this=0x8) at
Type.cpp:46
46 const Type *NewTy = Ty->getForwardedType();

(gdb) bt
#0 0x0861bf59 in llvm::PATypeHolder::get (this=0x8)
at Type.cpp:46
#1 0x0837cac5 in llvm::PATypeHolder::operator
llvm::Type* (this=0x8)
at
/work/aditya/llvm-2.2/include/llvm/AbstractTypeUser.h:149

#2 0x0837cadc in llvm::Value::getType (this=0x0)
at /work/aditya/llvm-2.2/include/llvm/Value.h:87

#3 0x08637b52 in (anonymous
namespace)::Verifier::visitBinaryOperator
(this=0x8794f18, B=@0x87994a8) at Verifier.cpp:905

#4 0x0863d81e in llvm::InstVisitor<(anonymous
namespace)::Verifier,
>::visitAdd (this=0x8794f18, I=@0x87994a8)
at
/work/aditya/llvm-2.2/include/llvm/Instruction.def:107

#5 0x0863de16 in llvm::InstVisitor<(anonymous
namespace)::Verifier,
>::visit (this=0x8794f18, I=@0x87994a8)
at
/work/aditya/llvm-2.2/include/llvm/Instruction.def:107

#6 0x0863e229 in llvm::InstVisitor<(anonymous
namespace)::Verifier,
>::visit<llvm::ilist_iterator<llvm::Instruction>
(this=0x8794f18,
Start=
{<bidirectional_iterator<llvm::Instruction,int>> = {<>
= {<No data
>}, <No data fields>}, NodePtr = 0x877fdd0},
End=
{<bidirectional_iterator<llvm::Instruction,int>> = {<>
= {<No data
>}, <No data fields>}, NodePtr = 0x8780030})
at
/work/aditya/llvm-2.2/include/llvm/Support/InstVisitor.h:92

#7 0x0863e2a0 in llvm::InstVisitor<(anonymous
namespace)::Verifier,
>::visit (this=0x8794f18, BB=@0x877cc28)
at
/work/aditya/llvm-2.2/include/llvm/Support/InstVisitor.h:107

#8 0x0863e2eb in llvm::InstVisitor<(anonymous
namespace)::Verifier,
>::visit<llvm::ilist_iterator<llvm::BasicBlock> >
(this=0x8794f18,
Start=
{<bidirectional_iterator<llvm::BasicBlock,int>> = {<>
= {<No data
>}, <No data fields>}, NodePtr = 0x877cc50},
End=
       {<bidirectional_iterator<llvm::BasicBlock,int>>
= {<> = {<No data
>}, <No data fields>}, NodePtr = 0x877c9a8})
at
/work/aditya/llvm-2.2/include/llvm/Support/InstVisitor.h:92

#9 0x0863e508 in llvm::InstVisitor<(anonymous
namespace)::Verifier,
>::visit (this=0x8794f18, F=@0x8777980)
at
/work/aditya/llvm-2.2/include/llvm/Support/InstVisitor.h:103

#10 0x0863e557 in (anonymous
namespace)::Verifier::runOnFunction
(this=0x8794f18, F=@0x8777980) at Verifier.cpp:155
#11 0x0860e6ea in llvm::FPPassManager::runOnFunction
(this=0x8793ca8,
F=@0x8777980) at PassManager.cpp:1171
#12 0x0860e896 in llvm::FPPassManager::runOnModule
(this=0x8793ca8,
M=@0x8773d10) at PassManager.cpp:1191
#13 0x0860e3ba in llvm::MPPassManager::runOnModule
(this=0x87731d8,
M=@0x8773d10) at PassManager.cpp:1240
#14 0x0860e570 in llvm::PassManagerImpl::run
(this=0x87766b8, M=@0x8773d10)
at PassManager.cpp:1313
#15 0x0860e5c2 in llvm::PassManager::run
(this=0xbfaeecf8, M=@0x8773d10) at
PassManager.cpp:1345
#16 0x0836680d in main (argc=13, argv=0xbfaeeee4) at
opt.cpp:426

When I tried debugging stepwise

Error:

Breakpoint 1, (anonymous
namespace)::Verifier::visitBinaryOperator
(this=0x8794f08, B=@0x87996a8) at Verifier.cpp:905

905 Assert1(B.getOperand(0)->getType() ==
B.getOperand(1)->getType(),
1: B.getName () = {static npos = 4294967295,
_M_dataplus =
{<std::allocator<char>> =
{<__gnu_cxx::new_allocator<char>> = {<No data
>}, <No data fields>}, _M_p = 0x879bfdc
"indvar.next4"}}

(gdb) print B->getParent()->getName()
Attempt to take contents of a non-pointer value.

(gdb) print B->getParent()
Attempt to take contents of a non-pointer value.

(gdb) print B.getOperand(0)
$25 = (class llvm::Value *) 0x0

(gdb) print B.getOperand(1)
$26 = (class llvm::Value *) 0x0