re PR debug/66691 (ICE on valid code at -O3 with -g enabled in simplify_subreg, at...
[gcc.git] / gcc / dumpfile.c
index c2cd89b59aaf6fdaddad5db7fba036add1af0e02..d5f601f139de66d6a1d5020ab8e79867820aff9a 100644 (file)
@@ -1,5 +1,5 @@
 /* Dump infrastructure for optimizations and intermediate representation.
-   Copyright (C) 2012-2014 Free Software Foundation, Inc.
+   Copyright (C) 2012-2015 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -22,6 +22,9 @@ along with GCC; see the file COPYING3.  If not see
 #include "coretypes.h"
 #include "diagnostic-core.h"
 #include "dumpfile.h"
+#include "alias.h"
+#include "symtab.h"
+#include "options.h"
 #include "tree.h"
 #include "gimple-pretty-print.h"
 #include "context.h"
@@ -217,21 +220,54 @@ get_dump_file_info (int phase) const
     return m_extra_dump_files + (phase - TDI_end);
 }
 
+/* Locate the dump_file_info with swtch equal to SWTCH,
+   or return NULL if no such dump_file_info exists.  */
+
+struct dump_file_info *
+gcc::dump_manager::
+get_dump_file_info_by_switch (const char *swtch) const
+{
+  for (unsigned i = 0; i < m_extra_dump_files_in_use; i++)
+    if (0 == strcmp (m_extra_dump_files[i].swtch, swtch))
+      return &m_extra_dump_files[i];
+
+  /* Not found.  */
+  return NULL;
+}
+
 
 /* Return the name of the dump file for the given phase.
+   The caller is responsible for calling free on the returned
+   buffer.
    If the dump is not enabled, returns NULL.  */
 
 char *
 gcc::dump_manager::
 get_dump_file_name (int phase) const
 {
-  char dump_id[10];
   struct dump_file_info *dfi;
 
   if (phase == TDI_none)
     return NULL;
 
   dfi = get_dump_file_info (phase);
+
+  return get_dump_file_name (dfi);
+}
+
+/* Return the name of the dump file for the given dump_file_info.
+   The caller is responsible for calling free on the returned
+   buffer.
+   If the dump is not enabled, returns NULL.  */
+
+char *
+gcc::dump_manager::
+get_dump_file_name (struct dump_file_info *dfi) const
+{
+  char dump_id[10];
+
+  gcc_assert (dfi);
+
   if (dfi->pstate == 0)
     return NULL;