re PR ipa/60854 (inline constructor of extern template)
authorJan Hubicka <hubicka@ucw.cz>
Thu, 17 Apr 2014 02:22:57 +0000 (04:22 +0200)
committerJan Hubicka <hubicka@gcc.gnu.org>
Thu, 17 Apr 2014 02:22:57 +0000 (02:22 +0000)
PR ipa/60854
* ipa.c (symtab_remove_unreachable_nodes): Mark targets of
external aliases alive, too.
* g++.dg/torture/pr60854.C: New testcase.

From-SVN: r209459

gcc/ChangeLog
gcc/ipa.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/torture/pr60854.C [new file with mode: 0644]

index ef1da88..5cff60e 100644 (file)
@@ -1,3 +1,9 @@
+2014-04-16  Jan Hubicka  <hubicka@ucw.cz>
+
+       PR ipa/60854
+       * ipa.c (symtab_remove_unreachable_nodes): Mark targets of
+       external aliases alive, too.
+
 2014-04-16  Andrew  Pinski  <apinski@cavium.com>
 
        * config/host-linux.c (TRY_EMPTY_VM_SPACE): Change aarch64 ilp32
index 26e9b03..3d82a39 100644 (file)
--- a/gcc/ipa.c
+++ b/gcc/ipa.c
@@ -415,7 +415,18 @@ symtab_remove_unreachable_nodes (bool before_inlining_p, FILE *file)
                          || !DECL_EXTERNAL (e->callee->decl)
                          || e->callee->alias
                          || before_inlining_p))
-                   pointer_set_insert (reachable, e->callee);
+                   {
+                     /* Be sure that we will not optimize out alias target
+                        body.  */
+                     if (DECL_EXTERNAL (e->callee->decl)
+                         && e->callee->alias
+                         && before_inlining_p)
+                       {
+                         pointer_set_insert (reachable,
+                                             cgraph_function_node (e->callee));
+                       }
+                     pointer_set_insert (reachable, e->callee);
+                   }
                  enqueue_node (e->callee, &first, reachable);
                }
 
index 8b83cd4..de911fd 100644 (file)
@@ -1,3 +1,8 @@
+2014-04-16  Jan Hubicka  <hubicka@ucw.cz>
+
+       PR ipa/60854
+       * g++.dg/torture/pr60854.C: New testcase.
+
 2014-04-16  Catherine Moore  <clm@codesourcery.com>
 
        * gcc.target/mips/umips-store16-2.c: New test.
diff --git a/gcc/testsuite/g++.dg/torture/pr60854.C b/gcc/testsuite/g++.dg/torture/pr60854.C
new file mode 100644 (file)
index 0000000..fa4b2e7
--- /dev/null
@@ -0,0 +1,13 @@
+template <typename T>
+class MyClass
+{
+public:
+  __attribute__ ((__always_inline__)) inline MyClass () { ; }
+};
+
+extern template class MyClass<double>;
+
+void Func()
+{
+  MyClass<double> x;
+}