Bug 86549 - [meta-bug] -flto -g0 vs. -g issues
Summary: [meta-bug] -flto -g0 vs. -g issues
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: debug (show other bugs)
Version: 9.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code, lto, meta-bug
Depends on: 86736 87187 88046
Blocks:
  Show dependency treegraph
 
Reported: 2018-07-17 12:55 UTC by Richard Biener
Modified: 2019-09-03 04:32 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2018-07-17 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Biener 2018-07-17 12:55:41 UTC
We do have some issues when compiling with LTO and -g0 but link with -g because
of the fact that the debug machinery doesn't consistently avoid creating types
late and with free-lang-data scrapping useful info dwarf2out gets confused.

Example from PR86523:

class a {
  int b;
};
int const c = 0, d = 1, f = 2, g = 3;
struct B {
  typedef a h;
  h i;
};
template <class> B j();
template <class> struct k { static B const e; };
template <class l> B const k<l>::e = j<l>();
inline B m() {
  switch (0) {
  case c:
  case d:
    return k<int>::e;
  case f:
  case g:;
  }
}

And that PRs comment#8 says

That would be fixed by sth like the following but that then hides
issues with consistent -g as we ran into.  It might be instead interesting
to make it more consistently fail by asserting early_dwarf here ...
(but I expect that to blow up in our face)

So I'm not going to fix this right now but will open a new bug for it.

diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index bd45e0b0685..3eaa032bb95 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -23732,12 +23732,13 @@ gen_variable_die (tree decl, tree origin, dw_die_ref context_die)
   else
     add_name_and_src_coords_attributes (var_die, decl, no_linkage_name);
 
-  if ((origin == NULL && !specialization_p)
-      || (origin != NULL
-         && !DECL_ABSTRACT_P (decl_or_origin)
-         && variably_modified_type_p (TREE_TYPE (decl_or_origin),
-                                      decl_function_context
-                                                       (decl_or_origin))))
+  if (early_dwarf
+      && ((origin == NULL && !specialization_p)
+         || (origin != NULL
+             && !DECL_ABSTRACT_P (decl_or_origin)
+             && variably_modified_type_p (TREE_TYPE (decl_or_origin),
+                                          decl_function_context
+                                            (decl_or_origin)))))
     {
       tree type = TREE_TYPE (decl_or_origin);
Comment 1 Jakub Jelinek 2018-07-26 10:58:37 UTC
GCC 8.2 has been released.
Comment 2 Dominique d'Humieres 2018-09-08 08:42:29 UTC
The patch in comment 0 fixes

FAIL: g++.dg/asan/pr62017.C   -O2 -flto  (internal compiler error)
FAIL: g++.dg/asan/pr62017.C   -O2 -flto  (test for excess errors)
FAIL: g++.dg/asan/pr62017.C   -O2 -flto -flto-partition=none  (internal compiler error)
FAIL: g++.dg/asan/pr62017.C   -O2 -flto -flto-partition=none  (test for excess errors)
FAIL: g++.dg/asan/pr78651.C   -O2 -flto  (internal compiler error)
FAIL: g++.dg/asan/pr78651.C   -O2 -flto  (test for excess errors)
FAIL: g++.dg/asan/pr78651.C   -O2 -flto -flto-partition=none  (internal compiler error)
FAIL: g++.dg/asan/pr78651.C   -O2 -flto -flto-partition=none  (test for excess errors)
FAIL: g++.dg/asan/pr81021.C   -O2 -flto  (internal compiler error)
FAIL: g++.dg/asan/pr81021.C   -O2 -flto  (test for excess errors)
FAIL: g++.dg/asan/pr81021.C   -O2 -flto -flto-partition=none  (internal compiler error)
FAIL: g++.dg/asan/pr81021.C   -O2 -flto -flto-partition=none  (test for excess errors)

but not pr87187.
Comment 3 Jakub Jelinek 2019-02-22 15:18:47 UTC
GCC 8.3 has been released.
Comment 4 Richard Biener 2019-03-21 11:18:55 UTC
Making a meta-bug, all known issues are fixed.
Comment 5 Eric Gallager 2019-09-03 04:32:12 UTC
(In reply to Richard Biener from comment #4)
> Making a meta-bug, all known issues are fixed.

...so... closing this, too, then. It can be re-opened if new issues falling under it turn up.