search for: arg_alloc

Displaying 1 result from an estimated 1 matches for "arg_alloc".

2015 Jan 27
2
[LLVMdev] Create a call to function malloc using LLVM API
...d an issue when attempting to create a call to function malloc. I just want to do a simple thing, suppose there is a variable p, if p is a pointer then allocate memory to p. Source code: int *p; p = (int *) malloc(sizeof(*p)); Try to generate LLVM IR for it: Type *tp = p->getType(); AllocaInst* arg_alloc = builder.CreateAlloca(tp);//builder is IRBuilder if(tp->isPointerTy()){ Type* tpp = tp->getPointerElementType(); Type* ITy = Type::getInt32Ty(getGlobalContext()); Constant* AllocSize = ConstantExpr::getSizeOf(tpp) AllocSize = ConstantExpr::getTruncOrBitCast(AllocSize, ITy); C...