search for: getpointerelementtyp

Displaying 10 results from an estimated 10 matches for "getpointerelementtyp".

Did you mean: getpointerelementtype
2014 Nov 05
3
[LLVMdev] How to lower the intrinsic function 'llvm.objectsize'?
...lse);) { IntrinsicInst *ii = dyn_cast<IntrinsicInst>(&*i); ++i; if(ii) { switch (ii->getIntrinsicID()) { case Intrinsic::objectsize: { IRBuilder<> builder(ii->getParent(), ii); Value *op1 = ii->getArgOperand(0); //i8* uint64_t bit_size = op1->getType()->getPointerElementType()->getPrimitiveSizeInBits(); Value *result = ConstantInt::get(ii->getType(), bit_size); ii->replaceAllUsesWith(result); ii->removeFromParent(); delete ii; break; } } } I'm new to LLVM and not sure whether the implementation is correct. Can anybody tell me whether...
2019 Dec 18
5
RFC: Opaque pointer status and future direction
Hi all, At the dev meeting I promised to update everyone on where my work with opaque pointers is right now. It's taken me a while, but at least it's the same year! Current Status ============== I've put two branches up at https://github.com/TNorthover/llvm-project: "opaque-ptr" which has most of the real work so far; and "opaque-ptr-always" that additionally has
2014 Nov 05
3
[LLVMdev] How to lower the intrinsic function 'llvm.objectsize'?
...ast<IntrinsicInst>(&*i); > ++i; > if(ii) { > switch (ii->getIntrinsicID()) { > case Intrinsic::objectsize: { > IRBuilder<> builder(ii->getParent(), ii); > Value *op1 = ii->getArgOperand(0); //i8* > uint64_t bit_size = op1->getType()->getPointerElementType()->getPrimitiveSizeInBits(); > > First, you can't always determine the size. Just looking at the pointer > element type isn't enough. This requires finding the object definition, > which can fail, and the existing handling uses llvm::getObjectSize to for. > In general w...
2015 Jan 27
2
[LLVMdev] Create a call to function malloc using LLVM API
...re 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); CallInst::CreateMalloc(arg_alloc, ITy, tpp, AllocSize); } But the generated LLVM IR seems incorrect: %malloccall = tail c...
2019 Dec 17
2
Using "opaque pointers" right now?
> pointers. If you're writing a front-end this probably means you need > to keep your AST's representation of element types alongside LLVM > pointer Values in your own data-structures Yeah, that’s no problem - the type is needed for signed/unsigned integer distinctions anyway. There’s no getting around having one’s own type hierarchy. >> And also - is it possible to use
2018 Jan 31
4
llvm.memcpy for struct copy
Hi Ma, how can I transform the llvm.memcpy into data move loop IR and eliminate > the bitcast instruction ? > I'm not sure why you are concerned about memcpy and bitcasts, but if you call MCpyInst->getSource() and MCpyInst->getDest() it will look through casts and give you the 'true' source/destination. If you want to get rid of memcpy altogether, you can take a look
2014 Aug 20
2
[LLVMdev] LLVM CreateStructGEP type assert error
cB->getType()->getPointerElementType()->dump(); gives: %struct.RB = type opaque2189 x_idx = builder.CreateStructGEP(cB, 0); cB->dump() gives: %struct.RB addrspace(1)* %cB $1 = void //To undo confusion, the last cB is the function arg name. For this example I unfortunately chose the same name for my argument Value* as...
2014 Aug 20
2
[LLVMdev] LLVM CreateStructGEP type assert error
..._____________ From: Tom Stellard [tom at stellard.net] Sent: Wednesday, August 20, 2014 3:43 PM To: Lowell, Daniel Cc: llvmdev at cs.uiuc.edu Subject: Re: [LLVMdev] LLVM CreateStructGEP type assert error On Wed, Aug 20, 2014 at 08:12:58PM +0000, Lowell, Daniel wrote: > > cB->getType()->getPointerElementType()->dump(); > > > gives: > > %struct.RB = type opaque2189 x_idx = builder.CreateStructGEP(cB, 0); > Ok, sorry. I thought that would dump the full struct type. Can you dump the struct as it is defined in LLVM IR, usually if you dump the whole module, this will be at...
2014 Aug 20
2
[LLVMdev] LLVM CreateStructGEP type assert error
...t stellard.net] > Sent: Wednesday, August 20, 2014 3:43 PM > To: Lowell, Daniel > Cc: llvmdev at cs.uiuc.edu > Subject: Re: [LLVMdev] LLVM CreateStructGEP type assert error > > On Wed, Aug 20, 2014 at 08:12:58PM +0000, Lowell, Daniel wrote: > > > > cB->getType()->getPointerElementType()->dump(); > > > > > > gives: > > > > %struct.RB = type opaque2189 x_idx = builder.CreateStructGEP(cB, 0); > > > > Ok, sorry. I thought that would dump the full struct type. Can you dump the > struct as it is defined in LLVM IR, usually if...
2014 Aug 20
2
[LLVMdev] LLVM CreateStructGEP type assert error
Hi all, Running LLVM 3.4 to create a custom pass for OpenCL transformations. I am attempting to GEP into a struct using IRBuilder's CreateStructGEP, but I keep getting this assert: aoc: ../../../../../../compiler/llvm/include/llvm/Instructions.h:703: llvm::Type* llvm::checkGEPType(llvm::Type*): Assertion `Ty && "Invalid GetElementPtrInst indices for type!"' failed.