[gcc(refs/users/aoliva/heads/testme)] strub: avoid lto inlining

Alexandre Oliva aoliva@gcc.gnu.org
Thu Dec 14 13:45:38 GMT 2023


https://gcc.gnu.org/g:1f85e24fda46b1438d3030293fd1bbd73a98a03b

commit 1f85e24fda46b1438d3030293fd1bbd73a98a03b
Author: Alexandre Oliva <oliva@adacore.com>
Date:   Thu Dec 14 08:53:42 2023 -0300

    strub: avoid lto inlining
    
    The strub builtins are not suited for cross-unit inlining, they should
    only be inlined by the builtin expanders, if at all.  While testing on
    sparc64, it occurred to me that, if libgcc was built with LTO enabled,
    lto1 might inline them, and that would likely break things.  So, make
    sure they're clearly marked as not inlinable.
    
    
    for  libgcc/ChangeLog
    
            * strub.c (ATTRIBUTE_NOINLINE): New.
            (ATTRIBUTE_STRUB_CALLABLE): Add it.
            (__strub_dummy_force_no_leaf): Drop it.

Diff:
---
 libgcc/strub.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/libgcc/strub.c b/libgcc/strub.c
index b0f990d9dee..5062554d0e1 100644
--- a/libgcc/strub.c
+++ b/libgcc/strub.c
@@ -36,7 +36,12 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 # define TOPS <
 #endif
 
-#define ATTRIBUTE_STRUB_CALLABLE __attribute__ ((__strub__ ("callable")))
+/* Make sure these builtins won't be inlined, even with LTO.  */
+#define ATTRIBUTE_NOINLINE \
+  __attribute__ ((__noinline__, __noclone__))
+
+#define ATTRIBUTE_STRUB_CALLABLE \
+  __attribute__ ((__strub__ ("callable"))) ATTRIBUTE_NOINLINE
 
 /* Enter a stack scrubbing context, initializing the watermark to the caller's
    stack address.  */
@@ -72,7 +77,6 @@ __strub_update (void **watermark)
 /* Dummy function, called to force the caller to not be a leaf function, so
    that it can't use the red zone.  */
 static void ATTRIBUTE_STRUB_CALLABLE
-__attribute__ ((__noinline__, __noipa__))
 __strub_dummy_force_no_leaf (void)
 {
 }


More information about the Gcc-cvs mailing list