public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/24539]  New: inconsistent handling of null-valued language hooks in GCC
@ 2005-10-26 14:28 gary at intrepid dot com
  2005-10-26 15:54 ` [Bug middle-end/24539] " pinskia at gcc dot gnu dot org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: gary at intrepid dot com @ 2005-10-26 14:28 UTC (permalink / raw)
  To: gcc-bugs

Also posted to the GCC mailing list:
http://gcc.gnu.org/ml/gcc/2005-10/msg00932.html
http://gcc.gnu.org/ml/gcc/2005-10/msg00938.html

While working with GCC's language hooks, we found that
certain places in GCC test for a null value of
lang_hooks.callgraph.expand_function, but
cgraph_expand_function() calls the hook directly:


In cgraphunit.c:

/* Expand function specified by NODE.  */

static void
cgraph_expand_function (struct cgraph_node *node)
{
  tree decl = node->decl;

  /* We ought to not compile any inline clones.  */
  gcc_assert (!node->global.inlined_to);

  if (flag_unit_at_a_time)
    announce_function (decl);

  cgraph_lower_function (node);

  /* Generate RTL for the body of DECL.  */
  lang_hooks.callgraph.expand_function (decl);
------------

In toplev.c:


  /* Disable unit-at-a-time mode for frontends not supporting callgraph
     interface.  */
  if (flag_unit_at_a_time && ! lang_hooks.callgraph.expand_function)
    flag_unit_at_a_time = 0;
------------

In function.c:


  /* Possibly warn about unused parameters.
     When frontend does unit-at-a-time, the warning is already
     issued at finalization time.  */
  if (warn_unused_parameter
      && !lang_hooks.callgraph.expand_function)
    do_warn_unused_parameter (current_function_decl);
------------

We tried setting lang_hooks.callgraph.expand_function to NULL:

/* For now, disable unit-at-a-time by setting expand_function to NULL */
#undef LANG_HOOKS_CALLGRAPH_EXPAND_FUNCTION
#define LANG_HOOKS_CALLGRAPH_EXPAND_FUNCTION NULL

which has the desired effect of disabling unit-at-a-time, but
runs aground in cgraph_expand_function() with a segfault,
when it attempts to call lang_hooks.callgraph.expand_function().

It seems that GCC is handling lang_hooks.callgraph.expand_function
in an inconsistent fashion.  Is a null value for expand_function
meaningful?  If it is, then what is the fix for cgraph_expand_function()?

----

In a follow-up note on the GCC list, Dueway Qi notes:

I have found another similar case.
lang_hooks.callgraph.analyze_expr  in  gcc/gcc/cgraphunit.c
    490           if (lang_hooks.callgraph.analyze_expr)
    491             return lang_hooks.callgraph.analyze_expr (tp,
walk_subtrees,
    492                                                       data);
but in another part of this file
    517       if ((unsigned int) TREE_CODE (t) >= LAST_AND_UNUSED_TREE_CODE)
    518         return lang_hooks.callgraph.analyze_expr (tp,
walk_subtrees, data);


-- 
           Summary: inconsistent handling of null-valued language hooks in
                    GCC
           Product: gcc
           Version: 4.0.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: gary at intrepid dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24539


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

end of thread, other threads:[~2011-12-22  1:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-24539-4@http.gcc.gnu.org/bugzilla/>
2011-12-22  1:16 ` [Bug middle-end/24539] inconsistent handling of null-valued language hooks in GCC pinskia at gcc dot gnu.org
2005-10-26 14:28 [Bug c/24539] New: " gary at intrepid dot com
2005-10-26 15:54 ` [Bug middle-end/24539] " pinskia at gcc dot gnu dot org
2005-10-26 16:07 ` gary at intrepid dot com
2005-10-26 16:09 ` pinskia at gcc dot gnu dot org

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).