[llvm-dev] Function arguments pass by value or by reference.

PeiLIU via llvm-dev llvm-dev at lists.llvm.org
Tue May 17 02:13:39 PDT 2016


Now, I am using LLVM-3.3 do some process with functions, however there are
some difficult things I can't handle by myself. So,

I want get your help to get it down properly.

Q1. There is a function declaration:

call i32 @create(i64* %tid, %union.t* %pab, i8* (i8*)* @worker, i8* null)
// callInst

Store instruction goes like this:

store i8* (i32, double, i32*)* %fp, i8* (i32, double, i32*)** %fp.addr //
storeInst

I want to determine the type of the operands are function pointer or not?
(That's what I want)

However, callInst->getOperand(2)->getType()->getTypeID() always return 14
that'a the enum number of

PointerTypeID. For the store instruction, first operand is the same as the
operation with call instruction.

How can I get the function pointer properly?

Q2. Function arguments can be passed by value or by pointer in
C-programming language.

int arr[10];
struct node {
int a;
int att[10];
double ul;
};

struct node Node;

testStruct(Node);

testStructPointer(&Node);

After compiled and change it to .ll file, it looks like this:

call void @testStruct(%struct.node* byval align 8 @Node), !dbg !160

call void @testStructPointer(%struct.node* @Node), !dbg !161

You can see that function named testStruction's parameter is passed by
value while the testStructPointer passed by pointer.

I used callInst->getOperand(0)->getType()->dump(), it always return the
same %struct.node*.

I want to know is there some properly library functions can be used to get
the precise parameters type?

I want to know the functions arguments are passed by value or by pointer?

Any advice would be appreciate. Thanks a lot.:)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160517/17e99cd8/attachment.html>


More information about the llvm-dev mailing list