[llvm-branch-commits] [clang] [clang] Add clang::nooutline Attribute (PR #163666)
Erich Keane via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Oct 16 14:08:10 PDT 2025
================
@@ -862,6 +862,36 @@ with ``__noinline__`` defined as a macro as ``__attribute__((noinline))``.
}];
}
+def NoOutlineDocs : Documentation {
+ let Category = DocCatFunction;
+ let Content = [{
+This function attribute suppresses outlining from the annotated function.
+
+Outlining is the process where common parts of separate functions are extracted
+into a separate function (or assembly snippet), and calls to that function or
+snippet are inserted in the original functions. In this way, it can be seen as
+the opposite of inlining. It can help to reduce code size.
+
+.. code-block:: c
+
+ [[clang::nooutline]] int x1(int y) {
+ int z = COMPLEX_MACRO(y); // Not outlined
+ return z + const1;
+ }
+
+ int x2(int y) {
+ int z = COMPLEX_MACRO(y); // May be outlined
+ return z * const2;
+ }
+
+ int x3(int y) {
+ int z = COMPLEX_MACRO(y); // May be outlined
+ reutrn z / const3;
+ }
+
+ }];
+}
----------------
erichkeane wrote:
Can you explain why one would not want this to happen? Perhaps a quick example? And can you show a psuedo-code version of x2/x3 (though I'd probably suggest only a single-one of those examples, they aren't unique enough to have 2) as to what it might look like as an 'outlined' version?
https://github.com/llvm/llvm-project/pull/163666
More information about the llvm-branch-commits
mailing list