Mark function argument with custom annotation

Hello all,

I want to add a custom annotation to a function argument in source code and later retrieve it from LLVM IR.

I’ve managed to do this for a function. Following is how I did it:

#define MY_ANNOTATION attribute((annotate(“my_annotation”)))

MY_ANNOTATION

void function(int* a) {…}

Now what I want to do is add MY_ANNOTATION to function argument int* a. I’ve tried following

void function (int* MY_ANNOTATION a)

but apparently this doesn’t work as annotation is not reflected in IR.

In one of the threads in llvm archives I saw a suggestion to achieve this by adding the custom attribute to clang sources and then use it to annotate function arguments. I wonder if there is another way to get the same result without making any modification to clang and/or llvm sources.

Thanks!