about creating the first value of the storeinst

Dear All

I’m trying to create storeInst using

StoreInst *SI = new StoreInst(val, AI, BB);

AI is an alloca instruction previously created, BB is the basicBlock I want to put instructionsi in. Val is the value to store.

I’ve created val from a genericValue like this:

Value* val = ConstantInt::get(getGlobalContext(), Result.IntVal);

Result is the genericValue

However I keep getting this error:

void llvm::StoreInst::AssertOK(): Assertion `getOperand(0)->getType() == cast(getOperand(1)->getType())->getElementType() && “Ptr must be a pointer to Val type!”’ failed.

What is wrong about my code?

Thanks a million in advance.

Regards,
Marwa Yusuf
Teaching Assistant - Computer Engineering Department
Faculty of Engineering - Benha University
E-JUST MSc Student
Computer Science & Engineering Dept.

It worked. I managed finally to create the StoreInst.

The problem was in AllocaInst from the start. I was passing a wrong type for CreateAlloca function so it was generating a wrong pointer.

Regards,
Marwa Yusuf
Teaching Assistant - Computer Engineering Department
Faculty of Engineering - Benha University
E-JUST MSc Student
Computer Science & Engineering Dept.