* gcc.dg/ipa/pr70306.c: New test.
* ipa-icf.c (sem_function::parse): Skip static
constructors and destructors.
From-SVN: r234378
+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
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 ();
+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.
--- /dev/null
+/* { 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" } } */