[llvm-dev] Mark function argument with custom annotation
Hayrapetyan, Anahit via llvm-dev
llvm-dev at lists.llvm.org
Tue Oct 9 07:06:09 PDT 2018
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!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20181009/0ee0ac73/attachment-0001.html>
More information about the llvm-dev
mailing list