This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Fix for regression in gcc.c-torture/execute/20011114-1.c


On Dec  5, 2001, Alexandre Oliva <aoliva@redhat.com> wrote:

> I disagree.  The documentation of DECL_ABSTRACT_ORIGIN supports the
> use I'm making of it.  If something else breaks because of this
> choice, it's this something else that should be fixed.  Or perhaps the
> documentation.

However, I must admit the patch had a problem.  For some reason, I had
assumed get_callee_fndecl() was only used by the tree inliner.  I was
wrong, and that's why the decision of following DECL_ABSTRACT_ORIGIN
has caused problems in C++.  Moving that change from get_callee_fndecl
to the tree inliner fixed the C++ regressions while not re-introducing
execute/20011114-1.c (though compile/20011114-1.c, totally unrelated,
still fails, and still gets me confused as to the test results <:-)

Here's the patch, bootstrapped and regression tested on
i686-pc-linux-gnu.  Ok to install?

Index: gcc/ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>

	* tree.c (get_callee_fndecl): Move DECL_ABSTRACT_ORIGIN-following...
	* tree-inline.c (expand_call_inline): ... here.

Index: gcc/tree.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/tree.c,v
retrieving revision 1.226
diff -u -p -r1.226 tree.c
--- gcc/tree.c 2001/12/04 22:49:20 1.226
+++ gcc/tree.c 2001/12/06 17:09:45
@@ -4382,23 +4382,7 @@ get_callee_fndecl (call)
      that `f' is being called.  */
   if (TREE_CODE (addr) == ADDR_EXPR
       && TREE_CODE (TREE_OPERAND (addr, 0)) == FUNCTION_DECL)
-    {
-      tree fn = TREE_OPERAND (addr, 0);
-
-      /* If fn is a declaration of a function in a nested scope that
-         was globally declared inline, we don't set its DECL_INITIAL.
-         However, we can't blindly follow DECL_ABSTRACT_ORIGIN because
-         the C++ front-end uses it for cdtors to refer to their
-         internal declarations, that are not real functions.
-         Fortunately those don't have trees to be saved, so we can tell by
-         checking their DECL_SAVED_TREE.  */
-      if (! DECL_INITIAL (fn)
-	  && DECL_ABSTRACT_ORIGIN (fn)
-	  && DECL_SAVED_TREE (DECL_ABSTRACT_ORIGIN (fn)))
-	fn = DECL_ABSTRACT_ORIGIN (fn);
-
-      return fn;
-    }
+    return TREE_OPERAND (addr, 0);
 
   /* We couldn't figure out what was being called.  */
   return NULL_TREE;
Index: gcc/tree-inline.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/tree-inline.c,v
retrieving revision 1.12
diff -u -p -r1.12 tree-inline.c
--- gcc/tree-inline.c 2001/12/05 23:48:10 1.12
+++ gcc/tree-inline.c 2001/12/06 17:09:45
@@ -807,6 +807,18 @@ expand_call_inline (tp, walk_subtrees, d
   if (!fn)
     return NULL_TREE;
 
+  /* If fn is a declaration of a function in a nested scope that was
+     globally declared inline, we don't set its DECL_INITIAL.
+     However, we can't blindly follow DECL_ABSTRACT_ORIGIN because the
+     C++ front-end uses it for cdtors to refer to their internal
+     declarations, that are not real functions.  Fortunately those
+     don't have trees to be saved, so we can tell by checking their
+     DECL_SAVED_TREE.  */
+  if (! DECL_INITIAL (fn)
+      && DECL_ABSTRACT_ORIGIN (fn)
+      && DECL_SAVED_TREE (DECL_ABSTRACT_ORIGIN (fn)))
+    fn = DECL_ABSTRACT_ORIGIN (fn);
+
   /* Don't try to inline functions that are not well-suited to
      inlining.  */
   if (!inlinable_function_p (fn, id))

-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                  aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist    *Please* write to mailing lists, not to me

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]