[cfe-dev] how to run no optimization except inlining at O3 level when generating IR

林政宗 via cfe-dev cfe-dev at lists.llvm.org
Sun Sep 20 00:15:47 PDT 2020


Hi, there,
I met a problem when compiling C source files into IR.
The C source files are compiled at O3 optimization level by clang into IR. There is a functon that I hope to always inline. So I add an always_inline attribute to the function. 
But except inlining I hope to run no optimization on it for performance reason, because it has been tuned at its best. I don't want clang to optimize it except inlining it.
I have tried optnone attribute. But it is incompatible with always_inline. 
I have also tried to add something like this.
--------------------------------------------------------
__attribute__((always_inline)) void conv2d_reduce() {
#pragma clang optimize off
/*     functionbody      */
#pragma clang optimize on
}
--------------------------------------------------------
It seems like that the #pragma directive does not take effect.


I wonder if there is any solution or suggestion. I am using clang11. Thanks in advance! 


Best Regards,
Jerry
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20200920/f9f26f0b/attachment.html>


More information about the cfe-dev mailing list