Hello.
Some parameters of the function would be changed according to ABI rules by compiler
I would like to mapping from coerced parameters of the function(by compiler(clang)) to C code.
For example,
In C
typedef struct data_info
{
char *buf;
size_t size;
} data_info;
data_info foo(data_info src, int result)
{
data_info dst;
dst.buf = (char *)malloc(src.size);
memcpy((dst.buf, src.buf, src.size);
return dst;
}
In IR (with reg2mem, no opt)
define {i8 , i64} @foo(i8, i64, i32*) #0 {
%4 = alloc %struct.dat_info, align 8
%5 = alloc %struct.dat_info, align 8
%6 = bitcast %struct.data_info* %6 to {i8 *, i64}
%7 = getelementptr inbounds {i8 *, i64}, {i8 , i64} %6, i32 0, i32 0
%8 = getelementptr inbounds {i8 *, i64}, {i8 , i64} %6, i32 0, i32 1
…
}
The foo function has 2 parameter in C code, but IR code has 3 parameters.
There is mismatch between C code and IR code.
I want to mapping parameters from IR to C code like in the below
1st parameter (i8 *) in IR code-> 1st field of the first parameter of the function in C
2nd (i64) → 2nd field of the 1st parameter of the function in C.
3rd (i32 *) → 2nd parameter of the function in C.
Is there any class or tools for it in LLVM.
Please advise the way/idea to map between original parameter in C code and coerced parameter in IR code