diff mbox

[debug-early] fix fortran regressions

Message ID 5425AA19.9080701@redhat.com
State New
Headers show

Commit Message

Aldy Hernandez Sept. 26, 2014, 6:02 p.m. UTC
On 09/26/14 01:29, Richard Biener wrote:

> So - please try dropping push_cfun as you set current_function_decl
> anyway.

Excellent.  Thanks for the clean-up suggestion.

I am also including a small fix to squelch a use-before-def problem.

Committing to branch.  Whine if in violent opposition.
Aldy
commit 7d371b0f69b8ff74a6fd17773dd5fde80687a698
Author: Aldy Hernandez <aldyh@redhat.com>
Date:   Fri Sep 26 08:24:38 2014 -0700

    	* dwarf2out.c (dwarf2out_early_global_decl): Do not set cfun.
    	(gen_variable_die): Set origin_die before we exit early.
diff mbox

Patch

diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 26997b8..339e547 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -19057,6 +19057,7 @@  gen_variable_die (tree decl, tree origin, dw_die_ref context_die)
       gcc_assert (old_die->die_parent == context_die);
       var_die = old_die;
       old_die = NULL;
+      origin_die = NULL;
       goto gen_variable_die_location;
     }
 
@@ -20879,40 +20880,26 @@  dwarf2out_early_global_decl (tree decl)
   bool save = symtab->global_info_ready;
   symtab->global_info_ready = true;
 
-  bool fndecl_was_null = false;
   /* We don't handle TYPE_DECLs.  If required, they'll be reached via
      other DECLs and they can point to template types or other things
      that dwarf2out can't handle when done via dwarf2out_decl.  */
   if (TREE_CODE (decl) != TYPE_DECL
       && TREE_CODE (decl) != PARM_DECL)
     {
+      tree save_fndecl = current_function_decl;
       if (TREE_CODE (decl) == FUNCTION_DECL)
 	{
-	  /* A missing cfun means the symbol is unused and was removed
-	     from the callgraph.  */
+	  /* A missing cfun means the symbol is unused.  */
 	  if (!DECL_STRUCT_FUNCTION (decl))
 	    goto early_decl_exit;
 
-	  if (current_function_decl)
-	    push_cfun (DECL_STRUCT_FUNCTION (decl));
-	  else
-	    {
-	      set_cfun (DECL_STRUCT_FUNCTION (decl));
-	      fndecl_was_null = true;
-	    }
 	  current_function_decl = decl;
 	}
       dw_die_ref die = dwarf2out_decl (decl);
       if (die)
 	die->dumped_early = true;
       if (TREE_CODE (decl) == FUNCTION_DECL)
-	{
-	  if (fndecl_was_null)
-	    set_cfun (NULL);
-	  else
-	    pop_cfun ();
-	  current_function_decl = NULL;
-	}
+	current_function_decl = save_fndecl;
     }
  early_decl_exit:
   symtab->global_info_ready = save;