search for: getgetelementptr

Displaying 20 results from an estimated 72 matches for "getgetelementptr".

2015 May 17
2
[LLVMdev] copy value of a global's data field to another global
Hi all, I can get access to the data stored in globals as follows: GlobalVariable* pGvarAct=_set_a_valid_global_; const_ptr_indicesVec=_the_indexes_ llvm::Constant* pConst; pConst=ConstantExpr::getGetElementPtr(pGvarAct, const_ptr_indicesVec); and e.g. use this to repalece an argumrnt of an instruction like: I->setOperand(someArgumentIndex,pConst); However, getGetElementPtr returns a pointerType, which holds the actual type as sub_type. This is a problem when I want to use the data from one global...
2015 May 18
2
[LLVMdev] copy value of a global's data field to another global
...alizer returns the complete initializer of the global. My globals are complex nested structs, from which I want to extract e.g. one double datafield. Example: >From a struct Stuct having double,array(3xint),float fields, I could extract the second int value using the index sequence 0,1,1 with getGetElementPtr. This gives me a constantPointer, but I would need to get a constInt... Alex David Blaikie wrote: > On Sat, May 16, 2015 at 10:28 PM, Alexander Poddey > <alexander.poddey at gmx.net >> wrote: > >> Hi all, >> >> I can get access to the data stored in globals...
2015 Mar 18
5
[LLVMdev] casting Constant * to value *?
John, you are right. I 'browsed' the doxygen's inheritance diagram. Shouldn't I then be able to cast Constant * to Value*? Plugging the retrieved Constant* (from ConstantExpr::getGetElementPtr) into Instruction->setOperand compiles, but gives me an assertion failure at runtime. I have no access to the code at the moment. I will gather more information possibly tomorrow. Thanks Alex John Criswell wrote: > On 3/17/15 8:40 PM, Alexander Poddey wrote: >> Hi all, >&g...
2016 Feb 16
2
LLVM IR to C++
Hi, I want to convert LLVM bitcode files to cpp. I use these commands: 1. clang -c -emit-llvm -fopenmp=libiomp5 oh2.c -o oh2.bc2. llc -march=cpp oh2.bc -o oh2.cpp3. g++ -fno-rtti -O0 -g `$HOME/llvmbuild/bin/llvm-config --cxxflags` oh2.cpp `$HOME/llvmbuild/bin/llvm-config --ldflags --libs --system-libs` -o oh2c After the 3rd command, I get a lot of compilation errors. Is it possible that llc
2012 Jul 04
2
[LLVMdev] Bogus assert in VMCore/Instructions.cpp CallInst::Create?
...Type *tys = { Type::getInt32Ty(block->getContext()) }; Function *annot = Intrinsic::getDeclaration( F->getParent(), Intrinsic::annotation, tys); Value *v1 =ConstantExpr::getGetElementPtr(g1, s1_id); Value *v2 =ConstantExpr::getGetElementPtr(g2, s2_id); Value *c1 = ConstantInt::get(tys, 1); Value *c2 = ConstantInt::get(tys, 0); vector<Value*> v; v.push_back(c1); v.push_back(v1); v.push_back(v2); v.push_back(c2); Value *callAn...
2011 May 18
3
[LLVMdev] access array problem
...int *counterArray; //record the load/store addresses //increase the counter if a load/store is performed std::vector<Constant *>index(2); index[0] = Constant::getNullvalue(Type:getInt32Ty(Context)); index[1] = Constant::get(Type::getInt32Ty(Context), 0); Constant *ElementPtr = ConstantExpr::getGetElementPtr(counter, &index[0], index.size()); Value *oldcounter = new LoadInst(ElementPtr, "oldcounter", InsertPos); Value *newcounter = BinaryOperator::Create(Instruction::Add, oldcounter, ConstantInt::get(Type::getInt64Ty(Context), 1), "newcounter", InsertPos); new StoreInst(newcount...
2011 May 18
2
[LLVMdev] access array problem
...>> index[0] = Constant::getNullvalue(Type:getInt32Ty(Context)); >> index[1] = Constant::get(Type::getInt32Ty(Context), 0); > The above two lines both compute the same thing (an i32 constant equal to > zero) in two different ways. > >> Constant *ElementPtr = ConstantExpr::getGetElementPtr(counter, >> &index[0], index.size()); >> Value *oldcounter = new LoadInst(ElementPtr, "oldcounter", InsertPos); >> Value *newcounter = BinaryOperator::Create(Instruction::Add, >> oldcounter, ConstantInt::get(Type::getInt64Ty(Context), 1), >> "newcoun...
2011 Feb 01
2
[LLVMdev] Convenience methods in ConstantExpr et al
...2 overloads) CreateConstGEP1_32 CreateConstInBoundsGEP1_32 CreateConstGEP2_32 CreateConstInBoundsGEP2_32 CreateConstGEP1_64 CreateConstInBoundsGEP1_64 CreateConstGEP2_64 CreateConstInBoundsGEP2_64 CreateStructGEP All of which are very useful. However, ConstExpression only has: getGetElementPtr getGetElementPtr getInBoundsGetElementPtr getInBoundsGetElementPtr It would be nice if ConstantExpr's GEP-building methods used the same naming convention and had the same convenience methods as IRBuilder. (In fact, the naming convention between IRBuilder and the various Constants.h clas...
2005 Apr 07
0
[LLVMdev] arguments to standard library functions
...t;CallInst>(bi); const Function* F = CI->getCalledFunction() ; if( F->isExternal() ){ std::vector<Value*> paramList; Constant *fname = ConstantArray::get(F->getName()); Constant *GEP = ConstantExpr::getGetElementPtr(fname, std::vector<Constant*>(2,Constant::getNullValue(Type::LongTy))); paramList.push_back( GEP); paramList.push_back( ConstantUInt::get( Type::UIntTy, CI->getNumOperands()) ); CallInst* newCI = new CallInst( CF, paramList, "",...
2011 May 18
0
[LLVMdev] access array problem
...32Ty(M.getContext()), 3000); > GlobalVariable *Counters = new GlobalVariable(M, ATy, false, > GlobalValue::InternalLinkage, > Constant::getNullValue(ATy), "MemTraceCounters"); OK, so Counters is an array of 3000 32 bit integers. >>> Constant *ElementPtr = ConstantExpr::getGetElementPtr(counter, >>> &index[0], index.size()); What is "counter", the same things as CounterSize? >>> //store the memory address to counterArray[oldcounter] >>> std::vector<Constant*> indexC(2); >>> indexC[0] = Constant::getNullvalue(Type:getInt...
2004 Dec 21
3
[LLVMdev] Help with code
...td::string("printf")); Constant *str=ConstantArray::get("Value : %d\n"); std::vector<Value *> Args(2); std::vector<Constant *> GEPIndices(2); GEPIndices[0]=Constant::getNullValue(Type::LongTy); GEPIndices[1]=Constant::getNullValue(Type::LongTy); Args[0]=ConstantExpr::getGetElementPtr(strcon,GEPIndices); Args[1]=ConstantInt::get(Type::IntTy, id); Instruction * cI= new CallInst(printFn, Args, "retprintf",instr); Thanks
2012 Jul 04
0
[LLVMdev] Bogus assert in VMCore/Instructions.cpp CallInst::Create?
...e::getInt32Ty(block->getContext()) }; > Function *annot = Intrinsic::getDeclaration( F->getParent(), > Intrinsic::annotation, > tys); > Value *v1 =ConstantExpr::getGetElementPtr(g1, s1_id); > Value *v2 =ConstantExpr::getGetElementPtr(g2, s2_id); > Value *c1 = ConstantInt::get(tys, 1); > Value *c2 = ConstantInt::get(tys, 0); > > vector<Value*> v; > v.push_back(c1); > v.push_back(v1); > v.push_back(v2)...
2011 May 18
0
[LLVMdev] access array problem
...t;Constant *>index(2); > index[0] = Constant::getNullvalue(Type:getInt32Ty(Context)); > index[1] = Constant::get(Type::getInt32Ty(Context), 0); The above two lines both compute the same thing (an i32 constant equal to zero) in two different ways. > Constant *ElementPtr = ConstantExpr::getGetElementPtr(counter, > &index[0], index.size()); > Value *oldcounter = new LoadInst(ElementPtr, "oldcounter", InsertPos); > Value *newcounter = BinaryOperator::Create(Instruction::Add, > oldcounter, ConstantInt::get(Type::getInt64Ty(Context), 1), > "newcounter", InsertPos...
2005 Mar 21
3
[LLVMdev] arguments to standard library functions
HI , I understand that the standard C library functions are executed using the native library of the host machine. ( for example when we execute a bytecode to extract the profile info ) Is it possible to extract for each standard library function that is executed , the arguments that the function is called with. For example if printf ("%d", some_int ) when called during runtime
2015 Mar 17
2
[LLVMdev] casting Constant * to value *?
Hi all, extracting datafields of globals, the API code ends up in a Constant * Constant* const_ptr_103 = ConstantExpr::getGetElementPtr(gvar_struct_foo, const_ptr_103_indices); it can be used to initialize e.g. a new instruction like: StoreInst* void_119 = new StoreInst(const_float_102, const_ptr_103, false, label_entry_113); But how about replacing the operand of an already existing instruction using a Constant *? Instruct...
2015 May 26
2
[LLVMdev] convert GetElemtPtr result to pointer on element?
Hi all, I'm still struggling with getElementPtr. I have a global variable (array of doubles). I can use ConstantExpr::getGetElementPtr(myGlobalVariable, indices) and use the result as argument of e.g. a function. I read the GEP docu and know that I need anextra leading '0' index to dereference the global's pointer. So far so good. But I can not succeed in using the getGetElementPtr result in constructing an initaliz...
2015 Mar 07
2
[LLVMdev] cannot understand global c++API code
...tantInt* const_int32_99 = ConstantInt::get(mod->getContext(), APInt(32, StringRef("1"), 10)); std::vector<Constant*> const_ptr_103_indices; const_ptr_103_indices.push_back(const_int32_98); const_ptr_103_indices.push_back(const_int32_99); Constant* const_ptr_103 = ConstantExpr::getGetElementPtr(gvar_struct_foo, const_ptr_103_indices); //the store inst is in principle clear StoreInst* void_119 = new StoreInst(const_float_102, const_ptr_103, false, label_entry_113); void_119->setAlignment(4); --------------------------------------------- comment: I don't get whats the meaning of...
2004 Jun 17
4
[LLVMdev] generating instructions with embedded ConstantExprs from within LLVM
...), &M); std::vector<Value*> params; //params to a CallInst std::vector<Value*> indices; //indices to gep indices.push_back((Value*) (ConstantInt::get(Type::IntTy, 0))); indices.push_back((Value*) (ConstantInt::get(Type::IntTy, 0))); Constant *gep = ConstantExpr::getGetElementPtr( (Constant*) str, indices); params.push_back((Value*) gep ); CallInst *CI = new CallInst(printf, params, std::string(""), I); This resulted in a "no such type plane" assertion. Currently I am doing this as two seperate instructions, which works, but slows down the r...
2011 Feb 02
0
[LLVMdev] Convenience methods in ConstantExpr et al
...dsGEP1_32 > CreateConstGEP2_32 > CreateConstInBoundsGEP2_32 > CreateConstGEP1_64 > CreateConstInBoundsGEP1_64 > CreateConstGEP2_64 > CreateConstInBoundsGEP2_64 > CreateStructGEP > > All of which are very useful. However, ConstExpression only has: > > getGetElementPtr > getGetElementPtr > getInBoundsGetElementPtr > getInBoundsGetElementPtr > > It would be nice if ConstantExpr's GEP-building methods used the same > naming convention and had the same convenience methods as IRBuilder. (In > fact, the naming convention between IRBuilde...
2004 Jun 17
0
[LLVMdev] generating instructions with embedded ConstantExprs from within LLVM
...t(inst2string(I)); //fucnction defined elsewhere > > //generates a correct Global string > GlobalVariable *str = new GlobalVariable(C->getType(), true, > GlobalValue::InternalLinkage, > C, mkStrName( strNumber++ ), &M); ... > Constant *gep = ConstantExpr::getGetElementPtr( (Constant*) str, indices); Sorry for responding twice. As soon as I sent that I realized the problem. The problem is that the cast on the bottom line here is masking the bug. In particular, you can't use the address of global variables as constants (yet: see PR122). This is definitely a b...