[LLVMdev] LLVM AllocaInst and StoreInst
Prakash Premkumar
prakash.prax at gmail.com
Mon Aug 4 05:18:54 PDT 2014
Hi,
I am trying to write a simple interpreter.
I am trying to generate LLVM IR for assignment operation. The code for the
generation part looks like this
llvm::Value* codeGenSymTab(llvm::LLVMContext& context) {
> printf("\n CodeGen SymTab \n");
> Value *num = ConstantInt::get(Type::getInt64Ty(context), aTable.value,
> true);
> Value *alloc = new AllocaInst(IntegerType::get(context, 32),
> aTable.variableName,entry);
> StoreInst *ptr = new StoreInst(num,alloc,false,entry);
> }
Here goes the SymTab definition:
struct SymTab {
char* variableName;
int value;
llvm::Value* (*codeGen)(llvm::LLVMContext& context);
};
When I try to execute the output file,I get the following error:
Assertion failed: (getOperand(0)->getType() ==
> cast<PointerType>(getOperand(1)->getType())->getElementType() && "Ptr must
> be a pointer to Val type!"), function AssertOK, file Instructions.cpp, line
> 1084.
> Abort trap: 6
Can you help me resolve it ?
Thanks
Prakash
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140804/a7b13602/attachment.html>
More information about the llvm-dev
mailing list