public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] fix pr25446
@ 2007-07-26 18:48 Nathan Froyd
  2007-08-02  1:31 ` Mark Mitchell
  0 siblings, 1 reply; 2+ messages in thread
From: Nathan Froyd @ 2007-07-26 18:48 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 1348 bytes --]

The attached patch fixes PR/25446, which is the result of a bad
interaction between vect-ifcvt-9.c and -fPIC.  The testcase boils down
to:

void foo ()  __attribute__((always_inline));
void foo (...)
{
  ...vectorizable loop...
}

int main ()
{
  foo (...);
  return 0;
}

with a dg-final check to ensure the loop is vectorized *twice*: once in
the definition of 'foo' and once when 'foo' is inlined into 'main'.

When -fPIC is active, however, 'foo' is not marked as inlinable due to
c_cannot_inline_tree_fn only checking

  !DECL_DECLARED_INLINE_P (fn) && !targetm.binds_local_p (fn))

when determining that the function cannot be auto-inlined.  Note that
it does not check whether the function has the always_inline attribute.
Since 'foo', above, is declared always_inline but is not declared
inline, the above test succeeds and c_cannot_inline_tree_fn indicates
that 'foo' may not be inlined.

The attached patch adds a check for the absence of the always_inline
attribute to the above condition.

Bootstrapped and lightly regtested on i586-wrs-vxworks (the testcase now
passes as expected with or without -fPIC).  OK to commit after full
testing completes?

-Nathan

gcc/
2007-07-26  Nathan Froyd  <froydnj@codesourcery.com>

	PR/25446
	* c-objc-common.c (c_cannot_inline_tree_fn): Check for an
	always_inline attribute on the function decl.


[-- Attachment #2: pr25446.patch --]
[-- Type: text/plain, Size: 1119 bytes --]

Index: gcc/c-objc-common.c
===================================================================
--- gcc/c-objc-common.c	(revision 177473)
+++ gcc/c-objc-common.c	(working copy)
@@ -73,9 +73,9 @@ c_cannot_inline_tree_fn (tree *fnp)
 		     && DECL_INLINE (fn)
 		     && DECL_DECLARED_INLINE_P (fn)
 		     && !DECL_IN_SYSTEM_HEADER (fn));
+  tree always_inline = lookup_attribute ("always_inline", DECL_ATTRIBUTES (fn));
 
-  if (flag_really_no_inline
-      && lookup_attribute ("always_inline", DECL_ATTRIBUTES (fn)) == NULL)
+  if (flag_really_no_inline && always_inline == NULL)
     {
       if (do_warning)
 	warning (OPT_Winline, "function %q+F can never be inlined because it "
@@ -85,7 +85,9 @@ c_cannot_inline_tree_fn (tree *fnp)
 
   /* Don't auto-inline anything that might not be bound within
      this unit of translation.  */
-  if (!DECL_DECLARED_INLINE_P (fn) && !targetm.binds_local_p (fn))
+  if (always_inline == NULL
+      && !DECL_DECLARED_INLINE_P (fn)
+      && !targetm.binds_local_p (fn))
     {
       if (do_warning)
 	warning (OPT_Winline, "function %q+F can never be inlined because it "

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] fix pr25446
  2007-07-26 18:48 [PATCH] fix pr25446 Nathan Froyd
@ 2007-08-02  1:31 ` Mark Mitchell
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Mitchell @ 2007-08-02  1:31 UTC (permalink / raw)
  To: gcc-patches

Nathan Froyd wrote:

> gcc/
> 2007-07-26  Nathan Froyd  <froydnj@codesourcery.com>
> 
> 	PR/25446
> 	* c-objc-common.c (c_cannot_inline_tree_fn): Check for an
> 	always_inline attribute on the function decl.

This is OK.

However:

+  if (flag_really_no_inline && always_inline == NULL)

+  if (always_inline == NULL

we generally use "!always_inline" in these cases -- which especially
makes sense here in that the tree returned by lookup_attribute is really
just being used as a boolean.

-- 
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-08-02  1:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-07-26 18:48 [PATCH] fix pr25446 Nathan Froyd
2007-08-02  1:31 ` Mark Mitchell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).