From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2181) id 3EC16385783D; Mon, 21 Sep 2020 22:43:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3EC16385783D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1600728215; bh=uDVYylg6Iv914T5a9jvi+6qRCQYqcUgf1lyppK5TMsk=; h=From:To:Subject:Date:From; b=HJ/k0BKn/G+bCrifiOd2RRq27ieRzbL/o2pfPM92Xj8grjs7jHE2U6ZU8xkmWrvvU sVWs1vWPtiYUfG/kGsZsWIDl0g0um8n1Kl43AHW68yM5vKrsOlMrb1MRwFaUVBRk6D hibe2MzJMVwipXI/pQ8dsf9yrLjiO5/PcHorwWS8= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Jonathan Wakely To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r11-3339] libstdc++: Use __builtin_expect in __glibcxx_assert X-Act-Checkin: gcc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/heads/master X-Git-Oldrev: aecea4158f4e547af349657a3d16cb031a30ec3b X-Git-Newrev: 7db5967f1050eb2b45e920b13d495d92ba4f16f4 Message-Id: <20200921224335.3EC16385783D@sourceware.org> Date: Mon, 21 Sep 2020 22:43:35 +0000 (GMT) X-BeenThere: libstdc++-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Sep 2020 22:43:35 -0000 https://gcc.gnu.org/g:7db5967f1050eb2b45e920b13d495d92ba4f16f4 commit r11-3339-g7db5967f1050eb2b45e920b13d495d92ba4f16f4 Author: Jonathan Wakely Date: Mon Sep 21 23:43:25 2020 +0100 libstdc++: Use __builtin_expect in __glibcxx_assert libstdc++-v3/ChangeLog: * include/bits/c++config (__replacement_assert): Add noreturn attribute. (__glibcxx_assert_impl): Use __builtin_expect to hint that the assertion is expected to pass. Diff: --- libstdc++-v3/include/bits/c++config | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bits/c++config index badf9d01a04..860bf6dbcb3 100644 --- a/libstdc++-v3/include/bits/c++config +++ b/libstdc++-v3/include/bits/c++config @@ -468,7 +468,8 @@ namespace std { // Avoid the use of assert, because we're trying to keep the // include out of the mix. - extern "C++" inline void + extern "C++" _GLIBCXX_NORETURN + inline void __replacement_assert(const char* __file, int __line, const char* __function, const char* __condition) { @@ -478,7 +479,7 @@ namespace std } } #define __glibcxx_assert_impl(_Condition) \ - if (!bool(_Condition)) \ + if (__builtin_expect(!bool(_Condition), false)) \ std::__replacement_assert(__FILE__, __LINE__, __PRETTY_FUNCTION__, \ #_Condition) #endif