https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64043

Jan Hubicka <hubicka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at redhat dot com

--- Comment #3 from Jan Hubicka <hubicka at gcc dot gnu.org> ---
OK, the problem is that the unit is compiled without -O2 and -fdevirtualize is
not properly marked as Optimization (have separate patch for this).

However it seems that for units that are not optimized with -fdevirtualize we
can just drop OBJ_TYPE_REF and save some of IL memory?

Jason, does this have chance to interfere with devirtualization required by C++
language that happens at -fno-devirtualize too?

Honza

Index: cp/class.c
===================================================================
--- cp/class.c  (revision 218249)
+++ cp/class.c  (working copy)
@@ -736,7 +736,8 @@ build_vfn_ref (tree instance_ptr, tree i
                   cp_build_addr_expr (aref, tf_warning_or_error));

   /* Remember this as a method reference, for later devirtualization.  */
-  aref = build3 (OBJ_TYPE_REF, TREE_TYPE (aref), aref, instance_ptr, idx);
+  if (flag_devirtualize)
+    aref = build3 (OBJ_TYPE_REF, TREE_TYPE (aref), aref, instance_ptr, idx);

   return aref;
 }
Index: testsuite/g++.dg/lto/pr64043_0.C
===================================================================
--- testsuite/g++.dg/lto/pr64043_0.C    (revision 0)
+++ testsuite/g++.dg/lto/pr64043_0.C    (revision 0)
@@ -0,0 +1,14 @@
+// { dg-lto-do link }
+// { dg-lto-options { { -flto -std=c++11 } } }
+// { dg-extra-ld-options "-r -nostdlib -O2" }
+class Validator
+{
+public:
+  virtual ~Validator ();
+};
+class FooWriter
+{
+  Validator *validator;
+  ~FooWriter ();
+};
+FooWriter::~FooWriter () { delete validator; }

Reply via email to