search for: arg_iterator

Displaying 20 results from an estimated 86 matches for "arg_iterator".

2017 Mar 22
2
arg_iterator missing inc/dec operators
...vm-mirror/llvm/blob/master/include/ > llvm/ADT/ilist_iterator.h#L153 > > Maybe you meant: > > llvm::Function *f; > foo(&*--f->arg_end()); > > ? > Correct, I mean exactly this. Though &* is not important in this case. This code doesn't work anymore, as arg_iterator is defined differently now: https://github.com/llvm-mirror/llvm/blob/master/include/llvm/IR/Function.h#L57 I get an error when I'm using pre-decrement operator: error: expression is not assignable --f->arg_end(); Dmitry. -------------- next part -------------- An HTML attachment was...
2017 Mar 22
3
arg_iterator missing inc/dec operators
Reid, After your recent redefinition of arg_iterator, it's missing increment/decrement operators (which people typically expect to be defined for iterators). So some external code relying on this is broken. If it's not intentional, would be nice to have it fixed. Specific code that I is broken looks like this: llvm::Function f; foo(--f->...
2012 Apr 23
1
[LLVMdev] Problem about the type of Function's arguement in llvm
...FunctionType::get(Type::getDoubleTy(Context), argslist, false); Function *fun= cast<Function> ( module->getOrInsertFunction("fun", funType)); BasicBlock * block = BasicBlock::Create(Context, "mainBlock", fun); IRBuilder<> builder(block); Function::arg_iterator itr = fun->arg_begin(); builder.CreateLoad(itr); Value *result = ConstantFP::get(Type::getDoubleTy(getGlobalContext()), 1.0); builder.CreateRet(result); vector<GenericValue> args; ExecutionEngine *e = EngineBuilder(module).create(); outs()<<*module<<&...
2009 Jun 18
2
[LLVMdev] Referring to an argument in another function
...o free with some function foo, so the C code would look like: foo(myarg1, myarg2, ptr); free(ptr); The problem occurs when I grab the arg from the free function and try to pass it to foo... if (isCallToFree(&I)) { Value* P; if (Function *F = I.getCalledFunction()) { Function::arg_iterator ait = F->arg_begin(); if (ait) { P = &(*ait); } createCallInst(mem_fcall, &I, 3, getOpcodeValue(I), getInstrIDValue(), P); } } createCallInst is my own wrapper. The error thrown during the pass is: "Referring to an argument in a...
2012 Apr 22
2
[LLVMdev] Problem about the type of Function's arguement in llvm
in the tutorial of official llvm doc, chapter 3, it deals with arguement of function as follow: for (Function::arg_iterator AI = F->arg_begin(); Idx != Args.size(); ++AI, ++Idx) { AI->setName(Args[Idx]); // NamedValues is map<string, Value*> NamedValues[Args[Idx]] = AI; and when it try to get the value of arguement, it simply does: Value *VariableExprAST::Codegen() { Value *V = NamedV...
2009 Jun 18
0
[LLVMdev] Referring to an argument in another function
...like: > > foo(myarg1, myarg2, ptr); > free(ptr); > > The problem occurs when I grab the arg from the free function and try > to pass it to foo... > > if (isCallToFree(&I)) { > Value* P; > if (Function *F = I.getCalledFunction()) { > Function::arg_iterator ait = F->arg_begin(); You want to look at the operands of the call/invoke/free instruction, not the arguments of the function being called. So if you're sure it's a call or invoke (not a 'free' instruction), try something like this: #include "llvm/Support/CallSite.h&quot...
2012 Apr 22
0
[LLVMdev] Problem about the type of Function's arguement in llvm
hi On Sun, Apr 22, 2012 at 8:36 PM, Jianfei Hu <hujianfei258 at gmail.com> wrote: > in the  tutorial of official llvm doc, chapter 3, it deals with arguement of > function as follow: > > for (Function::arg_iterator AI = F->arg_begin(); Idx != Args.size(); >        ++AI, ++Idx) { >     AI->setName(Args[Idx]); > >     // NamedValues is map<string, Value*> >     NamedValues[Args[Idx]] = AI; > > and when it try to get the value of arguement, it simply does: > > Value *Variab...
2007 Mar 06
6
[LLVMdev] alloca & store generation
...; <int*>:0 [#uses=1] alloca sbyte** ; <sbyte***>:0 [#uses=1] store int %argc, int* %0 store sbyte** %argv, sbyte*** %0 ... ----- I used the following code in my transformation: ----- BasicBlock* eb = M.getMainFunction()->getEntryBlock(); Function::arg_iterator argc_it = mainfun->arg_begin(); Function::arg_iterator argv_it = argc_it; ++argv_it; Argument* argc = &*argc_it; Argument* argv = &*argv_it; Instruction* insertNewInstsBefore = &eb->front(); AllocaInst* argc_alloca = new AllocaInst(argc->getType(), "&quot...
2007 Mar 06
0
[LLVMdev] alloca & store generation
...** ; <sbyte***>:0 [#uses=1] > store int %argc, int* %0 > store sbyte** %argv, sbyte*** %0 > ... > ----- > > I used the following code in my transformation: > > ----- > BasicBlock* eb = M.getMainFunction()->getEntryBlock(); > Function::arg_iterator argc_it = mainfun->arg_begin(); > Function::arg_iterator argv_it = argc_it; > ++argv_it; > Argument* argc = &*argc_it; > Argument* argv = &*argv_it; > Instruction* insertNewInstsBefore = &eb->front(); > AllocaInst* argc_alloca = new AllocaInst(a...
2009 Nov 11
4
[LLVMdev] Adding function call in LLVM IR using IRBuilder causes assertion error
...l function arguments and pass them as explained in the tutorial. My code is (this function is supposed to add a call to f in bb at pos): void addCallSite(Function *f, BasicBlock *bb, BasicBlock::iterator pos) { std::vector<Value*> args; IRBuilder<> builder(bb,pos); for(Function::arg_iterator argit = f->arg_begin();argit!=f->arg_end();argit++){ AllocaInst* allocInst = builder.CreateAlloca(argit->getType()); args.push_back(allocInst); } builder.CreateCall(f,args.begin(),args.end()); } This seems to work for functions without parameters (eg. int foo()), but onc...
2009 Apr 16
2
[LLVMdev] Patch: MSIL backend global pointers initialization
...Writer::printExternals() bool MSILWriter::compareCallSite(CallSite A, CallSite B) { return getCallSiteFType(A)<getCallSiteFType(B); } // Constructs function type from given CallSite FunctionType* MSILWriter::getCallSiteFType(CallSite CS) { std::vector<const Type *> params; CallSite::arg_iterator AI=CS.arg_begin(), AE = CS.arg_end(); for ( ; AI!=AE; ++AI ) params.push_back((*AI)->getType()); return FunctionType::get(CS.getCalledFunction()->getReturnType(), params,CS.getCalledFunction()->isVarArg()); } Thanks! Regards, Artur -------------- next part -------------- An HT...
2011 Sep 16
2
[LLVMdev] How to duplicate a function?
...nType(), Params, false); // Create the new function body and insert it into the module... Function *NF = Function::Create(NFTy, Fn->getLinkage()); NF->copyAttributesFrom(Fn); Fn->getParent()->getFunctionList().insert(Fn, NF); NF->takeName(Fn); for (Function::arg_iterator AI=F.arg_begin(), AE=F.arg_end(), NAI=NF->arg_begin(); AI != AE; ++AI, ++NAI) { NAI->takeName(AI); } // Since we have now create the new function, splice the body of the old // function right into the new function, leaving the old rotting hulk of the // funct...
2004 Oct 12
2
[LLVMdev] GenRegisterInfo.h.inc
...roblem? Back again to compilation problems under win32 with VC llvm\lib\Analysis\DataStructure\Local.cpp(628) : error C2105: '--' needs l-value the line is: Result.mergeWith(getValueDest(**--CS.arg_end())); Can I submit patches for mutate it in something like: llvm::CallSite::arg_iterator ii = CS.arg_end(); --ii; Result.mergeWith(getValueDest(**ii)); There're several of this in Local.cpp, and this is the only file affected. --- Paolo Invernizzi
2009 Nov 17
1
[LLVMdev] LLVM target-independent code generator for reconfigurable logic
...ased microprocessors.", so i want to insert my special DAG building code to the code generator. should i completely replace SelectionDAGISel, or modify SelectionDAGISel when necessary like this: LowerArguments(BasicBlock *LLVMBB) { // code for traditional target ........... for (Function::arg_iterator I = F.arg_begin(), E = F.arg_end(); I != E; ++I, ++Idx) { if (TLI.isStrangeTarget()) { //code for my strange target TLI.HandleArgment(...); continue; } // code for traditional target ....... } // code for traditional...
2009 May 19
1
[LLVMdev] How to get line number and source file name for IR?
...0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit17 to { }*)) I know that the first argument is line number, and the third argument, the compile unit llvm.dbg.compile_unit17, is mapped to a source file. I can get the first line number very easily by "CallSite::arg_iterator" (and represent the first argument with class ConstantInt). However, I do not know how to represent the "{ }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit17 to { }*)" in LLVM source code. Moreover, do we have a better way to achieve the line number and so...
2009 Apr 16
0
[LLVMdev] Patch: MSIL backend global pointers initialization
...pointers which can be quite unstable and in general bad for tests, etc. > > // Constructs function type from given CallSite At least - from arguments of the call :) > FunctionType* MSILWriter::getCallSiteFType(CallSite CS) { >   std::vector<const Type *> params; >   CallSite::arg_iterator AI=CS.arg_begin(), AE = CS.arg_end(); Why don't shorten life of AI, AE and not define them in the for() loop header? >   for ( ; AI!=AE; ++AI ) >     params.push_back((*AI)->getType()); -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg St...
2011 Oct 06
2
[LLVMdev] How to create arguments CallInst
virtual std::vector<Value *> getESetArgumentosFunc(Function *F){ std::vector<Value *> varg_list; varg_list.clear(); for(Function::arg_iterator arg_iti = F->getArgumentList().begin(), arg_ite = F->getArgumentList().end(); arg_iti != arg_ite; ++arg_iti){ Value *para = ConstantInt::get(IntegerType::get(getGlobalContext(),32), 0); *Value *val2 = cast<* arg_iti->getType()*>(para); <----------------------...
2010 Dec 21
2
[LLVMdev] the optional function return attribute and the llvm-c bindings
...eems to say is the proper mode for indexing the return parameter, but when I set an attribute on the parameter with index zero, it gets applied to the first function argument and not the return parameter. I believe the reason for this to be that LLVMGetParams() [and its cognates] all use Function::arg_iterator, which begins with the first function *argument* parameter and not the return parameter. The index argument to LLVMGetParams() is actually incremented by one when it's mapped to the index used for the Function::AttributeList member. There are separate functions for the function attributes, wh...
2010 Jul 22
2
[LLVMdev] Question about function arguments
...ine the values of function arguments using the iterators defined in Function.cpp. Any advice or hints would be great..! Basically, what I am trying out is: Function foo has the following function body: int foo(int a, int b) { } Function * f = module->getFunction("foo"); Function::arg_iterator start = f->arg_begin(); Function::arg_iterator end = f->arg_end(); while(start != end) { Argument * value = (Argument *)start; cout << "\n Argument: << value->getNameStr(); start++; } This piece of code works if 'module' contains the definition...
2012 Oct 08
1
[LLVMdev] Fwd: Multiply i8 operands promotes to i32
...GenTypes &CGT) : ABIInfo(CGT) {} ABIArgInfo classifyReturnType(QualType RetTy) const; ABIArgInfo classifyArgumentType(QualType RetTy) const; virtual void computeInfo(CGFunctionInfo &FI) const { FI.getReturnInfo() = classifyReturnType(FI.getReturnType()); for (CGFunctionInfo::arg_iterator it = FI.arg_begin(), ie = FI.arg_end(); it != ie; ++it) it->info = classifyArgumentType(it->type); } virtual llvm::Value *EmitVAArg(llvm::Value *VAListAddr, QualType Ty, CodeGenFunction &CGF) const { return 0; } }; ABIArgInfo MSP430ABI...