Hi, 

This is a simple patch to add a new first-class option 

-finline-visibility={all|extern|static}

to finer control inlining based on function’s visibility. 

'-finline-visibility=[all|extern|static]'
     By default, GCC inlines functions without considering their
     visibility.  This flag allows finer control of inlining based on
     their visibility.

     The value 'extern' tells the compiler to only inline functions with
     external visibility.  The value 'static' tells the compiler to only
     inline functions with static visibility.  The value 'all' tells the
     compilers to inline functions without considering their visibility.

     The default value of '-finline-visibility' is 'all'.

The major purpose of this option is to provide a way for the user 
to finer choose the inline candidates based on function’s visibility.
For example, some online patching users might want to limit the inlining
to only static functions to avoid patching the callers of global functions
in order to control the memory consumption caused by online patching. 

let me know any comments and suggestions.

thanks.

Qing

gcc/ChangeLog:

+2018-09-11  Qing Zhao  <qing.z...@oracle.com>
+
+       * cif-code.def (FUNCTION_EXTERN): New CIFCODE.
+       (FUNCTION_STATIC): Likewise.
+       * common.opt (-finline-visibility=): New option.
+       * doc/invoke.texi: Document -finline-visibility=.
+       * flag-types.h: Add a new enum inline_visibility.
+       * ipa-inline.c (can_inline_edge_p): Control inlining based on
+       function's visibility. 
+

gcc/testsuite/ChangeLog:

+2018-09-11  Qing Zhao  <qing.z...@oracle.com>
+
+       * gcc.dg/inline_visibility_1.c: New test.
+       * gcc.dg/inline_visibility_2.c: New test.
+

Attachment: add-a-new-option-for-inline-visibility.patch
Description: Binary data

Reply via email to