aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJan Hubicka <hubicka@ucw.cz>2014-12-15 23:50:18 +0100
committerJan Hubicka <hubicka@gcc.gnu.org>2014-12-15 22:50:18 +0000
commit2e118f3cd2536e40c46e1b449dbcec3a0f2065c0 (patch)
treec19ee228e68d4f368a2d2afdfe04d9e838523ffc /gcc
parentdaca16d1f07cdba2a6b8ac96e85cbd9c3b8b30bb (diff)
downloadgcc-2e118f3cd2536e40c46e1b449dbcec3a0f2065c0.zip
gcc-2e118f3cd2536e40c46e1b449dbcec3a0f2065c0.tar.gz
gcc-2e118f3cd2536e40c46e1b449dbcec3a0f2065c0.tar.bz2
decl2.c (decl_needed_p): When not optimizing, do not consider external decls as needed.
* decl2.c (decl_needed_p): When not optimizing, do not consider external decls as needed. From-SVN: r218769
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/decl2.c23
2 files changed, 22 insertions, 6 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index afb2483..4c6043e 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+2014-12-15 Jan Hubicka <hubicka@ucw.cz>
+
+ * decl2.c (decl_needed_p): When not optimizing, do not consider external
+ decls as needed.
+
2014-12-15 Jason Merrill <jason@redhat.com>
PR c++/64297
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index 07bdd92..b2123f2 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -1996,19 +1996,30 @@ decl_needed_p (tree decl)
COMDAT until that point. */
gcc_assert (at_eof);
- /* All entities with external linkage that are not COMDAT should be
+ /* All entities with external linkage that are not COMDAT/EXTERN should be
emitted; they may be referred to from other object files. */
- if (TREE_PUBLIC (decl) && !DECL_COMDAT (decl))
+ if (TREE_PUBLIC (decl) && !DECL_COMDAT (decl) && !DECL_REALLY_EXTERN (decl))
return true;
- /* If this entity was used, let the back end see it; it will decide
- whether or not to emit it into the object file. */
- if (TREE_USED (decl))
- return true;
/* Functions marked "dllexport" must be emitted so that they are
visible to other DLLs. */
if (flag_keep_inline_dllexport
&& lookup_attribute ("dllexport", DECL_ATTRIBUTES (decl)))
return true;
+
+ /* When not optimizing, do not bother to produce definitions for extern
+ symbols. */
+ if (DECL_REALLY_EXTERN (decl)
+ && ((TREE_CODE (decl) != FUNCTION_DECL
+ && !optimize)
+ || (TREE_CODE (decl) == FUNCTION_DECL
+ && !opt_for_fn (decl, optimize)))
+ && !lookup_attribute ("always_inline", decl))
+ return false;
+
+ /* If this entity was used, let the back end see it; it will decide
+ whether or not to emit it into the object file. */
+ if (TREE_USED (decl))
+ return true;
/* Virtual functions might be needed for devirtualization. */
if (flag_devirtualize
&& TREE_CODE (decl) == FUNCTION_DECL