diff mbox

Avoid a bit o useless work in rest_of_decl_compilation

Message ID 4C3DE5AA.1080105@redhat.com
State New
Headers show

Commit Message

Richard Henderson July 14, 2010, 4:28 p.m. UTC
I noticed this bit of weirdness when I added an assertion that emulated tls
variables should not be assembled.  That check crashed because I surely did
not expect to have to check for VAR_DECL in a function named assemble_variable.

It turns out there was only one place in the compiler silly enough to try
to assemble_variable on a function.

Committed.


r~


        * passes.c (rest_of_decl_compilation): Do not call assemble_variable
        for functions.
        * varasm.c (assemble_variable): Remove early exit for functions;
        assert that we're given a variable.
diff mbox

Patch

diff --git a/gcc/passes.c b/gcc/passes.c
index 8828967..72e9b5a 100644
--- a/gcc/passes.c
+++ b/gcc/passes.c
@@ -194,8 +194,6 @@  rest_of_decl_compilation (tree decl,
 	    ;
 	  else if (TREE_CODE (decl) != FUNCTION_DECL)
 	    varpool_finalize_decl (decl);
-	  else
-	    assemble_variable (decl, top_level, at_end, 0);
 	}
 
 #ifdef ASM_FINISH_DECLARE_OBJECT
diff --git a/gcc/varasm.c b/gcc/varasm.c
index 5fad5f0..55218c4 100644
--- a/gcc/varasm.c
+++ b/gcc/varasm.c
@@ -2150,6 +2150,9 @@  assemble_variable (tree decl, int top_level ATTRIBUTE_UNUSED,
   rtx decl_rtl, symbol;
   section *sect;
 
+  /* This function is supposed to handle VARIABLES.  Ensure we have one.  */
+  gcc_assert (TREE_CODE (decl) == VAR_DECL);
+
   if (! targetm.have_tls
       && TREE_CODE (decl) == VAR_DECL
       && DECL_THREAD_LOCAL_P (decl))
@@ -2188,12 +2191,6 @@  assemble_variable (tree decl, int top_level ATTRIBUTE_UNUSED,
   if (DECL_EXTERNAL (decl))
     return;
 
-  /* Output no assembler code for a function declaration.
-     Only definitions of functions output anything.  */
-
-  if (TREE_CODE (decl) == FUNCTION_DECL)
-    return;
-
   /* Do nothing for global register variables.  */
   if (DECL_RTL_SET_P (decl) && REG_P (DECL_RTL (decl)))
     {