diff mbox

[google/gcc-4_8] Fix ICE with -gsplit-dwarf and FDO

Message ID 20140604220258.B54B41606C1@ccoutant.mtv.corp.google.com
State New
Headers show

Commit Message

Cary Coutant June 4, 2014, 10:02 p.m. UTC
Fix ICE when -gsplit-dwarf is used with -freorder-blocks-and-partition.

When FDO and -freorder-blocks-and-partition are enabled, it's possible
that by the time we get to optimize_location_lists, we have not yet
created any .debug_addr table entries. If -gsplit-dwarf is also enabled,
we still need to assign .debug_addr indexes to the location lists, so
we should be calling index_location_lists even if addr_index_table
is still NULL.

This patch is for the google/gcc-4_8 branch. I will checkin the fix
to trunk and the gcc-4_9 branch once I have a test case to exercise the
failure.

Google ref: b/15417905


2014-06-04  Cary Coutant  <ccoutant@google.com>

gcc/
	* dwarf2out.c (dwarf2out_finish): Call index_location_lists
        even if addr_index_table is NULL.
diff mbox

Patch

Index: gcc/dwarf2out.c
===================================================================
--- gcc/dwarf2out.c	(revision 211246)
+++ gcc/dwarf2out.c	(working copy)
@@ -24297,18 +24297,23 @@  dwarf2out_finish (const char *filename)
 		   dwarf_strict ? DW_AT_macro_info : DW_AT_GNU_macros,
 		   macinfo_section_label);
 
-  if (dwarf_split_debug_info && addr_index_table != NULL)
+  if (dwarf_split_debug_info)
     {
       /* optimize_location_lists calculates the size of the lists,
          so index them first, and assign indices to the entries.
          Although optimize_location_lists will remove entries from
          the table, it only does so for duplicates, and therefore
          only reduces ref_counts to 1.  */
-      unsigned int index = 0;
       index_location_lists (comp_unit_die ());
-      htab_traverse_noresize (addr_index_table,
-                              index_addr_table_entry, &index);
+
+      if (addr_index_table != NULL)
+        {
+          unsigned int index = 0;
+          htab_traverse_noresize (addr_index_table,
+                                  index_addr_table_entry, &index);
+        }
     }
+
   if (have_location_lists)
     optimize_location_lists (comp_unit_die ());