[cfe-users] Custom function attributes in FunctionPass

Shixin Wang via cfe-users cfe-users at lists.llvm.org
Tue Oct 31 04:37:43 PDT 2017

I hope this is the right list for this question.

I wrote a Clang/LLVM plugin as a function pass to do some application
specific optimazations on my C/C++ code.

To exclude functions from this optimazation pass I want to use C++11 custom
function attributes and want to set *"plugin_do_not_optimize"* like this. I
want to check it in my pass and if it is set, simply skip the pass.

foo( void ) __attribute__(( plugin_do_not_optimize )){
    printf( "Hello world. \n" );}

I found the AttributBuilder in the docs but cant get rid of it, catching my

I already tried


but it does not return true on the function above and I get the following

test.cpp:4:28: warning: unknown attribute 'plugin_do_not_optimize'
ignored [-Wunknown-attributes]

How to declare my attribute in clang and get the information if it is
set in my pass?

Best regards,

Shixin Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-users/attachments/20171031/94c356b8/attachment.html>

More information about the cfe-users mailing list