diff options
author | Martin Liska <mliska@suse.cz> | 2016-03-21 20:33:33 +0100 |
---|---|---|
committer | Martin Liska <marxin@gcc.gnu.org> | 2016-03-21 19:33:33 +0000 |
commit | 2a85ddbbf18d68537e919cb5ff5c1621f2bdc0df (patch) | |
tree | 3683a2202a7db807159a26090dac04efd8f048a2 /gcc | |
parent | 9a72f5f6df7150707d83b533ea356319415b919a (diff) | |
download | gcc-2a85ddbbf18d68537e919cb5ff5c1621f2bdc0df.zip gcc-2a85ddbbf18d68537e919cb5ff5c1621f2bdc0df.tar.gz gcc-2a85ddbbf18d68537e919cb5ff5c1621f2bdc0df.tar.bz2 |
Skip static ctors/dtors in IPA ICF (PR ipa/70306)
* gcc.dg/ipa/pr70306.c: New test.
* ipa-icf.c (sem_function::parse): Skip static
constructors and destructors.
From-SVN: r234378
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/ipa-icf.c | 5 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/ipa/pr70306.c | 45 |
4 files changed, 59 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 0bc45fd..cd1e678 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2016-03-21 Martin Liska <mliska@suse.cz> + + * ipa-icf.c (sem_function::parse): Skip static + constructors and destructors. + 2016-03-21 Jakub Jelinek <jakub@redhat.com> PR target/70296 diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf.c index d82eb87..aa6589c 100644 --- a/gcc/ipa-icf.c +++ b/gcc/ipa-icf.c @@ -1697,6 +1697,11 @@ sem_function::parse (cgraph_node *node, bitmap_obstack *stack) if (lookup_attribute_by_prefix ("omp ", DECL_ATTRIBUTES (node->decl)) != NULL) return NULL; + /* PR ipa/70306. */ + if (DECL_STATIC_CONSTRUCTOR (node->decl) + || DECL_STATIC_DESTRUCTOR (node->decl)) + return NULL; + sem_function *f = new sem_function (node, 0, stack); f->init (); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 9bb36d3..f572c9d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2016-03-21 Martin Liska <mliska@suse.cz> + + * gcc.dg/ipa/pr70306.c: New test. + 2016-03-21 Andre Vieira <andre.simoesdiasvieira@arm> * gcc.target/arm/attr-align1.c: Skip if M-profile. diff --git a/gcc/testsuite/gcc.dg/ipa/pr70306.c b/gcc/testsuite/gcc.dg/ipa/pr70306.c new file mode 100644 index 0000000..be18208 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/pr70306.c @@ -0,0 +1,45 @@ +/* { dg-options "-O2 -fdump-ipa-icf" } */ +/* { dg-do run } */ + +int ctor_counter = 1; +int dtor_counter; + +__attribute__((constructor)) +void A() +{ + ctor_counter++; +} + +__attribute__((destructor)) +void B() +{ + if (dtor_counter == 0) + __builtin_abort (); + + dtor_counter--; +} + +__attribute__((constructor)) +static void C() { + ctor_counter++; +} + +__attribute__((destructor)) +static void D() { + if (dtor_counter == 0) + __builtin_abort (); + + dtor_counter--; +} + +int main() +{ + if (ctor_counter != 3) + __builtin_abort (); + + dtor_counter = 2; + + return 0; +} + +/* { dg-final { scan-ipa-dump "Equal symbols: 0" "icf" } } */ |