search for: getelementptrinst

Displaying 20 results from an estimated 188 matches for "getelementptrinst".

2008 Apr 09
2
[LLVMdev] Compiling Stacker compiler
...re: static llvm::PointerType* llvm::PointerType::get(const llvm::Type*, unsigned int) StackerCompiler.cpp: In member function 'llvm::Instruction* StackerCompiler::get_stack_pointer(llvm::BasicBlock*, llvm::Value*)': StackerCompiler.cpp:432: error: no matching function for call to 'llvm::GetElementPtrInst::GetElementPtrInst(llvm::GlobalVariable*&, llvm::Value**, size_t)' /opt/src-llvm/include/llvm/Instructions.h:480: note: candidates are: llvm::GetElementPtrInst::GetElementPtrInst(llvm::Value*, llvm::Value*, const std::string&, llvm::BasicBlock*) /opt/src-llvm/include/llvm/Instructions.h...
2016 Aug 31
2
Check if getElementPtr Operand
Thanks Ryan, I'm able to retrieved the type using the following code: Type *type=getElementPtrInst->getSourceElementType(); On Fri, Aug 12, 2016 at 7:00 PM, Ryan Taylor <ryta1203 at gmail.com> wrote: > Take a look at visitGetElementPtrInst in InstructionCombining.cpp for some > examples about how to iterate over GEP and check for type. > > http://llvm.org/docs/doxygen/ht...
2012 Jan 22
2
[LLVMdev] CreateGlobalStringPtr giving linker errors
...defined symbols for architecture x86_64: "llvm::ConstantExpr::getGetElementPtr(llvm::Constant*, llvm::ArrayRef<llvm::Value*>, bool)", referenced from: llvm::ConstantExpr::getInBoundsGetElementPtr(llvm::Constant*, llvm::ArrayRef<llvm::Value*>)in ccFB7xjg.o "llvm::GetElementPtrInst::getIndexedType(llvm::Type*, llvm::ArrayRef<llvm::Value*>)", referenced from: llvm::GetElementPtrInst::GetElementPtrInst(llvm::Value*, llvm::ArrayRef<llvm::Value*>, unsigned int, llvm::Twine const&, llvm::Instruction*)in ccFB7xjg.o "llvm::PointerType::get(llvm::Typ...
2012 Jan 22
0
[LLVMdev] CreateGlobalStringPtr giving linker errors
...tecture x86_64: > "llvm::ConstantExpr::getGetElementPtr(llvm::Constant*, > llvm::ArrayRef<llvm::Value*>, bool)", referenced from: > llvm::ConstantExpr::getInBoundsGetElementPtr(llvm::Constant*, > llvm::ArrayRef<llvm::Value*>)in ccFB7xjg.o > "llvm::GetElementPtrInst::getIndexedType(llvm::Type*, > llvm::ArrayRef<llvm::Value*>)", referenced from: > llvm::GetElementPtrInst::GetElementPtrInst(llvm::Value*, > llvm::ArrayRef<llvm::Value*>, unsigned int, llvm::Twine const&, > llvm::Instruction*)in ccFB7xjg.o > "llvm::P...
2016 Aug 12
2
Check if getElementPtr Operand
Hello, consider the following IR code : %count4 = getelementptr inbounds %struct.r32, %struct.r32* %cur.087, i64 0, i32 4 How to check in the instruction, whether the operand is a structure or not if(isa<GetElementPtrInst>(instruction)) { GetElementPtrInst *getElementPtrInst=dyn_cast<GetElementPtrInst>(&instruction); //check if getElemetPtrInst operands structure or array. } Thank You regards, Bernard Nongpoh -------------- next part -------------- An HTML attachment was scrubbed... URL: <http:/...
2005 Mar 16
2
[LLVMdev] Dynamic Creation of a simple program
...cBlock *BBlock = new BasicBlock("entry", MyFunc); ... Value *Zero = ConstantSInt::get(Type::IntTy, 0); Value *UZero = ConstantUInt::get(Type::UIntTy, 0); MallocInst* mi = new MallocInst( STyStru ); mi->setName("tmp.0"); BBlock->getInstList().push_back( mi ); GetElementPtrInst *m_Next = new GetElementPtrInst(mi, UZero, Zero, "tmp.3", BBlock ); ... ======================== But I tried your code instead of the lines above: GetElementPtrInst *GEP = new GetElementPtrInst(mi, // %tmp.0 ConstantSInt::get(Type::IntTy, 0),...
2012 Dec 02
3
[LLVMdev] GetElementPtrInst question
Hi all, How can I create an llvm::GetElementPtrInst in which the pointer and the index are in registers previously loaded with llvm::LoadInst ? I mean, the generated instruction will be like this: %1 = getelementptr i8* %myreg1, i32 %myreg2 here, %myreg1 and %myreg2 are previously created by load instructions (llvm::LoadInst). Please, let me kn...
2012 Jan 12
1
[LLVMdev] Cast error
...ith LLVM rev - 147926 cast instructions. Here is my code: ............ for(std::vector<Value*>::iterator it = getElementPtrs.begin(); it != getElementPtrs.end(); ++it) { Value* current = *it; errs() << *current << "\n"; GetElementPtrInst* gep = cast<GetElementPtrInst>(current); assert(gep != NULL && "GetElementPtrInst must be valid!"); ............ Program crashes with the above mentioned assertion. Here getElementPtrs is a vector of Values, that are GetElementPtrInst- s. errs() works fine....
2012 Feb 14
1
[LLVMdev] How to get the array size of GetElementPtrInst->getPointerOperand() ?
If I dump the Value of GetElementPtrInst->getPointerOperand(), I got this: %a = alloca [10 x i32], align 16 Obviously, there should be a way to get the dimension and element type via the "Value" returned from GetElementPtrInst->getPointerOperand(), but how? What kind of "Value" is this? Thanks! Welson -----...
2002 Sep 26
1
[LLVMdev] ReplaceUsesWith
When I try to do this: GetElementPtrInst *newIns = new GetElementPtrInst( ... ); OldIns->ReplaceAllUsesWith( newIns ); When I compile the code, it always says, no matching function for call to `GetElementPtrInst::ReplaceAllUsesWith (GetElementPtrInst *&)' But since GetElementPtrInst is a subclass of Value, why cannot use...
2013 Aug 02
1
[LLVMdev] replacing GetElementPtrConstantExpr with GetElementPtrInst ... sometimes
Hi During a pass, the XCore target lowers thread local global variables by turning them into global variable arrays indexed by the (max 8) thread ID. (see XCoreLowerThreadLocal.cpp) This works fine for instructions e.g. GetElementPtrInst But can't be done for constants e.g. GetElementPtrConstantExpr Thus I would like to replace GetElementPtrConstantExpr with GetElementPtrInst when it is accessing a thread local global variable. (Other constant expression ignored for now). My attempt (example code below) has revealed my lack o...
2008 Apr 29
0
[LLVMdev] [PATCH] use-diet for review
...ease avoid this if possible. Why are operand lists stored as templates instead of arrays? "Op<0>" is very strange to me. /// Constructors - These two constructors are convenience methods because one /// and two index getelementptr instructions are so common. static GetElementPtrInst *Create(Value *Ptr, Value *Idx, const std::string &Name = "", Instruction *InsertBefore = 0) { - return new(2/*FIXME*/) GetElementPtrInst(Ptr, Idx, Name, InsertBefore); + return new(2) GetElementPtrInst(Ptr, Idx, Name, InsertBefore);...
2012 Dec 02
0
[LLVMdev] GetElementPtrInst question
...wrong when using the above method. What was it? :) Cheers, James ________________________________________ From: llvmdev-bounces at cs.uiuc.edu [llvmdev-bounces at cs.uiuc.edu] On Behalf Of Eduardo [erocha.ssa at gmail.com] Sent: 02 December 2012 15:37 To: llvmdev at cs.uiuc.edu Subject: [LLVMdev] GetElementPtrInst question Hi all, How can I create an llvm::GetElementPtrInst in which the pointer and the index are in registers previously loaded with llvm::LoadInst ? I mean, the generated instruction will be like this: %1 = getelementptr i8* %myreg1, i32 %myreg2 here, %myreg1 and %myreg2 are previously cr...
2012 Dec 02
1
[LLVMdev] GetElementPtrInst question
Hi James, Thanks for your quick reply. > I assume because you asked this question, something went wrong when using the above method. What was it? :) No, I am not using this method. I was trying to create a llvm::GetElementPtrInst . I didn't create IRBuilder. I am writing a ModulePass that insert new instruction to an existing Module. Besides, how can you get a reference to myreg1 ? Looking at your snippet this variable would be a llvm::Value* (I saw that in the documentation of IRBuilder). All I have in my code is some...
2013 Jan 08
4
[LLVMdev] get ref to parent instruction
...reference to an operand? For example, let suppose I have a reference to the ConstantExpr "getelementptr inbounds" in the following instruction: %4 = getelementptr i32* getelementptr inbounds ([8 x i32]* @__mem_grid_MOD_nnyp, i32 0, i32 0), i32 %3 then, how can I get a reference to the GetElementPtrInst object? The reason I need that is because I want to change every instruction that uses certain variables (in the example above the __mem_grid_MOD_nnyp variable). The problem is that for the example I showed the actual user of the variable is a ConstantExpr object and not the GetElementPtrInst obje...
2007 Aug 17
1
[LLVMdev] Inserting trace information during opt transformations
...tion("mcp_trace_instruction", FT); return true; } then inserting a suitable CallInst instruction new CallInst(TraceFunc, gepinst, "", *wp); Looking at disassembly output from similar code, I can't just pass the constant array directly to the call because I need a GetElementPtrInst conversion. This is the thing I'm having trouble with. My current attempt is: GetElementPtrInst *gepinst = new GetElementPtrInst(itext, ConstantInt::get(Type::Int32Ty, 0), ConstantInt::get(Type::Int32Ty, 0), "", *wp); but it fa...
2015 May 28
1
[LLVMdev] Passing ConstantDataArray to GetElementPtrInst
...13 store [13 x i8] c"Hello world.\00", [13 x i8]* %myString %tmp1 = getelementptr [13 x i8]* %myString, i32 0, i32 0 %tmp2 = call i32 (i8*, ...)* @printf( i8* %tmp1 ) nounwind A simple Hello World example. But I can't seem to figure out what I'm supposed to pass to the GetElementPtrInst. For example, this snippet: std::vector<llvm::Value*> args; auto strValue = llvm::ConstantDataArray::getString(llvm::getGlobalContext(), llvm::StringRef("Hello world.")); std::vector<llvm::Value*> index_vector; index_vector.push_back(Builder.getInt32(0));...
2008 Apr 11
4
[LLVMdev] LLVMBuilder vs LLVMFoldingBuilder
Hi Dominic, +//===-- llvm/Support/IRBuilder.h - Builder for LLVM Instrs -----*- C++ -*-===// is this line the right length? It seems shorter than the similar lines below like this one: +//===----------------------------------------------------------------------===// + GetElementPtrInst *CreateStructGEP(Value *Ptr, unsigned Idx, + const char *Name = "") { + llvm::Value *Idxs[] = { + ConstantInt::get(llvm::Type::Int32Ty, 0), + ConstantInt::get(llvm::Type::Int32Ty, Idx) + }; + return Insert(GetElementPtrInst::Create(P...
2012 Feb 15
2
[LLVMdev] Wrong AliasAnalysis::getModRefInfo result
...nst_begin(F), E = inst_end(F); I != E; ++I) { Instruction *Inst = &*I; if ( CallInst *ci = dyn_cast<CallInst>(Inst) ){ ci->dump(); for(int i = 0; i < ci->getNumArgOperands(); i++){ Value *v = ci->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 Arra...
2008 May 08
0
[LLVMdev] Vector code
...e, label_entry); LoadInst* float_tmp5 = new LoadInst(ptr_y, "tmp5", false, label_entry); BinaryOperator* float_tmp6 = BinaryOperator::create(Instruction::Add, float_tmp2, float_tmp5, "tmp6", label_entry); StoreInst* void_20 = new StoreInst(float_tmp6, ptr_z, false, label_entry); GetElementPtrInst* ptr_tmp10 = new GetElementPtrInst(ptr_x, const_int32_13, "tmp10", label_entry); LoadInst* float_tmp11 = new LoadInst(ptr_tmp10, "tmp11", false, label_entry); GetElementPtrInst* ptr_tmp13 = new GetElementPtrInst(ptr_y, const_int32_13, "tmp13", label_entry); LoadInst* f...