[llvm-dev] Is there a way to map from coerced parameter to original parameter
ZIN MOON via llvm-dev
llvm-dev at lists.llvm.org
Thu Jan 16 01:18:05 PST 2020
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200116/7be5ec08/attachment.html>
More information about the llvm-dev
mailing list