From patchwork Tue Nov 23 21:30:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 48043 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 255463858425 for ; Tue, 23 Nov 2021 21:31:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 255463858425 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1637703073; bh=YwdwneZApcw9vNliFwFj2NdgQ+dGremWlbSKh+Atlww=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=eu50EXWLFs6jNj0ueDz95zlQOoByD5kz+DyQgbh5ZmLMbsFC2GLTaQk/O/X6PK8pd 833vu8038iY/P6hZfQYN+NgFR+o91iwxBrnGt1R6xDQ1ZqVAC+9TL/CZ867DFg6u4Z luWN6P8CbV6L2Vk372aJqujeblc4HkFsffaaMqzA= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 68E853858C2C for ; Tue, 23 Nov 2021 21:30:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 68E853858C2C Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-532-8t7gJYs3Mn6k_1nyjjYqgA-1; Tue, 23 Nov 2021 16:30:08 -0500 X-MC-Unique: 8t7gJYs3Mn6k_1nyjjYqgA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 05B199F92A; Tue, 23 Nov 2021 21:30:08 +0000 (UTC) Received: from localhost (unknown [10.33.36.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 973095F4E0; Tue, 23 Nov 2021 21:30:07 +0000 (UTC) To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Add effective-target for std::allocator implementation Date: Tue, 23 Nov 2021 21:30:06 +0000 Message-Id: <20211123213006.952292-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-14.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=unavailable autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jonathan Wakely via Gcc-patches From: Jonathan Wakely Reply-To: Jonathan Wakely Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Tested x86_64-linux, pushed to trunk. This allows tests to be skipped if the std::allocator implementation is not __gnu_cxx::new_allocator. The 20_util/allocator/overaligned.cc test requires either C++17 or new_allocator, otherwise we can't guarantee to return overaligned memory. libstdc++-v3/ChangeLog: * testsuite/18_support/50594.cc: Check effective target. * testsuite/20_util/allocator/1.cc: Likewise. * testsuite/20_util/allocator/overaligned.cc: Likewise. * testsuite/23_containers/unordered_map/96088.cc: Likewise. * testsuite/23_containers/unordered_multimap/96088.cc: Likewise. * testsuite/23_containers/unordered_multiset/96088.cc: Likewise. * testsuite/23_containers/unordered_set/96088.cc: Likewise. * testsuite/ext/throw_allocator/check_delete.cc: Likewise. * testsuite/ext/throw_allocator/check_new.cc: Likewise. * testsuite/lib/libstdc++.exp (check_effective_target_std_allocator_new): Define new proc. --- libstdc++-v3/testsuite/18_support/50594.cc | 1 + libstdc++-v3/testsuite/20_util/allocator/1.cc | 7 +++---- libstdc++-v3/testsuite/20_util/allocator/overaligned.cc | 2 +- .../testsuite/23_containers/unordered_map/96088.cc | 1 + .../testsuite/23_containers/unordered_multimap/96088.cc | 1 + .../testsuite/23_containers/unordered_multiset/96088.cc | 1 + .../testsuite/23_containers/unordered_set/96088.cc | 1 + .../testsuite/ext/throw_allocator/check_delete.cc | 1 + libstdc++-v3/testsuite/ext/throw_allocator/check_new.cc | 1 + libstdc++-v3/testsuite/lib/libstdc++.exp | 8 ++++++++ 10 files changed, 19 insertions(+), 5 deletions(-) diff --git a/libstdc++-v3/testsuite/18_support/50594.cc b/libstdc++-v3/testsuite/18_support/50594.cc index a18e8278081..c15e704debe 100644 --- a/libstdc++-v3/testsuite/18_support/50594.cc +++ b/libstdc++-v3/testsuite/18_support/50594.cc @@ -1,5 +1,6 @@ // { dg-options "-fwhole-program" } // { dg-additional-options "-static-libstdc++" { target *-*-mingw* } } +// { dg-require-effective-target std_allocator_new } // { dg-xfail-run-if "AIX operator new" { powerpc-ibm-aix* } } // Copyright (C) 2011-2021 Free Software Foundation, Inc. diff --git a/libstdc++-v3/testsuite/20_util/allocator/1.cc b/libstdc++-v3/testsuite/20_util/allocator/1.cc index ebcd6c28c5f..79e223c13c2 100644 --- a/libstdc++-v3/testsuite/20_util/allocator/1.cc +++ b/libstdc++-v3/testsuite/20_util/allocator/1.cc @@ -17,6 +17,8 @@ // with this library; see the file COPYING3. If not see // . +// { dg-require-effective-target std_allocator_new } + // 20.4.1.1 allocator members #include @@ -35,7 +37,7 @@ struct gnu { }; bool check_new = false; bool check_delete = false; -void* +void* operator new(std::size_t n) THROW(std::bad_alloc) { check_new = true; @@ -59,9 +61,6 @@ void test01() { std::allocator obj; - // NB: These should work for various size allocation and - // deallocations. Currently, they only work as expected for sizes > - // _MAX_BYTES as defined in stl_alloc.h, which happes to be 128. gnu* pobj = obj.allocate(256); VERIFY( check_new ); diff --git a/libstdc++-v3/testsuite/20_util/allocator/overaligned.cc b/libstdc++-v3/testsuite/20_util/allocator/overaligned.cc index fd03d62b238..8c90fcc0e92 100644 --- a/libstdc++-v3/testsuite/20_util/allocator/overaligned.cc +++ b/libstdc++-v3/testsuite/20_util/allocator/overaligned.cc @@ -16,7 +16,7 @@ // . // { dg-options "-faligned-new" } -// { dg-do run { target c++11 } } +// { dg-do run { target { c++11 && { c++17 || std_allocator_new } } } } // { dg-require-cstdint "" } #include diff --git a/libstdc++-v3/testsuite/23_containers/unordered_map/96088.cc b/libstdc++-v3/testsuite/23_containers/unordered_map/96088.cc index 83ca1c0afd6..27c499ed348 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_map/96088.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_map/96088.cc @@ -1,4 +1,5 @@ // { dg-do run { target c++17 } } +// { dg-require-effective-target std_allocator_new } // Copyright (C) 2021 Free Software Foundation, Inc. // diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multimap/96088.cc b/libstdc++-v3/testsuite/23_containers/unordered_multimap/96088.cc index de7f009dadc..eaadd08e7ca 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_multimap/96088.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_multimap/96088.cc @@ -1,4 +1,5 @@ // { dg-do run { target c++17 } } +// { dg-require-effective-target std_allocator_new } // Copyright (C) 2021 Free Software Foundation, Inc. // diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multiset/96088.cc b/libstdc++-v3/testsuite/23_containers/unordered_multiset/96088.cc index b9bbf63b863..aa137ec9302 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_multiset/96088.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_multiset/96088.cc @@ -1,4 +1,5 @@ // { dg-do run { target c++17 } } +// { dg-require-effective-target std_allocator_new } // Copyright (C) 2021 Free Software Foundation, Inc. // diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/96088.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/96088.cc index 83d5475c677..3f0835ce501 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_set/96088.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/96088.cc @@ -1,4 +1,5 @@ // { dg-do run { target c++17 } } +// { dg-require-effective-target std_allocator_new } // Copyright (C) 2021 Free Software Foundation, Inc. // diff --git a/libstdc++-v3/testsuite/ext/throw_allocator/check_delete.cc b/libstdc++-v3/testsuite/ext/throw_allocator/check_delete.cc index f5bc652c9dc..10e5c69edca 100644 --- a/libstdc++-v3/testsuite/ext/throw_allocator/check_delete.cc +++ b/libstdc++-v3/testsuite/ext/throw_allocator/check_delete.cc @@ -18,6 +18,7 @@ // { dg-require-time "" } // { dg-require-cstdint "" } +// { dg-require-effective-target std_allocator_new } #include #include diff --git a/libstdc++-v3/testsuite/ext/throw_allocator/check_new.cc b/libstdc++-v3/testsuite/ext/throw_allocator/check_new.cc index a4e3874d841..4e2a7250e32 100644 --- a/libstdc++-v3/testsuite/ext/throw_allocator/check_new.cc +++ b/libstdc++-v3/testsuite/ext/throw_allocator/check_new.cc @@ -18,6 +18,7 @@ // { dg-require-time "" } // { dg-require-cstdint "" } +// { dg-require-effective-target std_allocator_new } #include #include diff --git a/libstdc++-v3/testsuite/lib/libstdc++.exp b/libstdc++-v3/testsuite/lib/libstdc++.exp index 35ccbe47c39..4f4c78bed24 100644 --- a/libstdc++-v3/testsuite/lib/libstdc++.exp +++ b/libstdc++-v3/testsuite/lib/libstdc++.exp @@ -1338,6 +1338,14 @@ proc check_effective_target_net_ts_ip { } { }] } +# Return 1 if libstdc++ was built as --enable-libstdcxx-allocator=new +proc check_effective_target_std_allocator_new { } { + return [check_v3_target_prop_cached et_std_alloc_new { + set cond "_GLIBCXX_USE_ALLOCATOR_NEW" + return [v3_check_preprocessor_condition std_alloc_new $cond] + }] +} + set additional_prunes "" if { [info exists env(GCC_RUNTEST_PARALLELIZE_DIR)] \