diff mbox

Disable IPA-SRA for always_inline functions

Message ID 20140402122742.GA19304@virgil.suse
State New
Headers show

Commit Message

Martin Jambor April 2, 2014, 12:27 p.m. UTC
Hi,

when dealing with a PR yesterday I have noticed that IPA-SRA was
modifying an always_inline function which is useless work since the
function must then be inlined anyway.  Thus I'd like to propose the
following simple change disabling it in such cases.

Included in a bootstrap and testing on x86_64-linux.  OK for trunk now
or in the next stsge1?

Thanks,

Martin


2014-04-01  Martin Jambor  <mjambor@suse.cz>

	* tree-sra.c (ipa_sra_preliminary_function_checks): Skip
	always_inline functions.

Comments

Richard Biener April 2, 2014, 12:29 p.m. UTC | #1
On Wed, 2 Apr 2014, Martin Jambor wrote:

> Hi,
> 
> when dealing with a PR yesterday I have noticed that IPA-SRA was
> modifying an always_inline function which is useless work since the
> function must then be inlined anyway.  Thus I'd like to propose the
> following simple change disabling it in such cases.
> 
> Included in a bootstrap and testing on x86_64-linux.  OK for trunk now
> or in the next stsge1?

Ok for next stage1, but please short-cut the lookup_attribute
with a DECL_DISREGARD_INLINE_LIMITS () check.  Maybe even
abstract this away into a predicate on the cgraph node.

Thanks,
Richard.

> Thanks,
> 
> Martin
> 
> 
> 2014-04-01  Martin Jambor  <mjambor@suse.cz>
> 
> 	* tree-sra.c (ipa_sra_preliminary_function_checks): Skip
> 	always_inline functions.
> 
> Index: src/gcc/tree-sra.c
> ===================================================================
> --- src.orig/gcc/tree-sra.c
> +++ src/gcc/tree-sra.c
> @@ -4960,6 +4960,15 @@ ipa_sra_preliminary_function_checks (str
>    if (TYPE_ATTRIBUTES (TREE_TYPE (node->decl)))
>      return false;
>  
> +  if (lookup_attribute ("always_inline",
> +			DECL_ATTRIBUTES (node->decl)) != NULL)
> +    {
> +      if (dump_file)
> +	fprintf (dump_file, "Allways inline function will be inlined "
> +		 "anyway. \n");
> +      return false;
> +    }
> +
>    return true;
>  }
>  
> 
>
Jan Hubicka April 2, 2014, 10:23 p.m. UTC | #2
> Hi,
> 
> when dealing with a PR yesterday I have noticed that IPA-SRA was
> modifying an always_inline function which is useless work since the
> function must then be inlined anyway.  Thus I'd like to propose the
> following simple change disabling it in such cases.
> 
> Included in a bootstrap and testing on x86_64-linux.  OK for trunk now
> or in the next stsge1?

Actually are the attributes copied to the clone?
The patch looks OK to me, even at this stage.

Honza
> 
> Thanks,
> 
> Martin
> 
> 
> 2014-04-01  Martin Jambor  <mjambor@suse.cz>
> 
> 	* tree-sra.c (ipa_sra_preliminary_function_checks): Skip
> 	always_inline functions.
> 
> Index: src/gcc/tree-sra.c
> ===================================================================
> --- src.orig/gcc/tree-sra.c
> +++ src/gcc/tree-sra.c
> @@ -4960,6 +4960,15 @@ ipa_sra_preliminary_function_checks (str
>    if (TYPE_ATTRIBUTES (TREE_TYPE (node->decl)))
>      return false;
>  
> +  if (lookup_attribute ("always_inline",
> +			DECL_ATTRIBUTES (node->decl)) != NULL)
> +    {
> +      if (dump_file)
> +	fprintf (dump_file, "Allways inline function will be inlined "
> +		 "anyway. \n");
> +      return false;
> +    }
> +
>    return true;
>  }
>
diff mbox

Patch

Index: src/gcc/tree-sra.c
===================================================================
--- src.orig/gcc/tree-sra.c
+++ src/gcc/tree-sra.c
@@ -4960,6 +4960,15 @@  ipa_sra_preliminary_function_checks (str
   if (TYPE_ATTRIBUTES (TREE_TYPE (node->decl)))
     return false;
 
+  if (lookup_attribute ("always_inline",
+			DECL_ATTRIBUTES (node->decl)) != NULL)
+    {
+      if (dump_file)
+	fprintf (dump_file, "Allways inline function will be inlined "
+		 "anyway. \n");
+      return false;
+    }
+
   return true;
 }