I would like to do some analysis on each function in LLVM IR. However, when I generate LLVM IR code from my example c code, I found that in some case, the argument number of a function is different from my example c code. For example:
my example c code is as below:
struct outer_s{
int a;
int b;
int c;
};
void func_a(struct outer_s z){
// nothing
}
however, the generated LLVM IR code is as below:
%struct.outer_s = type { i32, i32, i32 }
; Function Attrs: noinline nounwind optnone uwtable
define dso_local void @func_a(i64, i32) #0 {
%3 = alloca %struct.outer_s, align 4
%4 = alloca { i64, i32 }, align 4
%5 = getelementptr inbounds { i64, i32 }, { i64, i32 }* %4, i32 0, i32 0
store i64 %0, i64* %5, align 4
%6 = getelementptr inbounds { i64, i32 }, { i64, i32 }* %4, i32 0, i32 1
store i32 %1, i32* %6, align 4
%7 = bitcast %struct.outer_s* %3 to i8*
%8 = bitcast { i64, i32 }* %4 to i8*
call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %7, i8* align 4 %8, i64 12, i1 false)
ret void
}
As we have seen above, the "struct outer_s z" argument is split in two parts. If I use API to get function arguments, the argument number that I get is also 2.
As my analysis is start from function arguments and wrong argument num will cause wrong result. So I’m wondering if there is any LLVM Pass or clang argument that I can use to avoid those "split" case?
#0attributes list have any hints? Can you post it? - arrowd