]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
lto/106334 - relax assert during WPA tree merging
authorRichard Biener <rguenther@suse.de>
Tue, 19 Jul 2022 08:02:40 +0000 (10:02 +0200)
committerRichard Biener <rguenther@suse.de>
Tue, 19 Jul 2022 09:16:27 +0000 (11:16 +0200)
The dwarf2out map of tree to symbol + offset is populated too early
when streaming in trees so that when WPA tree merging decides to
recycle them the mapping prevails and if we are unlucky the same
address is used for another tree with a symbol + offset DIE to
record.  The following mitigates the resulting ICE by relaxing the
assert, allowing re-use of a slot during WPA.  Delaying the register
would be better but it's already somewhat hairy and uglifying this
further doesn't look too important right now.

PR lto/106334
* dwarf2out.cc (dwarf2out_register_external_die): Allow
map entry re-use during WPA.

gcc/dwarf2out.cc

index e3920c898f5f7a1ace25cd44ed4cc30025fa35de..3ac39c1a5b0a83b050f12c68f7726bafbc145c8d 100644 (file)
@@ -6069,7 +6069,11 @@ dwarf2out_register_external_die (tree decl, const char *sym,
 
   if (!external_die_map)
     external_die_map = hash_map<tree, sym_off_pair>::create_ggc (1000);
-  gcc_checking_assert (!external_die_map->get (decl));
+  /* When we do tree merging during WPA we can end up re-using GC memory
+     as there's currently no way to unregister external DIEs.  Ideally
+     we'd register them only after merging finished but allowing override
+     here is easiest.  See PR106334.  */
+  gcc_checking_assert (flag_wpa || !external_die_map->get (decl));
   sym_off_pair p = { IDENTIFIER_POINTER (get_identifier (sym)), off };
   external_die_map->put (decl, p);
 }