OSDN Git Service

PR c++/18416
[pf3gnuchains/gcc-fork.git] / gcc / toplev.c
index b2990bc..29ae065 100644 (file)
@@ -61,7 +61,6 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include "intl.h"
 #include "ggc.h"
 #include "graph.h"
-#include "loop.h"
 #include "regs.h"
 #include "timevar.h"
 #include "diagnostic.h"
@@ -74,7 +73,6 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include "target.h"
 #include "langhooks.h"
 #include "cfglayout.h"
-#include "tree-alias-common.h" 
 #include "cfgloop.h"
 #include "hosthooks.h"
 #include "cgraph.h"
@@ -82,6 +80,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include "coverage.h"
 #include "value-prof.h"
 #include "alloc-pool.h"
+#include "tree-mudflap.h"
 
 #if defined (DWARF2_UNWIND_INFO) || defined (DWARF2_DEBUGGING_INFO)
 #include "dwarf2out.h"
@@ -140,6 +139,10 @@ static const char **save_argv;
 
 const char *main_input_filename;
 
+#ifndef USE_MAPPED_LOCATION
+location_t unknown_location = { NULL, 0 };
+#endif
+
 /* Used to enable -fvar-tracking, -fweb and -frename-registers according
    to optimize and default_debug_hooks in process_options ().  */
 #define AUTODETECT_FLAG_VAR_TRACKING 2
@@ -217,14 +220,9 @@ int optimize_size = 0;
    or 0 if between functions.  */
 tree current_function_decl;
 
-/* Set to the FUNC_BEGIN label of the current function, or NULL_TREE
+/* Set to the FUNC_BEGIN label of the current function, or NULL
    if none.  */
-tree current_function_func_begin_label;
-
-/* A DECL for the current file-scope context.  When using IMA, this heads a
-   chain of FILE_DECLs; currently only C uses it.  */
-
-tree current_file_decl;
+const char * current_function_func_begin_label;
 
 /* Temporarily suppress certain warnings.
    This is set while reading code from a system header file.  */
@@ -273,12 +271,6 @@ int flag_pcc_struct_return = DEFAULT_PCC_STRUCT_RETURN;
 
 int flag_complex_divide_method = 0;
 
-/* Nonzero means performs web construction pass.  When flag_web ==
-   AUTODETECT_FLAG_VAR_TRACKING it will be set according to optimize
-   and default_debug_hooks in process_options ().  */
-
-int flag_web = AUTODETECT_FLAG_VAR_TRACKING;
-
 /* Nonzero means that we don't want inlining by virtue of -fno-inline,
    not just because the tree inliner turned us off.  */
 
@@ -333,14 +325,16 @@ rtx stack_limit_rtx;
    one, unconditionally renumber instruction UIDs.  */
 int flag_renumber_insns = 1;
 
-/* Enable points-to analysis on trees.  */
-enum pta_type flag_tree_points_to = PTA_NONE;
-
 /* Nonzero if we should track variables.  When
    flag_var_tracking == AUTODETECT_FLAG_VAR_TRACKING it will be set according
    to optimize, debug_info_level and debug_hooks in process_options ().  */
 int flag_var_tracking = AUTODETECT_FLAG_VAR_TRACKING;
 
+/* True if the user has tagged the function with the 'section'
+   attribute.  */
+
+bool user_defined_section_attribute = false;
+
 /* Values of the -falign-* flags: how much to align labels in code.
    0 means `use default', 1 means `don't align'.
    For each variable, there is an _log variant which is the power
@@ -418,7 +412,7 @@ int warn_return_type;
 FILE *asm_out_file;
 FILE *aux_info_file;
 FILE *dump_file = NULL;
-FILE *cgraph_dump_file = NULL;
+const char *dump_file_name;
 
 /* The current working directory of a translation.  It's generally the
    directory from which compilation was initiated, but a preprocessed
@@ -535,7 +529,7 @@ read_integral_parameter (const char *p, const char *pname, const int  defval)
   if (*endp != 0)
     {
       if (pname != 0)
-       error ("invalid option argument `%s'", pname);
+       error ("invalid option argument %qs", pname);
       return defval;
     }
 
@@ -543,20 +537,23 @@ read_integral_parameter (const char *p, const char *pname, const int  defval)
 }
 
 /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
-   If X is 0, return -1.
-
-   This should be used via the floor_log2 macro.  */
+   If X is 0, return -1.  */
 
 int
-floor_log2_wide (unsigned HOST_WIDE_INT x)
+floor_log2 (unsigned HOST_WIDE_INT x)
 {
-  int t=0;
+  int t = 0;
+
   if (x == 0)
     return -1;
-  if (sizeof (HOST_WIDE_INT) * 8 > 64)
+
+#ifdef CLZ_HWI
+  t = HOST_BITS_PER_WIDE_INT - 1 - (int) CLZ_HWI (x);
+#else
+  if (HOST_BITS_PER_WIDE_INT > 64)
     if (x >= (unsigned HOST_WIDE_INT) 1 << (t + 64))
       t += 64;
-  if (sizeof (HOST_WIDE_INT) * 8 > 32)
+  if (HOST_BITS_PER_WIDE_INT > 32)
     if (x >= ((unsigned HOST_WIDE_INT) 1) << (t + 32))
       t += 32;
   if (x >= ((unsigned HOST_WIDE_INT) 1) << (t + 16))
@@ -569,21 +566,24 @@ floor_log2_wide (unsigned HOST_WIDE_INT x)
     t += 2;
   if (x >= ((unsigned HOST_WIDE_INT) 1) << (t + 1))
     t += 1;
+#endif
+
   return t;
 }
 
 /* Return the logarithm of X, base 2, considering X unsigned,
-   if X is a power of 2.  Otherwise, returns -1.
-
-   This should be used via the `exact_log2' macro.  */
+   if X is a power of 2.  Otherwise, returns -1.  */
 
 int
-exact_log2_wide (unsigned HOST_WIDE_INT x)
+exact_log2 (unsigned HOST_WIDE_INT x)
 {
-  /* Test for 0 or a power of 2.  */
-  if (x == 0 || x != (x & -x))
+  if (x != (x & -x))
     return -1;
-  return floor_log2_wide (x);
+#ifdef CTZ_HWI
+  return x ? CTZ_HWI (x) : -1;
+#else
+  return floor_log2 (x);
+#endif
 }
 
 /* Handler for fatal signals, such as SIGSEGV.  These are transformed
@@ -594,6 +594,15 @@ static void
 crash_signal (int signo)
 {
   signal (signo, SIG_DFL);
+
+  /* If we crashed while processing an ASM statement, then be a little more
+     graceful.  It's most likely the user's fault.  */
+  if (this_is_asm_operands)
+    {
+      output_operand_lossage ("unrecoverable error");
+      exit (FATAL_EXIT_CODE);
+    }
+
   internal_error ("%s", strsignal (signo));
 }
 
@@ -784,7 +793,7 @@ wrapup_global_declarations (tree *vec, int len)
              if (needed)
                {
                  reconsider = 1;
-                 rest_of_decl_compilation (decl, NULL, 1, 1);
+                 rest_of_decl_compilation (decl, 1, 1);
                }
            }
        }
@@ -810,13 +819,6 @@ check_global_declarations (tree *vec, int len)
     {
       decl = vec[i];
 
-      if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
-         && ! TREE_ASM_WRITTEN (decl))
-       /* Cancel the RTL for this decl so that, if debugging info
-          output for global variables is still to come,
-          this one will be omitted.  */
-       SET_DECL_RTL (decl, NULL_RTX);
-
       /* Warn about any function
         declared static but not defined.
         We don't warn about variables,
@@ -826,14 +828,16 @@ check_global_declarations (tree *vec, int len)
          && DECL_INITIAL (decl) == 0
          && DECL_EXTERNAL (decl)
          && ! DECL_ARTIFICIAL (decl)
+         && ! TREE_NO_WARNING (decl)
          && ! TREE_PUBLIC (decl)
          && (warn_unused_function
              || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
        {
          if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
-           pedwarn ("%J'%F' used but never defined", decl, decl);
+           pedwarn ("%J%qF used but never defined", decl, decl);
          else
-           warning ("%J'%F' declared `static' but never defined", decl, decl);
+           warning ("%J%qF declared %<static%> but never defined",
+                    decl, decl);
          /* This symbol is effectively an "extern" declaration now.  */
          TREE_PUBLIC (decl) = 1;
          assemble_external (decl);
@@ -858,7 +862,7 @@ check_global_declarations (tree *vec, int len)
          && ! (TREE_CODE (decl) == VAR_DECL && DECL_REGISTER (decl))
          /* Otherwise, ask the language.  */
          && lang_hooks.decls.warn_unused_global (decl))
-       warning ("%J'%D' defined but not used", decl, decl);
+       warning ("%J%qD defined but not used", decl, decl);
 
       /* Avoid confusing the debug information machinery when there are
         errors.  */
@@ -879,33 +883,44 @@ warn_deprecated_use (tree node)
     return;
 
   if (DECL_P (node))
-    warning ("`%s' is deprecated (declared at %s:%d)",
-            IDENTIFIER_POINTER (DECL_NAME (node)),
-            DECL_SOURCE_FILE (node), DECL_SOURCE_LINE (node));
+    {
+      expanded_location xloc = expand_location (DECL_SOURCE_LOCATION (node));
+      warning ("%qs is deprecated (declared at %s:%d)",
+              IDENTIFIER_POINTER (DECL_NAME (node)),
+              xloc.file, xloc.line);
+    }
   else if (TYPE_P (node))
     {
       const char *what = NULL;
       tree decl = TYPE_STUB_DECL (node);
 
-      if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE)
-       what = IDENTIFIER_POINTER (TYPE_NAME (node));
-      else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL
-              && DECL_NAME (TYPE_NAME (node)))
-       what = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (node)));
+      if (TYPE_NAME (node))
+       {
+         if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE)
+           what = IDENTIFIER_POINTER (TYPE_NAME (node));
+         else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL
+                  && DECL_NAME (TYPE_NAME (node)))
+           what = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (node)));
+       }
 
-      if (what)
+      if (decl)
        {
-         if (decl)
-           warning ("`%s' is deprecated (declared at %s:%d)", what,
-                    DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
+         expanded_location xloc
+           = expand_location (DECL_SOURCE_LOCATION (decl));
+         if (what)
+           warning ("%qs is deprecated (declared at %s:%d)", what,
+                      xloc.file, xloc.line);
          else
-           warning ("`%s' is deprecated", what);
+           warning ("type is deprecated (declared at %s:%d)",
+                    xloc.file, xloc.line);
        }
-      else if (decl)
-       warning ("type is deprecated (declared at %s:%d)",
-                DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
       else
-       warning ("type is deprecated");
+       {
+         if (what)
+           warning ("%qs is deprecated", what);
+         else
+           warning ("type is deprecated");
+       }
     }
 }
 
@@ -914,15 +929,23 @@ warn_deprecated_use (tree node)
    INPUT_LOCATION accordingly.  */
 
 void
+#ifdef USE_MAPPED_LOCATION
+push_srcloc (location_t fline)
+#else
 push_srcloc (const char *file, int line)
+#endif
 {
   struct file_stack *fs;
 
   fs = xmalloc (sizeof (struct file_stack));
   fs->location = input_location;
   fs->next = input_file_stack;
+#ifdef USE_MAPPED_LOCATION
+  input_location = fline;
+#else
   input_filename = file;
   input_line = line;
+#endif
   input_file_stack = fs;
   input_file_stack_tick++;
 }
@@ -951,6 +974,7 @@ compile_file (void)
 {
   /* Initialize yet another pass.  */
 
+  init_cgraph ();
   init_final (main_input_filename);
   coverage_init (aux_base_name);
 
@@ -980,6 +1004,10 @@ compile_file (void)
      functions in this compilation unit were deferred.  */
   coverage_finish ();
 
+  /* Likewise for mudflap static object registrations.  */
+  if (flag_mudflap)
+    mudflap_finish_file ();
+
   /* Write out any pending weak symbol declarations.  */
 
   weak_finish ();
@@ -1133,7 +1161,7 @@ decode_d_option (const char *arg)
 /* Indexed by enum debug_info_type.  */
 const char *const debug_type_names[] =
 {
-  "none", "stabs", "coff", "dwarf-1", "dwarf-2", "xcoff", "vms"
+  "none", "stabs", "coff", "dwarf-2", "xcoff", "vms"
 };
 
 /* Decode -m switches.  */
@@ -1187,7 +1215,7 @@ set_target_switch (const char *name)
 #endif
 
   if (!valid_target_option)
-    error ("invalid option `%s'", name);
+    error ("invalid option %qs", name);
 }
 
 /* Print version information to FILE.
@@ -1364,7 +1392,7 @@ init_asm_output (const char *name)
       else
        asm_out_file = fopen (asm_file_name, "w+b");
       if (asm_out_file == 0)
-       fatal_error ("can't open %s for writing: %m", asm_file_name);
+       fatal_error ("can%'t open %s for writing: %m", asm_file_name);
     }
 
 #ifdef IO_BUFFER_SIZE
@@ -1471,7 +1499,7 @@ default_pch_valid_p (const void *data_p, size_t len)
              goto make_message;
            }
        }
-      abort ();
+      gcc_unreachable ();
     }
   data += sizeof (target_flags);
   len -= sizeof (target_flags);
@@ -1500,7 +1528,7 @@ default_pch_valid_p (const void *data_p, size_t len)
  make_message:
   {
     char *r;
-    asprintf (&r, _("created and used with differing settings of `-m%s'"),
+    asprintf (&r, _("created and used with differing settings of '-m%s'"),
                  flag_that_differs);
     if (r == NULL)
       return _("out of memory");
@@ -1607,7 +1635,9 @@ process_options (void)
      sets the original filename if appropriate (e.g. foo.i -> foo.c)
      so we can correctly initialize debug output.  */
   no_backend = lang_hooks.post_options (&main_input_filename);
+#ifndef USE_MAPPED_LOCATION
   input_filename = main_input_filename;
+#endif
 
 #ifdef OVERRIDE_OPTIONS
   /* Some machines may reject certain combinations of options.  */
@@ -1652,27 +1682,23 @@ process_options (void)
   if (flag_unroll_all_loops)
     flag_unroll_loops = 1;
 
-  if (flag_unroll_loops)
-    {
-      flag_old_unroll_loops = 0;
-      flag_old_unroll_all_loops = 0;
-    }
-
-  if (flag_old_unroll_all_loops)
-    flag_old_unroll_loops = 1;
-
-  /* Old loop unrolling requires that strength_reduction be on also.  Silently
-     turn on strength reduction here if it isn't already on.  Also, the loop
-     unrolling code assumes that cse will be run after loop, so that must
-     be turned on also.  */
-  if (flag_old_unroll_loops)
-    {
-      flag_strength_reduce = 1;
-      flag_rerun_cse_after_loop = 1;
-    }
+  /* The loop unrolling code assumes that cse will be run after loop.  */
   if (flag_unroll_loops || flag_peel_loops)
     flag_rerun_cse_after_loop = 1;
 
+  /* If explicitly asked to run new loop optimizer, switch off the old
+     one.  */
+  if (flag_loop_optimize2)
+    flag_loop_optimize = 0;
+
+  /* Enable new loop optimizer pass if any of its optimizations is called.  */
+  if (flag_move_loop_invariants
+      || flag_unswitch_loops
+      || flag_peel_loops
+      || flag_unroll_loops
+      || flag_branch_on_count_reg)
+    flag_loop_optimize2 = 1;
+
   if (flag_non_call_exceptions)
     flag_asynchronous_unwind_tables = 1;
   if (flag_asynchronous_unwind_tables)
@@ -1686,6 +1712,17 @@ process_options (void)
   if (flag_value_profile_transformations)
     flag_profile_values = 1;
 
+  /* Speculative prefetching implies the value profiling.  We also switch off
+     the prefetching in the loop optimizer, so that we do not emit double
+     prefetches.  TODO -- we should teach these two to cooperate; the loop
+     based prefetching may sometimes do a better job, especially in connection
+     with reuse analysis.  */
+  if (flag_speculative_prefetching)
+    {
+      flag_profile_values = 1;
+      flag_prefetch_loop_arrays = 0;
+    }
+
   /* Warn about options that are not supported on this machine.  */
 #ifndef INSN_SCHEDULING
   if (flag_schedule_insns || flag_schedule_insns_after_reload)
@@ -1696,8 +1733,6 @@ process_options (void)
     warning ("this target machine does not have delayed branches");
 #endif
 
-  if (flag_tree_based_profiling && flag_test_coverage)
-    sorry ("test-coverage not yet implemented in trees.");
   if (flag_tree_based_profiling && flag_profile_values)
     sorry ("value-based profiling not yet implemented in trees.");
 
@@ -1762,8 +1797,9 @@ process_options (void)
     default_debug_hooks = &vmsdbg_debug_hooks;
 #endif
 
+  debug_hooks = &do_nothing_debug_hooks;
   if (write_symbols == NO_DEBUG)
-    debug_hooks = &do_nothing_debug_hooks;
+    ;
 #if defined(DBX_DEBUGGING_INFO)
   else if (write_symbols == DBX_DEBUG)
     debug_hooks = &dbx_debug_hooks;
@@ -1789,7 +1825,7 @@ process_options (void)
           debug_type_names[write_symbols]);
 
   /* Now we know which debug output will be used so we can set
-     flag_var_tracking, flag_rename_registers and flag_web if the user has
+     flag_var_tracking, flag_rename_registers if the user has
      not specified them.  */
   if (debug_info_level < DINFO_LEVEL_NORMAL
       || debug_hooks->var_location == do_nothing_debug_hooks.var_location)
@@ -1810,10 +1846,6 @@ process_options (void)
     flag_rename_registers = default_debug_hooks->var_location
                            != do_nothing_debug_hooks.var_location;
 
-  if (flag_web == AUTODETECT_FLAG_VAR_TRACKING)
-    flag_web = optimize >= 2 && (default_debug_hooks->var_location
-                                != do_nothing_debug_hooks.var_location);
-
   if (flag_var_tracking == AUTODETECT_FLAG_VAR_TRACKING)
     flag_var_tracking = optimize >= 1;
 
@@ -1824,7 +1856,7 @@ process_options (void)
     {
       aux_info_file = fopen (aux_info_file_name, "w");
       if (aux_info_file == 0)
-       fatal_error ("can't open %s: %m", aux_info_file_name);
+       fatal_error ("can%'t open %s: %m", aux_info_file_name);
     }
 
   if (! targetm.have_named_sections)
@@ -1853,12 +1885,24 @@ process_options (void)
       warning ("-fprefetch-loop-arrays not supported for this target");
       flag_prefetch_loop_arrays = 0;
     }
+  if (flag_speculative_prefetching)
+    {
+      if (flag_speculative_prefetching_set)
+       warning ("-fspeculative-prefetching not supported for this target");
+      flag_speculative_prefetching = 0;
+    }
 #else
   if (flag_prefetch_loop_arrays && !HAVE_prefetch)
     {
       warning ("-fprefetch-loop-arrays not supported for this target (try -march switches)");
       flag_prefetch_loop_arrays = 0;
     }
+  if (flag_speculative_prefetching && !HAVE_prefetch)
+    {
+      if (flag_speculative_prefetching_set)
+       warning ("-fspeculative-prefetching not supported for this target (try -march switches)");
+      flag_speculative_prefetching = 0;
+    }
 #endif
 
   /* This combination of options isn't handled for i386 targets and doesn't
@@ -1891,8 +1935,7 @@ backend_init (void)
                    /* Enable line number info for traceback.  */
                    || debug_info_level > DINFO_LEVEL_NONE
 #endif
-                   || flag_test_coverage
-                   || warn_notreached);
+                   || flag_test_coverage);
 
   init_regs ();
   init_fake_stack_mems ();
@@ -1915,12 +1958,20 @@ backend_init (void)
 static int
 lang_dependent_init (const char *name)
 {
+  location_t save_loc = input_location;
   if (dump_base_name == 0)
-    dump_base_name = name ? name : "gccdump";
+    dump_base_name = name && name[0] ? name : "gccdump";
 
   /* Other front-end initialization.  */
+#ifdef USE_MAPPED_LOCATION
+  input_location = BUILTINS_LOCATION;
+#else
+  input_filename = "<built-in>";
+  input_line = 0;
+#endif
   if (lang_hooks.init () == 0)
     return 0;
+  input_location = save_loc;
 
   init_asm_output (name);
 
@@ -1928,7 +1979,6 @@ lang_dependent_init (const char *name)
      front end is initialized.  */
   init_eh ();
   init_optabs ();
-  init_optimization_passes ();
 
   /* The following initialization functions need to generate rtl, so
      provide a dummy function context for them.  */