https://gcc.gnu.org/g:06c86ad9301366377979686a841af5c5783c7de5

commit r17-5625-g06c86ad9301366377979686a841af5c5783c7de5
Author: Josef Melcr <[email protected]>
Date:   Tue Sep 15 11:50:05 2026 +0200

    middle-end: Don't disable optimizations for assume bodies
    
    Currently, assume bodies are created with attributes preventing IPA
    optimizations, even if the function from which they were outlined don't
    have them.  In order to make IPA for assume bodies possible, this patch
    changes said behavior to make assumes inherit attributes from the
    function from which they were outlined.  This means that the assume body
    will have the IPA-preventing attribute only if the function which
    spawned it has it.  This patch also fixes a bug where the
    assume_function field wouldn't be copied during cloning.
    
    gcc/ChangeLog:
    
            * gimple-low.cc (create_assumption_fn): Don't add attributes
            disabling optimizations.
            * tree-inline.cc (initialize_cfun): Copy over assume_function to
            cfun when cloning.
    
    Signed-off-by: Josef Melcr <[email protected]>

Diff:
---
 gcc/gimple-low.cc  | 13 +------------
 gcc/tree-inline.cc |  1 +
 2 files changed, 2 insertions(+), 12 deletions(-)

diff --git a/gcc/gimple-low.cc b/gcc/gimple-low.cc
index a24d8e49bb22..f5e175387fcc 100644
--- a/gcc/gimple-low.cc
+++ b/gcc/gimple-low.cc
@@ -302,18 +302,7 @@ create_assumption_fn (location_t loc)
   DECL_EXTERNAL (decl) = 0;
   DECL_CONTEXT (decl) = NULL_TREE;
   DECL_INITIAL (decl) = make_node (BLOCK);
-  tree attributes = DECL_ATTRIBUTES (current_function_decl);
-  if (lookup_attribute ("noipa", attributes) == NULL)
-    {
-      attributes = tree_cons (get_identifier ("noipa"), NULL, attributes);
-      if (lookup_attribute ("noinline", attributes) == NULL)
-       attributes = tree_cons (get_identifier ("noinline"), NULL, attributes);
-      if (lookup_attribute ("noclone", attributes) == NULL)
-       attributes = tree_cons (get_identifier ("noclone"), NULL, attributes);
-      if (lookup_attribute ("no_icf", attributes) == NULL)
-       attributes = tree_cons (get_identifier ("no_icf"), NULL, attributes);
-    }
-  DECL_ATTRIBUTES (decl) = attributes;
+  DECL_ATTRIBUTES (decl) = DECL_ATTRIBUTES (current_function_decl);
   BLOCK_SUPERCONTEXT (DECL_INITIAL (decl)) = decl;
   DECL_FUNCTION_SPECIFIC_OPTIMIZATION (decl)
     = DECL_FUNCTION_SPECIFIC_OPTIMIZATION (current_function_decl);
diff --git a/gcc/tree-inline.cc b/gcc/tree-inline.cc
index 8162b1f5051a..01d66537d42a 100644
--- a/gcc/tree-inline.cc
+++ b/gcc/tree-inline.cc
@@ -2896,6 +2896,7 @@ initialize_cfun (tree new_fndecl, tree callee_fndecl, 
profile_count count)
   cfun->can_delete_dead_exceptions = src_cfun->can_delete_dead_exceptions;
   cfun->returns_struct = src_cfun->returns_struct;
   cfun->returns_pcc_struct = src_cfun->returns_pcc_struct;
+  cfun->assume_function = src_cfun->assume_function;
 
   init_empty_tree_cfg ();

Reply via email to