search for: getallocatedtyp

Displaying 20 results from an estimated 24 matches for "getallocatedtyp".

Did you mean: getallocatedtype
2008 Apr 21
2
[LLVMdev] newbie question for type comparison
...g dumps: >> > I'm not sure why the above doesn't work. My best guess is that the > allocated type is not an operand (since it is not an LLVM Value) but > is > an attribute (for lack of a better word) of the alloca instruction. Correct. > My suggestion is to use the getAllocatedType() method of the > AllocaInst > class. I'm pretty sure it does what you want: > > if (AI->getAllocatedType()->getTypeID() == Type::StructTyID) > Better: if (isa<StructType>) or if (StructType *sT = dyn_cast<StructType>). — Gordon
2010 Jul 21
1
[LLVMdev] How to recognize pointer variable & ordinary variable
...& pointer variables. Let's have a program, int a,b,c,*ptr; I want to extract only the local variables. That's what my question was. I think it is clear now. cast<PointerType>(A->getType() > > )->getElementType() is not working. I am also getting error with > A->getAllocatedType(). > On 22 July 2010 01:01, Duncan Sands <baldrick at free.fr> wrote: > Hi Soumya_Prasad_Ukil, > > > How to recognize pointer variable & ordinary variable? I have tried with > > "isa<PointerType>(V->getType())", but failed. > > I'm no...
2008 Apr 21
0
[LLVMdev] newbie question for type comparison
...b session, I've got the following dumps: > I'm not sure why the above doesn't work. My best guess is that the allocated type is not an operand (since it is not an LLVM Value) but is an attribute (for lack of a better word) of the alloca instruction. My suggestion is to use the getAllocatedType() method of the AllocaInst class. I'm pretty sure it does what you want: if (AI->getAllocatedType()->getTypeID() == Type::StructTyID) > (gdb) call AI->dump() > %s = alloca %struct.S ; <%struct.S*> [#uses=4] > (gdb) call AI->getOperand(0)->du...
2010 Jul 21
2
[LLVMdev] How to recognize pointer variable & ordinary variable
How to recognize pointer variable & ordinary variable? I have tried with "isa<PointerType>(V->getType())", but failed. -- regards, soumya prasad ukil -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100722/8a751551/attachment.html>
2010 Jul 21
0
[LLVMdev] How to recognize pointer variable & ordinary variable
...How to recognize pointer variable & ordinary variable? I have tried with > "isa<PointerType>(V->getType())", but failed. I'm not sure what you are asking, but if you are asking whether an alloca instruction A represents local memory of pointer type, you can use A->getAllocatedType(). You can also use cast<PointerType>(A->getType())->getElementType(). The reason that an alloca instruction always has pointer type is that the instruction represents a pointer to the allocated memory. Ciao, Duncan.
2008 Apr 21
0
[LLVMdev] newbie question for type comparison
...bove doesn't work. My best guess is that the >> allocated type is not an operand (since it is not an LLVM Value) but >> is >> an attribute (for lack of a better word) of the alloca instruction. >> > > Correct. > > >> My suggestion is to use the getAllocatedType() method of the >> AllocaInst >> class. I'm pretty sure it does what you want: >> >> if (AI->getAllocatedType()->getTypeID() == Type::StructTyID) >> >> > > Better: if (isa<StructType>) or if (StructType *sT = > dyn_cast<StructTy...
2008 Apr 21
3
[LLVMdev] newbie question for type comparison
Hi John, Thank you a lot. That clarifies some my confusions. What I want to do is to use both methods, get ALL struct allocation and a SPECIFIC struct allocation, at different situations. Here, I've got a couple of more questions. 1. For getting ALL struct allocation, when I use if( (AI = dyn_cast<AllocaInst>(&*i)))
2013 Sep 01
2
[LLVMdev] Distinguishing Pointer Variable and Ordinary Variable
Sorry I have actually edited the post. I did check its type by using isa<PointerType>(cast<AllocaInst>(instr->getOperand(1))->getAllocatedType()) but it is only detecting i32** %b on line 8 of IR as a pointer type. Whereas I also want to detect the i32* %1 on line 11 of IR as a pointer type. So how can I do this?? -- View this message in context: http://llvm.1065342.n5.nabble.com/Distinguishing-Pointer-type-variable-and-Ordinary-V...
2002 Nov 27
1
[LLVMdev] Instruciton replacement
llvm is giving me some assertion errors when trying to replace an instruction, and I'm not quite sure of what to do. I have the following snippet of code: switch((*I)->getOpcode()) { case Instruction::Malloc: { AllocaInst *AI; AI = new AllocaInst(cast<AllocationInst>(*I)->getAllocatedType(), cast<AllocationInst>(*I)->getArraySize()); (*I)->replaceAllUsesWith(AI); // (*I)->dropAllReferences(); // (*I)->getParent()->getInstList().erase(*I); // delete (*I); // delete(AI); } break; running the code will report: Leaked objects found: after running p...
2010 May 28
0
[LLVMdev] Retrieving Underlying Type from AllocaInst
...a member function of the alloca that would return the > original type that was passed to CreateAlloca. I can test for a > PointerTyID and then perform a cast to PointerType and then call the > getElementType() function on the PointerType but that seems a bit messy. There's alloca->getAllocatedType() which merely calls getType()->getElementType() for you. http://llvm.org/doxygen/classllvm_1_1AllocaInst.html . Nick
2010 May 28
2
[LLVMdev] Retrieving Underlying Type from AllocaInst
...the alloca that would return the >> original type that was passed to CreateAlloca. I can test for a >> PointerTyID and then perform a cast to PointerType and then call the >> getElementType() function on the PointerType but that seems a bit messy. > > There's alloca->getAllocatedType() which merely calls getType()->getElementType() for you. > > http://llvm.org/doxygen/classllvm_1_1AllocaInst.html . > > Nick -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100528/ca979cd8...
2010 May 28
2
[LLVMdev] Retrieving Underlying Type from AllocaInst
Is there a recommended way to retrieve the original type from an AllocaInst object? For example, I am creating alloca instructions using the IRBuilder interface like: alloca = builder.CreateAlloca( Type::getDoubleTy( context ), 0, variableName.c_str() ); and I place the alloca into a symbol table. Later when I am generating instructions for an assignment operation, I want to check the type of
2010 May 28
0
[LLVMdev] Retrieving Underlying Type from AllocaInst
...e alloca that would return the > > original type that was passed to CreateAlloca. I can test for a > > PointerTyID and then perform a cast to PointerType and then call the > > getElementType() function on the PointerType but that seems a bit messy. > > There's alloca->getAllocatedType() which merely calls > getType()->getElementType() for you. > > http://llvm.org/doxygen/classllvm_1_1AllocaInst.html . > > Nick > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc...
2012 Feb 15
2
[LLVMdev] Wrong AliasAnalysis::getModRefInfo result
...getArgOperand(i); if (GetElementPtrInst *vi = dyn_cast<GetElementPtrInst>(v)){ Value *vPtr = vi->getPointerOperand(); vPtr->dump(); if ( AllocaInst *allo = dyn_cast<AllocaInst>(vPtr) ) { const Type *t = allo->getAllocatedType(); if ( const ArrayType *at = dyn_cast<ArrayType>(t) ) { int64_t size = at->getNumElements() * at->getElementType()->getPrimitiveSizeInBits() / 8; ImmutableCallSite cs(ci); AliasAnalysis::Location loc(v, size);...
2013 Sep 01
0
[LLVMdev] Distinguishing Pointer Variable and Ordinary Variable
Check it's type to see if it's a pointer or not? On 1 September 2013 12:31, Abhinash Jain <omnia at mailinator.com> wrote: > C Code :- > int main() > { > int a=10,c; > int *b; > c=20; > *b=a; > return 0; > } > > IR of above code :- > define i32 @main() #0 { > entry: > 1. %retval = alloca i32, align 4 > 2. %a = alloca i32, align 4
2013 Sep 01
0
[LLVMdev] Distinguishing Pointer Variable and Ordinary Variable
...mnia at mailinator.com> wrote: > Sorry I have actually edited the post. This is primarily an e-mail list; the vast majority of us won't see any edits (on some web mirror?). > I did check its type by using > isa<PointerType>(cast<AllocaInst>(instr->getOperand(1))->getAllocatedType()) > but it is only detecting i32** %b on line 8 of IR as a pointer type. Not all pointers will come (directly or indirectly) from an AllocaInst. You might just want isa<PointerType>(instr->getOperand(1)->getType()), though of course that'll be true for any memory operand of a...
2002 Sep 28
0
[LLVMdev] Re: an error
....uiuc.edu/~vadve > From: Jianzhong Liu <jliu7 at uiuc.edu> > Sender: jliu7 at cs.uiuc.edu > Date: Sat, 28 Sep 2002 17:00:04 -0500 > Subject: an error > > I keep getting a core dump error for: > > ... > const Type *opType = (dyn_cast<AllocationInst>(i))->getAllocatedType(); > if(isa<StructType>(opType) == false) > return false; > ... > > > i is a Instruction* type. In fact it's a malloc or alloca instruction. I > want to determine if its operand is a structure. Thanks! > > Jianzhong > > > >
2012 Sep 21
0
[LLVMdev] How To Get The Name of the type the popinter is pointing to
i am using llvm , i did this if ( AllocaInst *allocInst = dyn_cast<AllocaInst>(&*bbit)){ PointerType *p = allocInst->getType(); if ( p->getElementType()->isPointerTy()){ StringRef name = allocInst->getName();
2013 Sep 01
2
[LLVMdev] Distinguishing Pointer Variable and Ordinary Variable
C Code :- int main() { int a=10,c; int *b; c=20; *b=a; return 0; } IR of above code :- define i32 @main() #0 { entry: 1. %retval = alloca i32, align 4 2. %a = alloca i32, align 4 3. %c = alloca i32, align 4 4. %b = alloca i32*, align 8 5. store i32 0, i32* %retval 6. store i32 10, i32* %a, align 4 7. store i32 20, i32* %c, align 4 8. %0 = load i32* %a, align 4 9. %1 = load i32** %b,
2016 Jun 28
0
mutateType on AllocaInst problem
...n be called in a correctly typed way - replace all uses of the old allocation to the new one (not necessary too) Here's the associated code running on each alloca instructions from each function given to the function pass: void __replace_alloca_vector_IRBuilder(AllocaInst *AI) { if(AI->getAllocatedType()->isPointerTy()){ LLVMContext *Context = &(AI->getContext()); IRBuilder<> IRB(*Context); VectorType *FDP_fatvector = VectorType::get( PointerType::getInt8PtrTy(*Context), 3 ); // two different ways depending on wether to create and insert or just...