[llvm-commits] [llvm-gcc-4.2] r62392 - in /llvm-gcc-4.2/trunk/gcc: cgraph.c cgraph.h cgraphunit.c ipa.c testsuite/gcc.target/i386/mmx-c99.c

Dale Johannesen dalej at apple.com
Fri Jan 16 17:21:16 PST 2009


Author: johannes
Date: Fri Jan 16 19:21:15 2009
New Revision: 62392

URL: http://llvm.org/viewvc/llvm-project?rev=62392&view=rev
Log:
Make sure the MMX/SSE intrinsics get inlined in
C99 mode.  Turning off the gcc inliner broke these,
because cgraph thought "always-inline" functions
had already been inlined and did not pass them through
to llvm's inliner.  It was doing this only for
what it calls "extern inline" functions for historical
reasons; this is semantically equivalent to "inline"
in C99, i.e. you don't have to generate a body.

But actually you should not generate a body for any
"always-inline" functions.  llvm is doing so
which is incorrect, but that's a different bug.


Added:
    llvm-gcc-4.2/trunk/gcc/testsuite/gcc.target/i386/mmx-c99.c
Modified:
    llvm-gcc-4.2/trunk/gcc/cgraph.c
    llvm-gcc-4.2/trunk/gcc/cgraph.h
    llvm-gcc-4.2/trunk/gcc/cgraphunit.c
    llvm-gcc-4.2/trunk/gcc/ipa.c

Modified: llvm-gcc-4.2/trunk/gcc/cgraph.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/cgraph.c?rev=62392&r1=62391&r2=62392&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/cgraph.c (original)
+++ llvm-gcc-4.2/trunk/gcc/cgraph.c Fri Jan 16 19:21:15 2009
@@ -600,7 +600,8 @@
       struct cgraph_node *n = (struct cgraph_node *) *slot;
       if (!n->next_clone && !n->global.inlined_to
 	  && (cgraph_global_info_ready
-	      && (TREE_ASM_WRITTEN (n->decl) || DECL_EXTERNAL (n->decl))))
+                                            /* LLVM LOCAL extern inline */
+	      && (TREE_ASM_WRITTEN (n->decl) || IS_EXTERN_INLINE (n->decl))))
 	kill_body = true;
     }
 
@@ -1183,7 +1184,8 @@
      good optimization is what this optimization is about.  */
 
   else if (!(*targetm.binds_local_p) (node->decl)
-	   && !DECL_COMDAT (node->decl) && !DECL_EXTERNAL (node->decl))
+            /* LLVM LOCAL extern inline */
+	   && !DECL_COMDAT (node->decl) && !IS_EXTERN_INLINE (node->decl))
     avail = AVAIL_OVERWRITABLE;
   else avail = AVAIL_AVAILABLE;
 

Modified: llvm-gcc-4.2/trunk/gcc/cgraph.h
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/cgraph.h?rev=62392&r1=62391&r2=62392&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/cgraph.h (original)
+++ llvm-gcc-4.2/trunk/gcc/cgraph.h Fri Jan 16 19:21:15 2009
@@ -333,4 +333,16 @@
 void cgraph_clone_inlined_nodes (struct cgraph_edge *, bool, bool);
 void cgraph_mark_inline_edge (struct cgraph_edge *, bool);
 bool cgraph_default_inline_p (struct cgraph_node *, const char **);
+
+/* LLVM LOCAL begin 6501843 */
+/* We're no longer running gcc's inliner at all, so the bodies of 
+   used extern always-inline functions must be passed down to the LLVM BE.
+   cgraph used to remove these.  (gcc "extern inline" == c99 "inline") */
+#ifdef ENABLE_LLVM
+#define IS_EXTERN_INLINE(f) (DECL_EXTERNAL(f) && \
+           !lookup_attribute("always_inline", DECL_ATTRIBUTES(f)))
+#else
+#define IS_EXTERN_INLINE(f) (DECL_EXTERNAL(f))
+#endif
+/* LLVM LOCAL end */
 #endif  /* GCC_CGRAPH_H  */

Modified: llvm-gcc-4.2/trunk/gcc/cgraphunit.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/cgraphunit.c?rev=62392&r1=62391&r2=62392&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/cgraphunit.c (original)
+++ llvm-gcc-4.2/trunk/gcc/cgraphunit.c Fri Jan 16 19:21:15 2009
@@ -384,7 +384,8 @@
       n->next_needed = NULL;
       if (!n->global.inlined_to
 	  && !n->alias
-	  && !DECL_EXTERNAL (n->decl))
+         /* LLVM LOCAL extern inline */
+	  && !IS_EXTERN_INLINE (n->decl))
 	{
 	  cgraph_expand_function (n);
 	  output = true;
@@ -847,7 +848,8 @@
 
   if (node->analyzed
       && DECL_SAVED_TREE (node->decl) && !TREE_ASM_WRITTEN (node->decl)
-      && (!DECL_EXTERNAL (node->decl) || node->global.inlined_to))
+        /* LLVM LOCAL extern inline */ 
+     && (!IS_EXTERN_INLINE (node->decl) || node->global.inlined_to))
     {
       if (this_cfun->cfg)
 	{
@@ -1292,21 +1294,24 @@
 	  && (node->needed
 	      || (e && node->reachable))
 	  && !TREE_ASM_WRITTEN (decl)
-	  && !DECL_EXTERNAL (decl))
+          /* LLVM LOCAL extern inline */
+	  && !IS_EXTERN_INLINE (decl))
 	node->output = 1;
       else
 	{
 	  /* We should've reclaimed all functions that are not needed.  */
 #ifdef ENABLE_CHECKING
 	  if (!node->global.inlined_to && DECL_SAVED_TREE (decl)
-	      && !DECL_EXTERNAL (decl))
+            /* LLVM LOCAL extern inline */
+	      && !IS_EXTERN_INLINE (decl))
 	    {
 	      dump_cgraph_node (stderr, node);
 	      internal_error ("failed to reclaim unneeded function");
 	    }
 #endif
 	  gcc_assert (node->global.inlined_to || !DECL_SAVED_TREE (decl)
-		      || DECL_EXTERNAL (decl));
+                       /* LLVM LOCAL extern inline */
+		      || IS_EXTERN_INLINE (decl));
 
 	}
 

Modified: llvm-gcc-4.2/trunk/gcc/ipa.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/ipa.c?rev=62392&r1=62391&r2=62392&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/ipa.c (original)
+++ llvm-gcc-4.2/trunk/gcc/ipa.c Fri Jan 16 19:21:15 2009
@@ -112,7 +112,8 @@
 #endif
   for (node = cgraph_nodes; node; node = node->next)
     if (node->needed && !node->global.inlined_to
-	&& ((!DECL_EXTERNAL (node->decl)) 
+            /* LLVM LOCAL extern inline */
+	&& ((!IS_EXTERN_INLINE (node->decl))
             || !node->analyzed
             || before_inlining_p))
       {
@@ -135,7 +136,8 @@
 	if (!e->callee->aux
 	    && node->analyzed
 	    && (!e->inline_failed || !e->callee->analyzed
-		|| (!DECL_EXTERNAL (e->callee->decl))
+                   /* LLVM LOCAL extern inline */
+		|| !IS_EXTERN_INLINE(e->callee->decl)
                 || before_inlining_p))
 	  {
 	    e->callee->aux = first;
@@ -166,7 +168,9 @@
 	    local_insns = 0;
 	  if (file)
 	    fprintf (file, " %s", cgraph_node_name (node));
-	  if (!node->analyzed || !DECL_EXTERNAL (node->decl)
+	  if (!node->analyzed 
+                 /* LLVM LOCAL extern inline */
+              || !IS_EXTERN_INLINE(node->decl)
 	      || before_inlining_p)
 	    cgraph_remove_node (node);
 	  else

Added: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.target/i386/mmx-c99.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.target/i386/mmx-c99.c?rev=62392&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.target/i386/mmx-c99.c (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.target/i386/mmx-c99.c Fri Jan 16 19:21:15 2009
@@ -0,0 +1,11 @@
+/* LLVM LOCAL file 6501843 */
+/* { dg-do compile { target i?86-*-* x86_64-*-* } } */
+/* { dg-options "-O2 -mmmx -std=c99" } */
+#include <emmintrin.h>
+
+typedef float vFloat __attribute__ ((__vector_size__ (16)));
+
+vFloat t(const float *A) {
+  return _mm_loadu_ps(&A[4]);
+}
+/* { dg-final { scan-assembler-not "call" } } */





More information about the llvm-commits mailing list