Constant *strcon==ConstantArray::get("Value : %d\n"); Sorry Typo. On Tue, 21 Dec 2004, Misha Brukman wrote:> On Tue, Dec 21, 2004 at 03:45:33PM -0700, Sriraman Tallam wrote: > > I have this call instruction to printf inserted which is causing > > an assertion failure. Any pointers to where I am wrong : > > > > Function *printFn=M.getNamedFunction(std::string("printf")); > > std::string() is unnecessary here as it's implicit. > > > Constant *str=ConstantArray::get("Value : %d\n"); > > std::vector<Value *> Args(2); > > std::vector<Constant *> GEPIndices(2); > > GEPIndices[0]=Constant::getNullValue(Type::LongTy); > > GEPIndices[1]=Constant::getNullValue(Type::LongTy); > > Args[0]=ConstantExpr::getGetElementPtr(strcon,GEPIndices); > > You are using 'strcon', but you defined 'str' above. Where is 'strcon' > coming from? > > > Args[1]=ConstantInt::get(Type::IntTy, id); > > Instruction * cI= new CallInst(printFn, Args, "retprintf",instr); > > -- > Misha Brukman :: http://misha.brukman.net :: http://llvm.cs.uiuc.edu > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://mail.cs.uiuc.edu/mailman/listinfo/llvmdev >
On Tue, Dec 21, 2004 at 03:53:47PM -0700, Sriraman Tallam wrote:> Constant *strcon==ConstantArray::get("Value : %d\n");OK, then what's the assertion? You can also see the resulting module by using -disable-verify: $ opt -yourpass -disable-verify < file.bc | llvm-dis You may see what the problem is by looking at the LLVM assembly. -- Misha Brukman :: http://misha.brukman.net :: http://llvm.cs.uiuc.edu
I have a feeling that my getElementPtr is wrongly framed. Thanks. On Tue, 21 Dec 2004, Sriraman Tallam wrote:> Constant *strcon==ConstantArray::get("Value : %d\n"); > > Sorry Typo. > > On Tue, 21 Dec 2004, Misha Brukman wrote: > > > On Tue, Dec 21, 2004 at 03:45:33PM -0700, Sriraman Tallam wrote: > > > I have this call instruction to printf inserted which is causing > > > an assertion failure. Any pointers to where I am wrong : > > > > > > Function *printFn=M.getNamedFunction(std::string("printf")); > > > > std::string() is unnecessary here as it's implicit. > > > > > Constant *str=ConstantArray::get("Value : %d\n"); > > > std::vector<Value *> Args(2); > > > std::vector<Constant *> GEPIndices(2); > > > GEPIndices[0]=Constant::getNullValue(Type::LongTy); > > > GEPIndices[1]=Constant::getNullValue(Type::LongTy); > > > Args[0]=ConstantExpr::getGetElementPtr(strcon,GEPIndices); > > > > You are using 'strcon', but you defined 'str' above. Where is 'strcon' > > coming from? > > > > > Args[1]=ConstantInt::get(Type::IntTy, id); > > > Instruction * cI= new CallInst(printFn, Args, "retprintf",instr); > > > > -- > > Misha Brukman :: http://misha.brukman.net :: http://llvm.cs.uiuc.edu > > > > _______________________________________________ > > LLVM Developers mailing list > > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > > http://mail.cs.uiuc.edu/mailman/listinfo/llvmdev > > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://mail.cs.uiuc.edu/mailman/listinfo/llvmdev >
opt: Constants.cpp:1142: static llvm::Constant* llvm::ConstantExpr::getGetElementPtr(llvm::Constant*, const std::vector<llvm::Constant*, std::allocator<llvm::Constant*> >&): Assertion `Ty && "GEP indices invalid!"' failed. This is the llvm gcc error. I'll try the disable-verify option. Thanks. On Tue, 21 Dec 2004, Misha Brukman wrote:> On Tue, Dec 21, 2004 at 03:53:47PM -0700, Sriraman Tallam wrote: > > Constant *strcon==ConstantArray::get("Value : %d\n"); > > OK, then what's the assertion? > > You can also see the resulting module by using -disable-verify: > > $ opt -yourpass -disable-verify < file.bc | llvm-dis > > You may see what the problem is by looking at the LLVM assembly. > > -- > Misha Brukman :: http://misha.brukman.net :: http://llvm.cs.uiuc.edu > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://mail.cs.uiuc.edu/mailman/listinfo/llvmdev >