Displaying 20 results from an estimated 117 matches for "arg_begin".
2016 Mar 14
4
LLVM 3.8 change in function argument lists?
Hi,
I am upgrading my project from 3.7 to 3.8. I find that following code
used to compile in 3.7 but doesn't in 3.8 and I can't understand why.
llvm::Function *mainFunc = ...;
auto argiter = mainFunc->arg_begin();
llvm::Value *arg1 = argiter++;
arg1->setName("obj");
But if I change the code to following it compiles:
auto argiter = mainFunc->arg_begin();
llvm::Value *arg1 = &(*argiter);
arg1->setName("obj");
As far as I can tell the first version should have worked as w...
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 = NamedValues[Name];
return...
2012 Apr 23
1
[LLVMdev] Problem about the type of Function's arguement in llvm
...DoubleTy(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<<"\n";
outs(...
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 *VariableExprAST::Codegen()...
2009 Jun 18
2
[LLVMdev] Referring to an argument in another 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 another function!"...
2011 Sep 04
1
[LLVMdev] correct types for ArgumentList?
...t; v_params;
v_params.push_back(ptrType); /* Shadow */
v_params.push_back(ptrType); /* New Value */
v_params.push_back(ptrType); /* Pointer */
ArrayRef<Type *> a_params(v_params);
Where the assignment will look something like this:
Value *val = newFunc->arg_begin();
Value *ptr = ++(newFunc->arg_begin());
new StoreInst(val, ptr, block);
But the only way I know to call is it is like this:
vector<Value *> v_args;
v_args.push_back(shadow);
v_args.push_back(store->getValueOperand());
v_args.push_back(store->getPointerOpe...
2017 Jun 08
4
DICompileUnit duplication in LLVM 4.0.0?
...nctionType *NewTy) const {
Function *New = Function::Create(NewTy, Old.getLinkage(), "", &M);
New->setAttributes(Old.getAttributes());
New->setCallingConv(Old.getCallingConv());
// Map old arguments to the new arguments.
ValueToValueMapTy VMap;
for (auto OldFI = Old.arg_begin(), OldFE = Old.arg_end(),
NewFI = New->arg_begin();
OldFI != OldFE; ++OldFI, ++NewFI) {
Argument &OldA = *OldFI;
Argument &NewA = *NewFI;
NewA.setName(OldA.getName());
VMap[&OldA] = &NewA;
}
SmallVector<ReturnInst *, 16> Returns;
Cl...
2011 Sep 16
2
[LLVMdev] How to duplicate a function?
...alse);
// 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
// function empty....
2016 Aug 29
2
GVN / Alias Analysis issue with llvm.masked.scatter/gather intrinsics
this is definitely a bug in AA.
225 for (auto I = CS2.arg_begin(), E = CS2.arg_end(); I != E; ++I) {
226 const Value *Arg = *I;
227 if (!Arg->getType()->isPointerTy())
-> 228 continue;
229 unsigned CS2ArgIdx = std::distance(CS2.arg_begin(), I);
230 auto CS2ArgLoc = MemoryLocation::getForArgument(CS2,
CS2...
2010 Jun 09
1
[LLVMdev] Segmentation fault 'cause of accessing function arguments
Hi all,
I am experimenting to run a pass inherited from CallGraphSCCPass. In
the pass, I iterate all functions in a SCC. In each iteration, I
access all arguments of a function in the following way:
Function::arg_iterator PI = fun->arg_begin(), PE = fun->arg_end();
...
I have no trouble with building. However, I am troubled with
"segmentation fault" when I run the pass via:
opt -load ../../build-llvm/Debug/lib/LLVMRCI.dylib -rci < a.out.bc
The error message is attached later.
So, am I wrong with accessing func...
2007 Jan 23
2
[LLVMdev] Semi-random crashes seemingly related to Arguments
...parameters), but those seem to be
quiescent at the time. Any ideas?
Thanks,
Marcel
------- my weird code.m ------------
-argumentAtIndex:(int)argIndex
{
Argument *ArgX;
if ( argIndex < numArgs ) {
int i;
ArgX = ((Function*)function)->arg_begin();
for (i=0 ;i<argIndex;i++) {
++ArgX;
}
[NSString stringWithFormat:@"get argument[%d/%d]=
%x",argIndex,numArgs,ArgX]; // with this in place, it doesn't
crash
return [MPWLLVMValue...
2007 Jan 23
0
[LLVMdev] Semi-random crashes seemingly related to Arguments
...e. Any ideas?
>
> Thanks,
>
> Marcel
>
>
> ------- my weird code.m ------------
> -argumentAtIndex:(int)argIndex
> {
> Argument *ArgX;
> if ( argIndex < numArgs ) {
> int i;
> ArgX = ((Function*)function)->arg_begin();
> for (i=0 ;i<argIndex;i++) {
> ++ArgX;
> }
>
> [NSString stringWithFormat:@"get argument[%d/%d]=
> %x",argIndex,numArgs,ArgX]; // with this in place, it doesn't
> crash
>...
2016 Aug 29
2
GVN / Alias Analysis issue with llvm.masked.scatter/gather intrinsics
...ons of them, but memory locations expect to be one
> thing, not a group of things, etc).
>
>
>
>
> On Mon, Aug 29, 2016 at 8:58 AM, Daniel Berlin <dberlin at dberlin.org>
> wrote:
>
>> this is definitely a bug in AA.
>>
>> 225 for (auto I = CS2.arg_begin(), E = CS2.arg_end(); I != E;
>> ++I) {
>> 226 const Value *Arg = *I;
>> 227 if (!Arg->getType()->isPointerTy())
>> -> 228 continue;
>> 229 unsigned CS2ArgIdx = std::distance(CS2.arg_begin(), I);
>> 230 au...
2009 Jun 18
0
[LLVMdev] Referring to an argument in another function
...rg1, 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"
// ...
Call...
2017 Jun 08
2
DICompileUnit duplication in LLVM 4.0.0?
...::Create(NewTy, Old.getLinkage(), "", &M);
>> New->setAttributes(Old.getAttributes());
>> New->setCallingConv(Old.getCallingConv());
>>
>> // Map old arguments to the new arguments.
>> ValueToValueMapTy VMap;
>> for (auto OldFI = Old.arg_begin(), OldFE = Old.arg_end(),
>> NewFI = New->arg_begin();
>> OldFI != OldFE; ++OldFI, ++NewFI) {
>> Argument &OldA = *OldFI;
>> Argument &NewA = *NewFI;
>> NewA.setName(OldA.getName());
>> VMap[&OldA] = &NewA;
&g...
2011 Sep 16
0
[LLVMdev] How to duplicate a function?
...alse);
// 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
// function empty....
2011 Jul 06
2
[LLVMdev] First steps with LLVM and partial evaluation
...ValueToValueMapTy& ValueMap)
{
vector<const Type*> ArgTypes;
// The user might be deleting arguments to the function by specifying them in
// the ValueMap. If so, we need to not add the arguments to the arg ty vector
//
for (Function::const_arg_iterator I = F->arg_begin(), E = F->arg_end();
I != E; ++I)
if (ValueMap.count(I) == 0) // Haven't mapped the argument to anything yet?
ArgTypes.push_back(I->getType());
// Create a new function type...
FunctionType *FTy = FunctionType::get(F->getFunctionType()->getReturnTyp...
2019 Mar 16
2
Why getNumOperands() incorrectly returns 0?
Hi all,
I have encountered a weird case that I cannot understand. Inside the
visitStoreInst I have a reference (F) to the function png_set_mem_fn. If I
do F->dump() i can set the IR of that function correctly e.g.:
; Function Attrs: nounwind uwtable
define void @png_set_mem_fn(%struct.png_struct_def.68* noalias %png_ptr,
i8* %mem_ptr, i8* (%struct.png_struct_def.68*, i64)* %malloc_fn, void
2008 Sep 13
3
[LLVMdev] Duplicate Function with duplicated Arguments
I'm now writing a pass and I wanna ask a question about how to
duplicate the function and add duplicated arguments in llvm, for
example:
func(int a, char *b) -> func(int a, char *b, int a1, char *b1)
I'm now stuck at using "getOrInsertFunction" and how to handle
"getArgumentList", please share your opinion, thanks a lot!
James
2013 Apr 24
1
[LLVMdev] JIT pass runtime struct on to subroutines
...because I compiled all instruction-functions to an LLVM Module and loaded it.
llvm::Function *machine_instr = llvm_execution_engine->FindFunctionNamed(instruction_function_name);
// Prepare for setting the parameters of a call instruction
llvm::Argument *llvm_arg = machine_instr->arg_begin();
// Add a pointer to the machine-struct as a first parameter to every instruction-function call.
// This should be the same pointer that is passed at runtime to the predicate-function (llvm_function)
llvm_arg++ = ??;
// pseudo: for any additional parameters of the machine instru...