From dbc6ac1e9b10131092a426413e2034782d8cd9b0 Mon Sep 17 00:00:00 2001 From: Alfonso Gregory Date: Sun, 25 Jul 2021 21:44:31 -0400 Subject: [PATCH 01/17] Update memchr.h --- libc/src/string/memchr.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libc/src/string/memchr.h b/libc/src/string/memchr.h index 369475305236d..98246cb4ea032 100644 --- a/libc/src/string/memchr.h +++ b/libc/src/string/memchr.h @@ -13,7 +13,7 @@ namespace __llvm_libc { -void *memchr(const void *src, int c, size_t n); +void *memchr(const void *src, int c, size_t n) noexcept; } // namespace __llvm_libc From 162f8aebe83af1b5496cd11bad6211b6b249c12c Mon Sep 17 00:00:00 2001 From: Alfonso Gregory <83477269+gAlfonso-bit@users.noreply.github.com> Date: Mon, 26 Jul 2021 09:44:16 -0400 Subject: [PATCH 02/17] Patch 1 --- libc/src/__support/common.h | 4 ++-- libc/src/__support/integer_operations.h | 6 ++---- libc/src/assert/__assert_fail.cpp | 11 ++++++----- libc/src/string/memmove.cpp | 2 +- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/libc/src/__support/common.h b/libc/src/__support/common.h index 53a63fc2e9173..b5cd66ae52ca9 100644 --- a/libc/src/__support/common.h +++ b/libc/src/__support/common.h @@ -24,9 +24,9 @@ LLVM_LIBC_FUNCTION_ATTR decltype(__llvm_libc::name) \ __##name##_impl__ __asm__(#name); \ decltype(__llvm_libc::name) name [[gnu::alias(#name)]]; \ - type __##name##_impl__ arglist + type __##name##_impl__ arglist noexcept #else -#define LLVM_LIBC_FUNCTION(type, name, arglist) type name arglist +#define LLVM_LIBC_FUNCTION(type, name, arglist) type name arglist noexcept #endif namespace __llvm_libc { diff --git a/libc/src/__support/integer_operations.h b/libc/src/__support/integer_operations.h index 733fb7ed9ce91..f52c11a4a97e7 100644 --- a/libc/src/__support/integer_operations.h +++ b/libc/src/__support/integer_operations.h @@ -14,10 +14,8 @@ namespace __llvm_libc { template -static inline cpp::EnableIfType::Value, T> integerAbs(T n) { - if (n < 0) - return -n; - return n; +static constexpr inline cpp::EnableIfType::Value, T> integerAbs(T n) { + return (n < 0) ? -n : n; } } // namespace __llvm_libc diff --git a/libc/src/assert/__assert_fail.cpp b/libc/src/assert/__assert_fail.cpp index 614e130276338..5ccb96dc4af47 100644 --- a/libc/src/assert/__assert_fail.cpp +++ b/libc/src/assert/__assert_fail.cpp @@ -18,15 +18,16 @@ namespace __llvm_libc { // This is just a temporary solution to make assert available to internal // llvm libc code. In the future writeToStderr will not exist and __assert_fail // will call fprintf(stderr, ...). -static void writeToStderr(const char *s) { +static void writeToStderr(const char *s) noexcept { size_t length = 0; - for (const char *curr = s; *curr; ++curr, ++length); + for (const char *curr = s; *curr; ++curr) + ++length; __llvm_libc::syscall(SYS_write, 2, s, length); } -LLVM_LIBC_FUNCTION(void, __assert_fail, - (const char *assertion, const char *file, unsigned line, - const char *function)) { +[[noreturn]] LLVM_LIBC_FUNCTION(void, __assert_fail, + (const char *assertion, const char *file, + unsigned line, const char *function)) { writeToStderr(file); writeToStderr(": Assertion failed: '"); writeToStderr(assertion); diff --git a/libc/src/string/memmove.cpp b/libc/src/string/memmove.cpp index ebbe4643e7da6..3e5b493e0f7f2 100644 --- a/libc/src/string/memmove.cpp +++ b/libc/src/string/memmove.cpp @@ -16,7 +16,7 @@ namespace __llvm_libc { static inline void move_byte_forward(char *dest_m, const char *src_m, - size_t count) { + size_t count) noexcept { for (size_t offset = 0; count; --count, ++offset) dest_m[offset] = src_m[offset]; } From 59a1a0d779c249ceb4fcfe2206dbbc4df92f2a8a Mon Sep 17 00:00:00 2001 From: Alfonso Gregory <83477269+gAlfonso-bit@users.noreply.github.com> Date: Mon, 26 Jul 2021 10:42:06 -0400 Subject: [PATCH 03/17] First batch --- libc/src/ctype/ctype_utils.h | 12 ++++++------ libc/src/ctype/isalnum.cpp | 4 +++- libc/src/ctype/isalpha.cpp | 4 +++- libc/src/ctype/isalpha.h | 2 +- libc/src/ctype/isascii.cpp | 4 +++- libc/src/ctype/isascii.h | 2 +- libc/src/ctype/isblank.cpp | 3 +-- libc/src/ctype/isblank.h | 2 +- libc/src/ctype/iscntrl.cpp | 2 +- libc/src/ctype/iscntrl.h | 2 +- libc/src/ctype/isdigit.cpp | 4 +++- libc/src/ctype/isdigit.h | 2 +- libc/src/ctype/isgraph.cpp | 4 +++- libc/src/ctype/isgraph.h | 2 +- libc/src/ctype/islower.cpp | 4 +++- libc/src/ctype/islower.h | 2 +- libc/src/ctype/isprint.cpp | 2 +- libc/src/ctype/isprint.h | 2 +- libc/src/ctype/ispunct.cpp | 3 ++- libc/src/ctype/ispunct.h | 2 +- libc/src/ctype/isspace.cpp | 2 +- libc/src/ctype/isspace.h | 2 +- libc/src/ctype/isupper.cpp | 4 +++- libc/src/ctype/isupper.h | 2 +- libc/src/ctype/isxdigit.cpp | 2 +- libc/src/ctype/isxdigit.h | 2 +- libc/src/ctype/toascii.h | 2 +- libc/src/ctype/tolower.cpp | 2 +- libc/src/ctype/tolower.h | 2 +- libc/src/ctype/toupper.cpp | 2 +- libc/src/ctype/toupper.h | 2 +- 31 files changed, 51 insertions(+), 37 deletions(-) diff --git a/libc/src/ctype/ctype_utils.h b/libc/src/ctype/ctype_utils.h index 6238bd32d9f8c..b8457227aa832 100644 --- a/libc/src/ctype/ctype_utils.h +++ b/libc/src/ctype/ctype_utils.h @@ -18,17 +18,17 @@ namespace internal { // of a function call by inlining them. // ------------------------------------------------------ -static inline int isalpha(unsigned ch) { return (ch | 32) - 'a' < 26; } +static constexpr int isalpha(unsigned ch) { return (ch | 32) - 'a' < 26; } -static inline int isdigit(unsigned ch) { return (ch - '0') < 10; } +static constexpr int isdigit(unsigned ch) { return (ch - '0') < 10; } -static inline int isalnum(unsigned ch) { return isalpha(ch) || isdigit(ch); } +static constexpr int isalnum(unsigned ch) { return isalpha(ch) || isdigit(ch); } -static inline int isgraph(unsigned ch) { return 0x20 < ch && ch < 0x7f; } +static constexpr int isgraph(unsigned ch) { return 0x20 < ch && ch < 0x7f; } -static inline int islower(unsigned ch) { return (ch - 'a') < 26; } +static constexpr int islower(unsigned ch) { return (ch - 'a') < 26; } -static inline int isupper(unsigned ch) { return (ch - 'A') < 26; } +static constexpr int isupper(unsigned ch) { return (ch - 'A') < 26; } } // namespace internal } // namespace __llvm_libc diff --git a/libc/src/ctype/isalnum.cpp b/libc/src/ctype/isalnum.cpp index 3e8da722c674a..aae0112adaf73 100644 --- a/libc/src/ctype/isalnum.cpp +++ b/libc/src/ctype/isalnum.cpp @@ -15,6 +15,8 @@ namespace __llvm_libc { // TODO: Currently restricted to default locale. // These should be extended using locale information. -LLVM_LIBC_FUNCTION(int, isalnum, (int c)) { return internal::isalnum(c); } +LLVM_LIBC_FUNCTION(int, isalnum, (int c)) { + return internal::isalnum(static_cast(c)); +} } // namespace __llvm_libc diff --git a/libc/src/ctype/isalpha.cpp b/libc/src/ctype/isalpha.cpp index cecf1b516939d..b019377cf5499 100644 --- a/libc/src/ctype/isalpha.cpp +++ b/libc/src/ctype/isalpha.cpp @@ -15,6 +15,8 @@ namespace __llvm_libc { // TODO: Currently restricted to default locale. // These should be extended using locale information. -LLVM_LIBC_FUNCTION(int, isalpha, (int c)) { return internal::isalpha(c); } +LLVM_LIBC_FUNCTION(int, isalpha, (int c)) { + return internal::isalpha(static_cast(c)); +} } // namespace __llvm_libc diff --git a/libc/src/ctype/isalpha.h b/libc/src/ctype/isalpha.h index d5697a39e9aa5..c1f1f9e9ed054 100644 --- a/libc/src/ctype/isalpha.h +++ b/libc/src/ctype/isalpha.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -int isalpha(int c); +int isalpha(int c) noexcept; } // namespace __llvm_libc diff --git a/libc/src/ctype/isascii.cpp b/libc/src/ctype/isascii.cpp index c12915ecd6ee3..d7f00dcd0b2e9 100644 --- a/libc/src/ctype/isascii.cpp +++ b/libc/src/ctype/isascii.cpp @@ -12,6 +12,8 @@ namespace __llvm_libc { -LLVM_LIBC_FUNCTION(int, isascii, (int c)) { return (c & (~0x7f)) == 0; } +LLVM_LIBC_FUNCTION(int, isascii, (int c)) { + return static_cast(c) <= 0x7f; +} } // namespace __llvm_libc diff --git a/libc/src/ctype/isascii.h b/libc/src/ctype/isascii.h index 7e31b3c6ca4dd..ce328f2a2467e 100644 --- a/libc/src/ctype/isascii.h +++ b/libc/src/ctype/isascii.h @@ -13,7 +13,7 @@ namespace __llvm_libc { -int isascii(int c); +int isascii(int c) noexcept; } // namespace __llvm_libc diff --git a/libc/src/ctype/isblank.cpp b/libc/src/ctype/isblank.cpp index 1c3061379b293..4e3d0d6297bbd 100644 --- a/libc/src/ctype/isblank.cpp +++ b/libc/src/ctype/isblank.cpp @@ -15,8 +15,7 @@ namespace __llvm_libc { // TODO: Currently restricted to default locale. // These should be extended using locale information. LLVM_LIBC_FUNCTION(int, isblank, (int c)) { - const unsigned char ch = static_cast(c); - return ch == ' ' || ch == '\t'; + return c == ' ' || c == '\t'; } } // namespace __llvm_libc diff --git a/libc/src/ctype/isblank.h b/libc/src/ctype/isblank.h index 0554322d08251..ac706d60588f9 100644 --- a/libc/src/ctype/isblank.h +++ b/libc/src/ctype/isblank.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -int isblank(int c); +int isblank(int c) noexcept; } // namespace __llvm_libc diff --git a/libc/src/ctype/iscntrl.cpp b/libc/src/ctype/iscntrl.cpp index b061199c47ec5..d4a9491e1e05f 100644 --- a/libc/src/ctype/iscntrl.cpp +++ b/libc/src/ctype/iscntrl.cpp @@ -15,7 +15,7 @@ namespace __llvm_libc { // TODO: Currently restricted to default locale. // These should be extended using locale information. LLVM_LIBC_FUNCTION(int, iscntrl, (int c)) { - const unsigned char ch = static_cast(c); + const unsigned ch = static_cast(c); return ch < 0x20 || ch == 0x7f; } diff --git a/libc/src/ctype/iscntrl.h b/libc/src/ctype/iscntrl.h index 26f094053a28a..676123e269d47 100644 --- a/libc/src/ctype/iscntrl.h +++ b/libc/src/ctype/iscntrl.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -int iscntrl(int c); +int iscntrl(int c) noexcept; } // namespace __llvm_libc diff --git a/libc/src/ctype/isdigit.cpp b/libc/src/ctype/isdigit.cpp index 8471e4b5569a4..dc746860b7e21 100644 --- a/libc/src/ctype/isdigit.cpp +++ b/libc/src/ctype/isdigit.cpp @@ -14,6 +14,8 @@ namespace __llvm_libc { // TODO: Currently restricted to default locale. // These should be extended using locale information. -LLVM_LIBC_FUNCTION(int, isdigit, (int c)) { return internal::isdigit(c); } +LLVM_LIBC_FUNCTION(int, isdigit, (int c)) { + return internal::isdigit(static_cast(c)); +} } // namespace __llvm_libc diff --git a/libc/src/ctype/isdigit.h b/libc/src/ctype/isdigit.h index 32a76235e0592..a0d1aa4d8181b 100644 --- a/libc/src/ctype/isdigit.h +++ b/libc/src/ctype/isdigit.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -int isdigit(int c); +int isdigit(int c) noexcept; } // namespace __llvm_libc diff --git a/libc/src/ctype/isgraph.cpp b/libc/src/ctype/isgraph.cpp index 2bb6a57da4073..741ae96ef3c48 100644 --- a/libc/src/ctype/isgraph.cpp +++ b/libc/src/ctype/isgraph.cpp @@ -15,6 +15,8 @@ namespace __llvm_libc { // TODO: Currently restricted to default locale. // These should be extended using locale information. -LLVM_LIBC_FUNCTION(int, isgraph, (int c)) { return internal::isgraph(c); } +LLVM_LIBC_FUNCTION(int, isgraph, (int c)) { + return internal::isgraph(static_cast(c)); +} } // namespace __llvm_libc diff --git a/libc/src/ctype/isgraph.h b/libc/src/ctype/isgraph.h index 421d0ffc4488b..9eb47aa3d9372 100644 --- a/libc/src/ctype/isgraph.h +++ b/libc/src/ctype/isgraph.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -int isgraph(int c); +int isgraph(int c) noexcept; } // namespace __llvm_libc diff --git a/libc/src/ctype/islower.cpp b/libc/src/ctype/islower.cpp index 907a322174969..230b10f3f7381 100644 --- a/libc/src/ctype/islower.cpp +++ b/libc/src/ctype/islower.cpp @@ -15,6 +15,8 @@ namespace __llvm_libc { // TODO: Currently restricted to default locale. // These should be extended using locale information. -LLVM_LIBC_FUNCTION(int, islower, (int c)) { return internal::islower(c); } +LLVM_LIBC_FUNCTION(int, islower, (int c)) { + return internal::islower(static_cast(c)); +} } // namespace __llvm_libc diff --git a/libc/src/ctype/islower.h b/libc/src/ctype/islower.h index 7643542fb7a99..7905506ad05cc 100644 --- a/libc/src/ctype/islower.h +++ b/libc/src/ctype/islower.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -int islower(int c); +int islower(int c) noexcept; } // namespace __llvm_libc diff --git a/libc/src/ctype/isprint.cpp b/libc/src/ctype/isprint.cpp index a80500b133c4f..a155b95ca1ef6 100644 --- a/libc/src/ctype/isprint.cpp +++ b/libc/src/ctype/isprint.cpp @@ -15,7 +15,7 @@ namespace __llvm_libc { // TODO: Currently restricted to default locale. // These should be extended using locale information. LLVM_LIBC_FUNCTION(int, isprint, (int c)) { - const unsigned ch = c; + const unsigned ch = static_cast(c); return (ch - ' ') < 95; } diff --git a/libc/src/ctype/isprint.h b/libc/src/ctype/isprint.h index 17ed56ef25340..97daf4b908b1d 100644 --- a/libc/src/ctype/isprint.h +++ b/libc/src/ctype/isprint.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -int isprint(int c); +int isprint(int c) noexcept; } // namespace __llvm_libc diff --git a/libc/src/ctype/ispunct.cpp b/libc/src/ctype/ispunct.cpp index 064b7b07c6e6a..f74967201e169 100644 --- a/libc/src/ctype/ispunct.cpp +++ b/libc/src/ctype/ispunct.cpp @@ -16,7 +16,8 @@ namespace __llvm_libc { // TODO: Currently restricted to default locale. // These should be extended using locale information. LLVM_LIBC_FUNCTION(int, ispunct, (int c)) { - return !internal::isalnum(c) && internal::isgraph(c); + const unsigned ch = static_cast(c); + return !internal::isalnum(ch) && internal::isgraph(ch); } } // namespace __llvm_libc diff --git a/libc/src/ctype/ispunct.h b/libc/src/ctype/ispunct.h index 23cc08a0bac9c..265524d65711b 100644 --- a/libc/src/ctype/ispunct.h +++ b/libc/src/ctype/ispunct.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -int ispunct(int c); +int ispunct(int c) noexcept; } // namespace __llvm_libc diff --git a/libc/src/ctype/isspace.cpp b/libc/src/ctype/isspace.cpp index 4a269ef29bf2f..85bed92231185 100644 --- a/libc/src/ctype/isspace.cpp +++ b/libc/src/ctype/isspace.cpp @@ -15,7 +15,7 @@ namespace __llvm_libc { // TODO: Currently restricted to default locale. // These should be extended using locale information. LLVM_LIBC_FUNCTION(int, isspace, (int c)) { - const unsigned ch = c; + const unsigned ch = static_cast(c); return ch == ' ' || (ch - '\t') < 5; } diff --git a/libc/src/ctype/isspace.h b/libc/src/ctype/isspace.h index d919e9e7d972b..ef49dea7462df 100644 --- a/libc/src/ctype/isspace.h +++ b/libc/src/ctype/isspace.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -int isspace(int c); +int isspace(int c) noexcept; } // namespace __llvm_libc diff --git a/libc/src/ctype/isupper.cpp b/libc/src/ctype/isupper.cpp index f1c56fc942f68..e429dc20592ee 100644 --- a/libc/src/ctype/isupper.cpp +++ b/libc/src/ctype/isupper.cpp @@ -15,6 +15,8 @@ namespace __llvm_libc { // TODO: Currently restricted to default locale. // These should be extended using locale information. -LLVM_LIBC_FUNCTION(int, isupper, (int c)) { return internal::isupper(c); } +LLVM_LIBC_FUNCTION(int, isupper, (int c)) { + return internal::isupper(static_cast(c)); +} } // namespace __llvm_libc diff --git a/libc/src/ctype/isupper.h b/libc/src/ctype/isupper.h index 7a1f2270943a9..83a9df3044c57 100644 --- a/libc/src/ctype/isupper.h +++ b/libc/src/ctype/isupper.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -int isupper(int c); +int isupper(int c) noexcept; } // namespace __llvm_libc diff --git a/libc/src/ctype/isxdigit.cpp b/libc/src/ctype/isxdigit.cpp index 5ee1b1090b778..cf9b912ca76fc 100644 --- a/libc/src/ctype/isxdigit.cpp +++ b/libc/src/ctype/isxdigit.cpp @@ -16,7 +16,7 @@ namespace __llvm_libc { // TODO: Currently restricted to default locale. // These should be extended using locale information. LLVM_LIBC_FUNCTION(int, isxdigit, (int c)) { - const unsigned ch = c; + const unsigned ch = static_cast(c); return internal::isdigit(ch) || (ch | 32) - 'a' < 6; } diff --git a/libc/src/ctype/isxdigit.h b/libc/src/ctype/isxdigit.h index a332ecc1018ff..16a12c1afdd42 100644 --- a/libc/src/ctype/isxdigit.h +++ b/libc/src/ctype/isxdigit.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -int isxdigit(int c); +int isxdigit(int c) noexcept; } // namespace __llvm_libc diff --git a/libc/src/ctype/toascii.h b/libc/src/ctype/toascii.h index c3f48a38d84c9..59bac6770b844 100644 --- a/libc/src/ctype/toascii.h +++ b/libc/src/ctype/toascii.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -int toascii(int c); +int toascii(int c) noexcept; } // namespace __llvm_libc diff --git a/libc/src/ctype/tolower.cpp b/libc/src/ctype/tolower.cpp index c01f4f0ded81d..ea64d83881076 100644 --- a/libc/src/ctype/tolower.cpp +++ b/libc/src/ctype/tolower.cpp @@ -16,7 +16,7 @@ namespace __llvm_libc { // TODO: Currently restricted to default locale. // These should be extended using locale information. LLVM_LIBC_FUNCTION(int, tolower, (int c)) { - if (internal::isupper(c)) + if (internal::isupper(static_cast(c))) return c + 'a' - 'A'; return c; } diff --git a/libc/src/ctype/tolower.h b/libc/src/ctype/tolower.h index 97e675c558252..d88be0e6f9551 100644 --- a/libc/src/ctype/tolower.h +++ b/libc/src/ctype/tolower.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -int tolower(int c); +int tolower(int c) noexcept; } // namespace __llvm_libc diff --git a/libc/src/ctype/toupper.cpp b/libc/src/ctype/toupper.cpp index 254befc38f30a..fac1959d57b1e 100644 --- a/libc/src/ctype/toupper.cpp +++ b/libc/src/ctype/toupper.cpp @@ -16,7 +16,7 @@ namespace __llvm_libc { // TODO: Currently restricted to default locale. // These should be extended using locale information. LLVM_LIBC_FUNCTION(int, toupper, (int c)) { - if (internal::islower(c)) + if (internal::islower(static_cast(c))) return c + 'A' - 'a'; return c; } diff --git a/libc/src/ctype/toupper.h b/libc/src/ctype/toupper.h index a21b0cf79d955..eac891d4d5949 100644 --- a/libc/src/ctype/toupper.h +++ b/libc/src/ctype/toupper.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -int toupper(int c); +int toupper(int c) noexcept; } // namespace __llvm_libc From b565df0ded41ce4667f10cfc0601cfeb6e212ced Mon Sep 17 00:00:00 2001 From: Alfonso Gregory <83477269+gAlfonso-bit@users.noreply.github.com> Date: Mon, 26 Jul 2021 11:08:07 -0400 Subject: [PATCH 04/17] Round 2 --- libc/src/errno/__errno_location.h | 2 +- libc/src/fenv/feclearexcept.h | 2 +- libc/src/fenv/fegetenv.h | 2 +- libc/src/fenv/fegetexceptflag.h | 2 +- libc/src/fenv/fegetround.h | 2 +- libc/src/fenv/feholdexcept.h | 2 +- libc/src/fenv/feraiseexcept.h | 2 +- libc/src/fenv/fesetenv.h | 2 +- libc/src/fenv/fesetexceptflag.h | 2 +- libc/src/fenv/fesetround.h | 2 +- libc/src/fenv/fetestexcept.h | 2 +- libc/src/fenv/feupdateenv.h | 2 +- libc/utils/FPUtil/x86_64/FEnvImpl.h | 45 +++++++++++++++-------------- libc/utils/FPUtil/x86_64/FMA.h | 8 ++--- 14 files changed, 39 insertions(+), 38 deletions(-) diff --git a/libc/src/errno/__errno_location.h b/libc/src/errno/__errno_location.h index 20be3fcf812ae..edc98535f63ef 100644 --- a/libc/src/errno/__errno_location.h +++ b/libc/src/errno/__errno_location.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -int *__errno_location(); +int *__errno_location() noexcept; } // namespace __llvm_libc diff --git a/libc/src/fenv/feclearexcept.h b/libc/src/fenv/feclearexcept.h index fa771cee32a18..3266db3050ab7 100644 --- a/libc/src/fenv/feclearexcept.h +++ b/libc/src/fenv/feclearexcept.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -int feclearexcept(int); +int feclearexcept(int) noexcept; } // namespace __llvm_libc diff --git a/libc/src/fenv/fegetenv.h b/libc/src/fenv/fegetenv.h index e1001682a42bb..3849a9bbd88ee 100644 --- a/libc/src/fenv/fegetenv.h +++ b/libc/src/fenv/fegetenv.h @@ -13,7 +13,7 @@ namespace __llvm_libc { -int fegetenv(fenv_t *); +int fegetenv(fenv_t *) noexcept; } // namespace __llvm_libc diff --git a/libc/src/fenv/fegetexceptflag.h b/libc/src/fenv/fegetexceptflag.h index 20913cb7a22f8..e173b4b722cf4 100644 --- a/libc/src/fenv/fegetexceptflag.h +++ b/libc/src/fenv/fegetexceptflag.h @@ -13,7 +13,7 @@ namespace __llvm_libc { -int fegetexceptflag(fexcept_t *, int excepts); +int fegetexceptflag(fexcept_t *, int excepts) noexcept; } // namespace __llvm_libc diff --git a/libc/src/fenv/fegetround.h b/libc/src/fenv/fegetround.h index 1bc79cbf5a6c4..7934dea2beaf5 100644 --- a/libc/src/fenv/fegetround.h +++ b/libc/src/fenv/fegetround.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -int fegetround(); +int fegetround() noexcept; } // namespace __llvm_libc diff --git a/libc/src/fenv/feholdexcept.h b/libc/src/fenv/feholdexcept.h index cfb86b54ff49e..5ac71e1d1c65b 100644 --- a/libc/src/fenv/feholdexcept.h +++ b/libc/src/fenv/feholdexcept.h @@ -13,7 +13,7 @@ namespace __llvm_libc { -int feholdexcept(fenv_t *); +int feholdexcept(fenv_t *) noexcept; } // namespace __llvm_libc diff --git a/libc/src/fenv/feraiseexcept.h b/libc/src/fenv/feraiseexcept.h index 5c9eacf462d49..446b255243eba 100644 --- a/libc/src/fenv/feraiseexcept.h +++ b/libc/src/fenv/feraiseexcept.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -int feraiseexcept(int); +int feraiseexcept(int) noexcept; } // namespace __llvm_libc diff --git a/libc/src/fenv/fesetenv.h b/libc/src/fenv/fesetenv.h index 316ecee41996e..fc6d612f193a2 100644 --- a/libc/src/fenv/fesetenv.h +++ b/libc/src/fenv/fesetenv.h @@ -13,7 +13,7 @@ namespace __llvm_libc { -int fesetenv(const fenv_t *); +int fesetenv(const fenv_t *) noexcept; } // namespace __llvm_libc diff --git a/libc/src/fenv/fesetexceptflag.h b/libc/src/fenv/fesetexceptflag.h index 0e6497abafaed..05dfe59a8e54b 100644 --- a/libc/src/fenv/fesetexceptflag.h +++ b/libc/src/fenv/fesetexceptflag.h @@ -13,7 +13,7 @@ namespace __llvm_libc { -int fesetexceptflag(const fexcept_t *, int excepts); +int fesetexceptflag(const fexcept_t *, int excepts) noexcept; } // namespace __llvm_libc diff --git a/libc/src/fenv/fesetround.h b/libc/src/fenv/fesetround.h index 148a5eabcf3d5..6ad8c24f045d6 100644 --- a/libc/src/fenv/fesetround.h +++ b/libc/src/fenv/fesetround.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -int fesetround(int); +int fesetround(int) noexcept; } // namespace __llvm_libc diff --git a/libc/src/fenv/fetestexcept.h b/libc/src/fenv/fetestexcept.h index fb3e4045dd6b0..f67796343ae63 100644 --- a/libc/src/fenv/fetestexcept.h +++ b/libc/src/fenv/fetestexcept.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -int fetestexcept(int); +int fetestexcept(int) noexcept; } // namespace __llvm_libc diff --git a/libc/src/fenv/feupdateenv.h b/libc/src/fenv/feupdateenv.h index 1599c01ebddff..9e2d6cec67e69 100644 --- a/libc/src/fenv/feupdateenv.h +++ b/libc/src/fenv/feupdateenv.h @@ -13,7 +13,7 @@ namespace __llvm_libc { -int feupdateenv(const fenv_t *); +int feupdateenv(const fenv_t *) noexcept; } // namespace __llvm_libc diff --git a/libc/utils/FPUtil/x86_64/FEnvImpl.h b/libc/utils/FPUtil/x86_64/FEnvImpl.h index fae74bb5da9bc..f628d3211bb4b 100644 --- a/libc/utils/FPUtil/x86_64/FEnvImpl.h +++ b/libc/utils/FPUtil/x86_64/FEnvImpl.h @@ -61,7 +61,7 @@ static constexpr uint16_t MXCSRExceptionContolBitPoistion = 7; // Exception flags are individual bits in the corresponding registers. // So, we just OR the bit values to get the full set of exceptions. -static inline uint16_t getStatusValueForExcept(int excepts) { +static constexpr uint16_t getStatusValueForExcept(int excepts) { // We will make use of the fact that exception control bits are single // bit flags in the control registers. return (excepts & FE_INVALID ? ExceptionFlags::Invalid : 0) | @@ -74,7 +74,7 @@ static inline uint16_t getStatusValueForExcept(int excepts) { (excepts & FE_INEXACT ? ExceptionFlags::Inexact : 0); } -static inline int exceptionStatusToMacro(uint16_t status) { +static constexpr int exceptionStatusToMacro(uint16_t status) { return (status & ExceptionFlags::Invalid ? FE_INVALID : 0) | #ifdef __FE_DENORM (status & ExceptionFlags::Denormal ? __FE_DENORM : 0) | @@ -107,53 +107,54 @@ static_assert( sizeof(fenv_t) == sizeof(FPState), "Internal floating point state does not match the public fenv_t type."); -static inline uint16_t getX87ControlWord() { +static inline uint16_t getX87ControlWord() noexcept { uint16_t w; __asm__ __volatile__("fnstcw %0" : "=m"(w)::); SANITIZER_MEMORY_INITIALIZED(&w, sizeof(w)); return w; } -static inline void writeX87ControlWord(uint16_t w) { +static inline void writeX87ControlWord(uint16_t w) noexcept { __asm__ __volatile__("fldcw %0" : : "m"(w) :); } -static inline uint16_t getX87StatusWord() { +static inline uint16_t getX87StatusWord() noexcept { uint16_t w; __asm__ __volatile__("fnstsw %0" : "=m"(w)::); SANITIZER_MEMORY_INITIALIZED(&w, sizeof(w)); return w; } -static inline void clearX87Exceptions() { +static inline void clearX87Exceptions() noexcept { __asm__ __volatile__("fnclex" : : :); } -static inline uint32_t getMXCSR() { +static inline uint32_t getMXCSR() noexcept { uint32_t w; __asm__ __volatile__("stmxcsr %0" : "=m"(w)::); SANITIZER_MEMORY_INITIALIZED(&w, sizeof(w)); return w; } -static inline void writeMXCSR(uint32_t w) { +static inline void writeMXCSR(uint32_t w) noexcept { __asm__ __volatile__("ldmxcsr %0" : : "m"(w) :); } -static inline void getX87StateDescriptor(X87StateDescriptor &s) { +static inline void getX87StateDescriptor(X87StateDescriptor &s) noexcept { __asm__ __volatile__("fnstenv %0" : "=m"(s)); SANITIZER_MEMORY_INITIALIZED(&s, sizeof(s)); } -static inline void writeX87StateDescriptor(const X87StateDescriptor &s) { +static inline void +writeX87StateDescriptor(const X87StateDescriptor &s) noexcept { __asm__ __volatile__("fldenv %0" : : "m"(s) :); } -static inline void fwait() { __asm__ __volatile__("fwait"); } +static inline void fwait() noexcept { __asm__ __volatile__("fwait"); } } // namespace internal -static inline int enableExcept(int excepts) { +static inline int enableExcept(int excepts) noexcept { // In the x87 control word and in MXCSR, an exception is blocked // if the corresponding bit is set. That is the reason for all the // bit-flip operations below as we need to turn the bits to zero @@ -180,7 +181,7 @@ static inline int enableExcept(int excepts) { return internal::exceptionStatusToMacro(oldExcepts); } -static inline int disableExcept(int excepts) { +static inline int disableExcept(int excepts) noexcept { // In the x87 control word and in MXCSR, an exception is blocked // if the corresponding bit is set. @@ -200,7 +201,7 @@ static inline int disableExcept(int excepts) { return internal::exceptionStatusToMacro(oldExcepts); } -static inline int clearExcept(int excepts) { +static inline int clearExcept(int excepts) noexcept { internal::X87StateDescriptor state; internal::getX87StateDescriptor(state); state.StatusWord &= ~internal::getStatusValueForExcept(excepts); @@ -212,7 +213,7 @@ static inline int clearExcept(int excepts) { return 0; } -static inline int testExcept(int excepts) { +static inline int testExcept(int excepts) noexcept { uint16_t statusValue = internal::getStatusValueForExcept(excepts); // Check both x87 status word and MXCSR. return internal::exceptionStatusToMacro( @@ -221,7 +222,7 @@ static inline int testExcept(int excepts) { } // Sets the exception flags but does not trigger the exception handler. -static inline int setExcept(int excepts) { +static inline int setExcept(int excepts) noexcept { uint16_t statusValue = internal::getStatusValueForExcept(excepts); internal::X87StateDescriptor state; internal::getX87StateDescriptor(state); @@ -235,7 +236,7 @@ static inline int setExcept(int excepts) { return 0; } -static inline int raiseExcept(int excepts) { +static inline int raiseExcept(int excepts) noexcept { uint16_t statusValue = internal::getStatusValueForExcept(excepts); // We set the status flag for exception one at a time and call the @@ -251,7 +252,7 @@ static inline int raiseExcept(int excepts) { // ensure that the writes by the exception handler are maintained // when raising the next exception. - auto raiseHelper = [](uint16_t singleExceptFlag) { + auto raiseHelper = [](uint16_t singleExceptFlag) { internal::X87StateDescriptor state; internal::getX87StateDescriptor(state); state.StatusWord |= singleExceptFlag; @@ -283,7 +284,7 @@ static inline int raiseExcept(int excepts) { return 0; } -static inline int getRound() { +static inline int getRound() noexcept { uint16_t bitValue = (internal::getMXCSR() >> internal::MXCSRRoundingControlBitPosition) & 0x3; switch (bitValue) { @@ -300,7 +301,7 @@ static inline int getRound() { } } -static inline int setRound(int mode) { +static inline int setRound(int mode) noexcept { uint16_t bitValue; switch (mode) { case FE_TONEAREST: @@ -339,14 +340,14 @@ static inline int setRound(int mode) { } #if !(defined(_WIN32)) -static inline int getEnv(fenv_t *envp) { +static inline int getEnv(fenv_t *envp) noexcept { internal::FPState *state = reinterpret_cast(envp); internal::getX87StateDescriptor(state->X87Status); state->MXCSR = internal::getMXCSR(); return 0; } -static inline int setEnv(const fenv_t *envp) { +static inline int setEnv(const fenv_t *envp) noexcept { const internal::FPState *state = reinterpret_cast(envp); internal::writeX87StateDescriptor(state->X87Status); diff --git a/libc/utils/FPUtil/x86_64/FMA.h b/libc/utils/FPUtil/x86_64/FMA.h index e1bc806e4ac8b..0f38e837cbca5 100644 --- a/libc/utils/FPUtil/x86_64/FMA.h +++ b/libc/utils/FPUtil/x86_64/FMA.h @@ -15,8 +15,8 @@ namespace __llvm_libc { namespace fputil { template -static inline cpp::EnableIfType::Value, T> fma(T x, T y, - T z) { +static inline cpp::EnableIfType::Value, T> +fma(T x, T y, T z) noexcept { float result = x; __asm__ __volatile__("vfmadd213ss %x2, %x1, %x0" : "+x"(result) @@ -25,8 +25,8 @@ static inline cpp::EnableIfType::Value, T> fma(T x, T y, } template -static inline cpp::EnableIfType::Value, T> fma(T x, T y, - T z) { +static inline cpp::EnableIfType::Value, T> +fma(T x, T y, T z) noexcept { double result = x; __asm__ __volatile__("vfmadd213sd %x2, %x1, %x0" : "+x"(result) From ca034214fcc63fe50d909dacb909fc51a7960b32 Mon Sep 17 00:00:00 2001 From: Alfonso Gregory <83477269+gAlfonso-bit@users.noreply.github.com> Date: Mon, 26 Jul 2021 11:24:49 -0400 Subject: [PATCH 05/17] math --- libc/src/math/ceil.h | 2 +- libc/src/math/ceilf.h | 2 +- libc/src/math/ceill.h | 2 +- libc/src/math/copysign.h | 2 +- libc/src/math/copysignf.h | 2 +- libc/src/math/copysignl.h | 2 +- libc/src/math/cos.h | 2 +- libc/src/math/cosf.h | 2 +- libc/src/math/exp2f.h | 2 +- libc/src/math/expf.h | 2 +- libc/src/math/expm1f.h | 2 +- libc/src/math/fabs.h | 2 +- libc/src/math/fabsf.h | 2 +- libc/src/math/fabsl.h | 2 +- libc/src/math/fdim.h | 2 +- libc/src/math/fdimf.h | 2 +- libc/src/math/fdiml.h | 2 +- libc/src/math/floor.h | 2 +- libc/src/math/floorf.h | 2 +- libc/src/math/floorl.h | 2 +- libc/src/math/fma.h | 2 +- libc/src/math/fmaf.h | 2 +- libc/src/math/fmax.h | 2 +- libc/src/math/fmaxf.h | 2 +- libc/src/math/fmaxl.h | 2 +- libc/src/math/fmin.h | 2 +- libc/src/math/fminf.h | 2 +- libc/src/math/fminl.h | 2 +- libc/src/math/frexp.h | 2 +- libc/src/math/frexpf.h | 2 +- libc/src/math/frexpl.h | 2 +- libc/src/math/generic/math_utils.h | 34 ++++++++++++++++----------- libc/src/math/generic/sincosf_utils.h | 12 ++++++---- libc/src/math/hypot.h | 2 +- libc/src/math/hypotf.h | 2 +- libc/src/math/ilogb.h | 2 +- libc/src/math/ilogbf.h | 2 +- libc/src/math/ilogbl.h | 2 +- libc/src/math/ldexp.h | 2 +- libc/src/math/ldexpf.h | 2 +- libc/src/math/ldexpl.h | 2 +- libc/src/math/llrint.h | 2 +- libc/src/math/llrintf.h | 2 +- libc/src/math/llrintl.h | 2 +- libc/src/math/llround.h | 2 +- libc/src/math/llroundf.h | 2 +- libc/src/math/llroundl.h | 2 +- libc/src/math/logb.h | 2 +- libc/src/math/logbf.h | 2 +- libc/src/math/logbl.h | 2 +- libc/src/math/lrint.h | 2 +- libc/src/math/lrintf.h | 2 +- libc/src/math/lrintl.h | 2 +- libc/src/math/lround.h | 2 +- libc/src/math/lroundf.h | 2 +- libc/src/math/lroundl.h | 2 +- libc/src/math/modf.h | 2 +- libc/src/math/modff.h | 2 +- libc/src/math/modfl.h | 2 +- libc/src/math/nearbyint.h | 2 +- libc/src/math/nearbyintf.h | 2 +- libc/src/math/nearbyintl.h | 2 +- libc/src/math/nextafter.h | 2 +- libc/src/math/nextafterf.h | 2 +- libc/src/math/nextafterl.h | 2 +- libc/src/math/remainder.h | 2 +- libc/src/math/remainderf.h | 2 +- libc/src/math/remainderl.h | 2 +- libc/src/math/remquo.h | 2 +- libc/src/math/remquof.h | 2 +- libc/src/math/remquol.h | 2 +- libc/src/math/rint.h | 2 +- libc/src/math/rintf.h | 2 +- libc/src/math/rintl.h | 2 +- libc/src/math/round.h | 2 +- libc/src/math/roundf.h | 2 +- libc/src/math/roundl.h | 2 +- libc/src/math/sin.h | 2 +- libc/src/math/sincosf.h | 2 +- libc/src/math/sinf.h | 2 +- libc/src/math/sqrt.h | 2 +- libc/src/math/sqrtf.h | 2 +- libc/src/math/sqrtl.h | 2 +- libc/src/math/tan.h | 2 +- libc/src/math/trunc.h | 2 +- libc/src/math/truncf.h | 2 +- libc/src/math/truncl.h | 2 +- 87 files changed, 112 insertions(+), 104 deletions(-) diff --git a/libc/src/math/ceil.h b/libc/src/math/ceil.h index 98188de20e405..b1a7e9b0fb70a 100644 --- a/libc/src/math/ceil.h +++ b/libc/src/math/ceil.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -double ceil(double x); +double ceil(double x) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/ceilf.h b/libc/src/math/ceilf.h index e8e64565052a6..6f2add587808d 100644 --- a/libc/src/math/ceilf.h +++ b/libc/src/math/ceilf.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -float ceilf(float x); +float ceilf(float x) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/ceill.h b/libc/src/math/ceill.h index 8bf4c565c7d3b..22184f4b55e3d 100644 --- a/libc/src/math/ceill.h +++ b/libc/src/math/ceill.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -long double ceill(long double x); +long double ceill(long double x) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/copysign.h b/libc/src/math/copysign.h index edffe1b082fe0..21929390c36e2 100644 --- a/libc/src/math/copysign.h +++ b/libc/src/math/copysign.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -double copysign(double x, double y); +double copysign(double x, double y) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/copysignf.h b/libc/src/math/copysignf.h index 5b7f1132252d6..5affaa796553a 100644 --- a/libc/src/math/copysignf.h +++ b/libc/src/math/copysignf.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -float copysignf(float x, float y); +float copysignf(float x, float y) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/copysignl.h b/libc/src/math/copysignl.h index 4f48323c70141..e815c52708d38 100644 --- a/libc/src/math/copysignl.h +++ b/libc/src/math/copysignl.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -long double copysignl(long double x, long double y); +long double copysignl(long double x, long double y) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/cos.h b/libc/src/math/cos.h index aca1d6d1e2281..71cb5504caabb 100644 --- a/libc/src/math/cos.h +++ b/libc/src/math/cos.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -double cos(double x); +double cos(double x) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/cosf.h b/libc/src/math/cosf.h index 1aaabe900ba88..f1b2e4f8b4a9a 100644 --- a/libc/src/math/cosf.h +++ b/libc/src/math/cosf.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -float cosf(float x); +float cosf(float x) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/exp2f.h b/libc/src/math/exp2f.h index c1f72b1b80fa8..9a7496d693331 100644 --- a/libc/src/math/exp2f.h +++ b/libc/src/math/exp2f.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -float exp2f(float x); +float exp2f(float x) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/expf.h b/libc/src/math/expf.h index c61ce98e9ddcf..6dc96333d3d66 100644 --- a/libc/src/math/expf.h +++ b/libc/src/math/expf.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -float expf(float x); +float expf(float x) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/expm1f.h b/libc/src/math/expm1f.h index 2577e4a492980..d52fc9e1497e8 100644 --- a/libc/src/math/expm1f.h +++ b/libc/src/math/expm1f.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -float expm1f(float x); +float expm1f(float x) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/fabs.h b/libc/src/math/fabs.h index 424d2e01646b0..e4894213e90bc 100644 --- a/libc/src/math/fabs.h +++ b/libc/src/math/fabs.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -double fabs(double x); +double fabs(double x) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/fabsf.h b/libc/src/math/fabsf.h index 0ad97a027c6c8..0379397f9a95c 100644 --- a/libc/src/math/fabsf.h +++ b/libc/src/math/fabsf.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -float fabsf(float x); +float fabsf(float x) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/fabsl.h b/libc/src/math/fabsl.h index fa25b1ab564d7..5625dea600184 100644 --- a/libc/src/math/fabsl.h +++ b/libc/src/math/fabsl.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -long double fabsl(long double x); +long double fabsl(long double x) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/fdim.h b/libc/src/math/fdim.h index f838c121e291c..1dbabb3e2980a 100644 --- a/libc/src/math/fdim.h +++ b/libc/src/math/fdim.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -double fdim(double x, double y); +double fdim(double x, double y) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/fdimf.h b/libc/src/math/fdimf.h index 50c586c49cc39..8e5a650875efb 100644 --- a/libc/src/math/fdimf.h +++ b/libc/src/math/fdimf.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -float fdimf(float x, float y); +float fdimf(float x, float y) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/fdiml.h b/libc/src/math/fdiml.h index 6de261fe861a0..36b936054ec4c 100644 --- a/libc/src/math/fdiml.h +++ b/libc/src/math/fdiml.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -long double fdiml(long double x, long double y); +long double fdiml(long double x, long double y) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/floor.h b/libc/src/math/floor.h index 88a76ebf7d805..7542f0f184f05 100644 --- a/libc/src/math/floor.h +++ b/libc/src/math/floor.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -double floor(double x); +double floor(double x) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/floorf.h b/libc/src/math/floorf.h index 029df3ac5c9fe..2e4be43a63265 100644 --- a/libc/src/math/floorf.h +++ b/libc/src/math/floorf.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -float floorf(float x); +float floorf(float x) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/floorl.h b/libc/src/math/floorl.h index 224cc13ec6fa6..96895f54438d1 100644 --- a/libc/src/math/floorl.h +++ b/libc/src/math/floorl.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -long double floorl(long double x); +long double floorl(long double x) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/fma.h b/libc/src/math/fma.h index fbc7f09ee2c74..f8346f604ba70 100644 --- a/libc/src/math/fma.h +++ b/libc/src/math/fma.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -double fma(double x, double y, double z); +double fma(double x, double y, double z) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/fmaf.h b/libc/src/math/fmaf.h index 48fbb65d66506..89463d4999595 100644 --- a/libc/src/math/fmaf.h +++ b/libc/src/math/fmaf.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -float fmaf(float x, float y, float z); +float fmaf(float x, float y, float z) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/fmax.h b/libc/src/math/fmax.h index 9f057983d28bb..b9697c8ecb8b7 100644 --- a/libc/src/math/fmax.h +++ b/libc/src/math/fmax.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -double fmax(double x, double y); +double fmax(double x, double y) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/fmaxf.h b/libc/src/math/fmaxf.h index e37df5cf9565d..dfaebf014f40c 100644 --- a/libc/src/math/fmaxf.h +++ b/libc/src/math/fmaxf.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -float fmaxf(float x, float y); +float fmaxf(float x, float y) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/fmaxl.h b/libc/src/math/fmaxl.h index 41d80ba4aa52c..78f52a8893de8 100644 --- a/libc/src/math/fmaxl.h +++ b/libc/src/math/fmaxl.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -long double fmaxl(long double x, long double y); +long double fmaxl(long double x, long double y) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/fmin.h b/libc/src/math/fmin.h index 52334ee8e4560..15c967f68120c 100644 --- a/libc/src/math/fmin.h +++ b/libc/src/math/fmin.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -double fmin(double x, double y); +double fmin(double x, double y) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/fminf.h b/libc/src/math/fminf.h index 62dad57d852aa..cf30993743874 100644 --- a/libc/src/math/fminf.h +++ b/libc/src/math/fminf.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -float fminf(float x, float y); +float fminf(float x, float y) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/fminl.h b/libc/src/math/fminl.h index c19505c018283..eae2d0d607e51 100644 --- a/libc/src/math/fminl.h +++ b/libc/src/math/fminl.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -long double fminl(long double x, long double y); +long double fminl(long double x, long double y) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/frexp.h b/libc/src/math/frexp.h index 9258243188360..71fe10fd1532c 100644 --- a/libc/src/math/frexp.h +++ b/libc/src/math/frexp.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -double frexp(double x, int *exp); +double frexp(double x, int *exp) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/frexpf.h b/libc/src/math/frexpf.h index ed303d2c76dd5..534effa24b2e9 100644 --- a/libc/src/math/frexpf.h +++ b/libc/src/math/frexpf.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -float frexpf(float x, int *exp); +float frexpf(float x, int *exp) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/frexpl.h b/libc/src/math/frexpl.h index 9f75c82b9034a..e5e96494a2b8f 100644 --- a/libc/src/math/frexpl.h +++ b/libc/src/math/frexpl.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -long double frexpl(long double x, int *exp); +long double frexpl(long double x, int *exp) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/generic/math_utils.h b/libc/src/math/generic/math_utils.h index 4afddb04d6e43..e96b36f3e974c 100644 --- a/libc/src/math/generic/math_utils.h +++ b/libc/src/math/generic/math_utils.h @@ -18,25 +18,29 @@ namespace __llvm_libc { -static inline uint32_t as_uint32_bits(float x) { +static inline uint32_t as_uint32_bits(float x) noexcept { return *reinterpret_cast(&x); } -static inline uint64_t as_uint64_bits(double x) { +static inline uint64_t as_uint64_bits(double x) noexcept { return *reinterpret_cast(&x); } -static inline float as_float(uint32_t x) { +static inline float as_float(uint32_t x) noexcept { return *reinterpret_cast(&x); } -static inline double as_double(uint64_t x) { +static inline double as_double(uint64_t x) noexcept { return *reinterpret_cast(&x); } -static inline uint32_t top12_bits(float x) { return as_uint32_bits(x) >> 20; } +static inline uint32_t top12_bits(float x) noexcept { + return as_uint32_bits(x) >> 20; +} -static inline uint32_t top12_bits(double x) { return as_uint64_bits(x) >> 52; } +static inline uint32_t top12_bits(double x) noexcept { + return as_uint64_bits(x) >> 52; +} // Values to trigger underflow and overflow. template struct XFlowValues; @@ -53,17 +57,17 @@ template <> struct XFlowValues { static const double may_underflow_value; }; -template static inline T with_errno(T x, int err) { +template static inline T with_errno(T x, int err) noexcept { if (math_errhandling & MATH_ERRNO) errno = err; // NOLINT return x; } -template static inline void force_eval(T x) { +template static inline void force_eval(T x) noexcept { volatile T y UNUSED = x; } -template static inline T opt_barrier(T x) { +template static inline T opt_barrier(T x) noexcept { volatile T y = x; return y; } @@ -77,28 +81,30 @@ template using EnableIfFloatOrDouble = cpp::EnableIfType::Value, int>; template = 0> -T xflow(uint32_t sign, T y) { +T xflow(uint32_t sign, T y) noexcept { // Underflow happens when two extremely small values are multiplied. // Likewise, overflow happens when two large values are multiplied. y = opt_barrier(sign ? -y : y) * y; return with_errno(y, ERANGE); } -template = 0> T overflow(uint32_t sign) { +template = 0> +T overflow(uint32_t sign) noexcept { return xflow(sign, XFlowValues::overflow_value); } -template = 0> T underflow(uint32_t sign) { +template = 0> +T underflow(uint32_t sign) noexcept { return xflow(sign, XFlowValues::underflow_value); } template = 0> -T may_underflow(uint32_t sign) { +T may_underflow(uint32_t sign) noexcept { return xflow(sign, XFlowValues::may_underflow_value); } template = 0> -static inline constexpr float invalid(T x) { +static constexpr float invalid(T x) { T y = (x - x) / (x - x); return isnan(x) ? y : with_errno(y, EDOM); } diff --git a/libc/src/math/generic/sincosf_utils.h b/libc/src/math/generic/sincosf_utils.h index 8c54cb9c1d904..a6fbb18a9214e 100644 --- a/libc/src/math/generic/sincosf_utils.h +++ b/libc/src/math/generic/sincosf_utils.h @@ -36,7 +36,7 @@ extern const sincos_t __sincosf_table[2]; extern const uint32_t __inv_pio4[]; // Top 12 bits of the float representation with the sign bit cleared. -static inline uint32_t abstop12(float x) { +static inline uint32_t abstop12(float x) noexcept { return (as_uint32_bits(x) >> 20) & 0x7ff; } @@ -44,7 +44,7 @@ static inline uint32_t abstop12(float x) { // polynomial P and store the results in SINP and COSP. N is the quadrant, // if odd the cosine and sine polynomials are swapped. static inline void sincosf_poly(double x, double x2, const sincos_t *p, int n, - float *sinp, float *cosp) { + float *sinp, float *cosp) noexcept { double x3, x4, x5, x6, s, c, c1, c2, s1; x4 = x2 * x2; @@ -70,7 +70,8 @@ static inline void sincosf_poly(double x, double x2, const sincos_t *p, int n, // Return the sine of inputs X and X2 (X squared) using the polynomial P. // N is the quadrant, and if odd the cosine polynomial is used. -static inline float sinf_poly(double x, double x2, const sincos_t *p, int n) { +static inline float sinf_poly(double x, double x2, const sincos_t *p, + int n) noexcept { double x3, x4, x6, x7, s, c, c1, c2, s1; if ((n & 1) == 0) { @@ -98,7 +99,8 @@ static inline float sinf_poly(double x, double x2, const sincos_t *p, int n) { // The values for PI/2 and 2/PI are accessed via P. Since PI/2 as a double // is accurate to 55 bits and the worst-case cancellation happens at 6 * PI/4, // the result is accurate for |X| <= 120.0. -static inline double reduce_fast(double x, const sincos_t *p, int *np) { +static inline double reduce_fast(double x, const sincos_t *p, + int *np) noexcept { double r; // Use scaled float to int conversion with explicit rounding. // hpi_inv is prescaled by 2^24 so the quadrant ends up in bits 24..31. @@ -116,7 +118,7 @@ static inline double reduce_fast(double x, const sincos_t *p, int *np) { // multiply computes the exact 2.62-bit fixed-point modulo. Since the result // can have at most 29 leading zeros after the binary point, the double // precision result is accurate to 33 bits. -static inline double reduce_large(uint32_t xi, int *np) { +static inline double reduce_large(uint32_t xi, int *np) noexcept { const uint32_t *arr = &__inv_pio4[(xi >> 26) & 15]; int shift = (xi >> 23) & 7; uint64_t n, res0, res1, res2; diff --git a/libc/src/math/hypot.h b/libc/src/math/hypot.h index 6c901ee8f4c0c..5778813123a59 100644 --- a/libc/src/math/hypot.h +++ b/libc/src/math/hypot.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -double hypot(double x, double y); +double hypot(double x, double y) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/hypotf.h b/libc/src/math/hypotf.h index 084fd7f3ef814..a64fa211477ab 100644 --- a/libc/src/math/hypotf.h +++ b/libc/src/math/hypotf.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -float hypotf(float x, float y); +float hypotf(float x, float y) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/ilogb.h b/libc/src/math/ilogb.h index 96672077865a9..951dd44d30837 100644 --- a/libc/src/math/ilogb.h +++ b/libc/src/math/ilogb.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -int ilogb(double x); +int ilogb(double x) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/ilogbf.h b/libc/src/math/ilogbf.h index 1afb76a107c1c..d84c64f23b489 100644 --- a/libc/src/math/ilogbf.h +++ b/libc/src/math/ilogbf.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -int ilogbf(float x); +int ilogbf(float x) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/ilogbl.h b/libc/src/math/ilogbl.h index 4d1cc1995341b..24d9c5cb0da10 100644 --- a/libc/src/math/ilogbl.h +++ b/libc/src/math/ilogbl.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -int ilogbl(long double x); +int ilogbl(long double x) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/ldexp.h b/libc/src/math/ldexp.h index 74f9a600666fa..6a3f486102037 100644 --- a/libc/src/math/ldexp.h +++ b/libc/src/math/ldexp.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -double ldexp(double x, int exp); +double ldexp(double x, int exp) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/ldexpf.h b/libc/src/math/ldexpf.h index f30d60155f1fd..9a79f0cfda724 100644 --- a/libc/src/math/ldexpf.h +++ b/libc/src/math/ldexpf.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -float ldexpf(float x, int exp); +float ldexpf(float x, int exp) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/ldexpl.h b/libc/src/math/ldexpl.h index bf8435b1a21d8..ac1c6664d45d9 100644 --- a/libc/src/math/ldexpl.h +++ b/libc/src/math/ldexpl.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -long double ldexpl(long double x, int exp); +long double ldexpl(long double x, int exp) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/llrint.h b/libc/src/math/llrint.h index 96bd7b8cc9e1c..8a9c37022c22e 100644 --- a/libc/src/math/llrint.h +++ b/libc/src/math/llrint.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -long long llrint(double x); +long long llrint(double x) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/llrintf.h b/libc/src/math/llrintf.h index eecf380f5e94d..eedd748c15c78 100644 --- a/libc/src/math/llrintf.h +++ b/libc/src/math/llrintf.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -long long llrintf(float x); +long long llrintf(float x) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/llrintl.h b/libc/src/math/llrintl.h index 94dfba7080aa9..e6e5d46edf6a4 100644 --- a/libc/src/math/llrintl.h +++ b/libc/src/math/llrintl.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -long long llrintl(long double x); +long long llrintl(long double x) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/llround.h b/libc/src/math/llround.h index 5b2b7fc96df87..eae50a7d37dd7 100644 --- a/libc/src/math/llround.h +++ b/libc/src/math/llround.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -long long llround(double x); +long long llround(double x) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/llroundf.h b/libc/src/math/llroundf.h index 65faad1e07a61..b65a8ddc0a285 100644 --- a/libc/src/math/llroundf.h +++ b/libc/src/math/llroundf.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -long long llroundf(float x); +long long llroundf(float x) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/llroundl.h b/libc/src/math/llroundl.h index f859485a730bd..7cdf620746b24 100644 --- a/libc/src/math/llroundl.h +++ b/libc/src/math/llroundl.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -long long llroundl(long double x); +long long llroundl(long double x) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/logb.h b/libc/src/math/logb.h index b875dcd702bab..6debaa8923632 100644 --- a/libc/src/math/logb.h +++ b/libc/src/math/logb.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -double logb(double x); +double logb(double x) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/logbf.h b/libc/src/math/logbf.h index 46dcd3c91d628..7225b0252ad04 100644 --- a/libc/src/math/logbf.h +++ b/libc/src/math/logbf.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -float logbf(float x); +float logbf(float x) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/logbl.h b/libc/src/math/logbl.h index 3630e52c92d29..07d2aa6f83801 100644 --- a/libc/src/math/logbl.h +++ b/libc/src/math/logbl.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -long double logbl(long double x); +long double logbl(long double x) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/lrint.h b/libc/src/math/lrint.h index 62df79a1de230..565cae847e3d4 100644 --- a/libc/src/math/lrint.h +++ b/libc/src/math/lrint.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -long lrint(double x); +long lrint(double x) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/lrintf.h b/libc/src/math/lrintf.h index af5159437532b..604f53d76e5d3 100644 --- a/libc/src/math/lrintf.h +++ b/libc/src/math/lrintf.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -long lrintf(float x); +long lrintf(float x) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/lrintl.h b/libc/src/math/lrintl.h index 812acecadafad..e16070f7c220e 100644 --- a/libc/src/math/lrintl.h +++ b/libc/src/math/lrintl.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -long lrintl(long double x); +long lrintl(long double x) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/lround.h b/libc/src/math/lround.h index 8c555e816c8ba..78631d51562e3 100644 --- a/libc/src/math/lround.h +++ b/libc/src/math/lround.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -long lround(double x); +long lround(double x) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/lroundf.h b/libc/src/math/lroundf.h index 3d318a7a2faba..19e31f1a156d1 100644 --- a/libc/src/math/lroundf.h +++ b/libc/src/math/lroundf.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -long lroundf(float x); +long lroundf(float x) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/lroundl.h b/libc/src/math/lroundl.h index a8b5aff0fcf38..b6116e80925ee 100644 --- a/libc/src/math/lroundl.h +++ b/libc/src/math/lroundl.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -long lroundl(long double x); +long lroundl(long double x) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/modf.h b/libc/src/math/modf.h index 1dc732f6e89ab..2816e1c53916f 100644 --- a/libc/src/math/modf.h +++ b/libc/src/math/modf.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -double modf(double x, double *iptr); +double modf(double x, double *iptr) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/modff.h b/libc/src/math/modff.h index 21457e0d2e81a..36d5849836d54 100644 --- a/libc/src/math/modff.h +++ b/libc/src/math/modff.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -float modff(float x, float *iptr); +float modff(float x, float *iptr) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/modfl.h b/libc/src/math/modfl.h index ff89239c4bfde..44206211bdf2e 100644 --- a/libc/src/math/modfl.h +++ b/libc/src/math/modfl.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -long double modfl(long double x, long double *iptr); +long double modfl(long double x, long double *iptr) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/nearbyint.h b/libc/src/math/nearbyint.h index 957a06b979214..bde631c421549 100644 --- a/libc/src/math/nearbyint.h +++ b/libc/src/math/nearbyint.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -double nearbyint(double x); +double nearbyint(double x) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/nearbyintf.h b/libc/src/math/nearbyintf.h index 3793f6bc1b881..9d1f42a905f1b 100644 --- a/libc/src/math/nearbyintf.h +++ b/libc/src/math/nearbyintf.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -float nearbyintf(float x); +float nearbyintf(float x) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/nearbyintl.h b/libc/src/math/nearbyintl.h index 7029e86a52114..8b896002e178b 100644 --- a/libc/src/math/nearbyintl.h +++ b/libc/src/math/nearbyintl.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -long double nearbyintl(long double x); +long double nearbyintl(long double x) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/nextafter.h b/libc/src/math/nextafter.h index 1f6d24de5f2e0..89ff5cc4819b7 100644 --- a/libc/src/math/nextafter.h +++ b/libc/src/math/nextafter.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -double nextafter(double x, double y); +double nextafter(double x, double y) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/nextafterf.h b/libc/src/math/nextafterf.h index 8afac0e5f6a03..9ab90f26fa148 100644 --- a/libc/src/math/nextafterf.h +++ b/libc/src/math/nextafterf.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -float nextafterf(float x, float y); +float nextafterf(float x, float y) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/nextafterl.h b/libc/src/math/nextafterl.h index 912877867dc21..14f652e9904b3 100644 --- a/libc/src/math/nextafterl.h +++ b/libc/src/math/nextafterl.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -long double nextafterl(long double x, long double y); +long double nextafterl(long double x, long double y) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/remainder.h b/libc/src/math/remainder.h index 8a720fc23b6be..924fc15ec6abb 100644 --- a/libc/src/math/remainder.h +++ b/libc/src/math/remainder.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -double remainder(double x, double y); +double remainder(double x, double y) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/remainderf.h b/libc/src/math/remainderf.h index 19a16d08a94d3..f177e5c7e08ea 100644 --- a/libc/src/math/remainderf.h +++ b/libc/src/math/remainderf.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -float remainderf(float x, float y); +float remainderf(float x, float y) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/remainderl.h b/libc/src/math/remainderl.h index f2837635ab77c..2aeb09c2b56f8 100644 --- a/libc/src/math/remainderl.h +++ b/libc/src/math/remainderl.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -long double remainderl(long double x, long double y); +long double remainderl(long double x, long double y) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/remquo.h b/libc/src/math/remquo.h index cb753fee6ea0d..c4a0b686aca28 100644 --- a/libc/src/math/remquo.h +++ b/libc/src/math/remquo.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -double remquo(double x, double y, int *exp); +double remquo(double x, double y, int *exp) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/remquof.h b/libc/src/math/remquof.h index feb2e4f5e0dd5..53ae441acb475 100644 --- a/libc/src/math/remquof.h +++ b/libc/src/math/remquof.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -float remquof(float x, float y, int *exp); +float remquof(float x, float y, int *exp) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/remquol.h b/libc/src/math/remquol.h index d1b0e20fcc865..c50e3ec36faac 100644 --- a/libc/src/math/remquol.h +++ b/libc/src/math/remquol.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -long double remquol(long double x, long double y, int *exp); +long double remquol(long double x, long double y, int *exp) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/rint.h b/libc/src/math/rint.h index e4910ad95a81c..f8b1a7612b527 100644 --- a/libc/src/math/rint.h +++ b/libc/src/math/rint.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -double rint(double x); +double rint(double x) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/rintf.h b/libc/src/math/rintf.h index 0091ba3a8cd00..3de8f2703d4e7 100644 --- a/libc/src/math/rintf.h +++ b/libc/src/math/rintf.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -float rintf(float x); +float rintf(float x) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/rintl.h b/libc/src/math/rintl.h index 2bf095de76f88..93d45b394ab5f 100644 --- a/libc/src/math/rintl.h +++ b/libc/src/math/rintl.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -long double rintl(long double x); +long double rintl(long double x) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/round.h b/libc/src/math/round.h index bb09ea4a77c53..b0378a577e2f2 100644 --- a/libc/src/math/round.h +++ b/libc/src/math/round.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -double round(double x); +double round(double x) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/roundf.h b/libc/src/math/roundf.h index 6bab35adf781a..8d39f4267ed61 100644 --- a/libc/src/math/roundf.h +++ b/libc/src/math/roundf.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -float roundf(float x); +float roundf(float x) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/roundl.h b/libc/src/math/roundl.h index 43fb63e231de4..0b3aced3b2fa5 100644 --- a/libc/src/math/roundl.h +++ b/libc/src/math/roundl.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -long double roundl(long double x); +long double roundl(long double x) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/sin.h b/libc/src/math/sin.h index f3919c46df603..43dbe80fdb91c 100644 --- a/libc/src/math/sin.h +++ b/libc/src/math/sin.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -double sin(double x); +double sin(double x) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/sincosf.h b/libc/src/math/sincosf.h index 47ef983f4385f..430f6f6417ae4 100644 --- a/libc/src/math/sincosf.h +++ b/libc/src/math/sincosf.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -void sincosf(float x, float *sinx, float *cosx); +void sincosf(float x, float *sinx, float *cosx) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/sinf.h b/libc/src/math/sinf.h index e63db04c51b5d..8e6b4f3dc0c30 100644 --- a/libc/src/math/sinf.h +++ b/libc/src/math/sinf.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -float sinf(float x); +float sinf(float x) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/sqrt.h b/libc/src/math/sqrt.h index 2390e07b5dce5..26dc527e8a5c0 100644 --- a/libc/src/math/sqrt.h +++ b/libc/src/math/sqrt.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -double sqrt(double x); +double sqrt(double x) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/sqrtf.h b/libc/src/math/sqrtf.h index d1d06f3adfa8e..6ab9dbe208d7d 100644 --- a/libc/src/math/sqrtf.h +++ b/libc/src/math/sqrtf.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -float sqrtf(float x); +float sqrtf(float x) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/sqrtl.h b/libc/src/math/sqrtl.h index 5fbfa14507147..a033849d77c85 100644 --- a/libc/src/math/sqrtl.h +++ b/libc/src/math/sqrtl.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -long double sqrtl(long double x); +long double sqrtl(long double x) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/tan.h b/libc/src/math/tan.h index 05366db52ff87..6e733be6746ff 100644 --- a/libc/src/math/tan.h +++ b/libc/src/math/tan.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -double tan(double x); +double tan(double x) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/trunc.h b/libc/src/math/trunc.h index f7fed01f30d25..dba5d37d027f8 100644 --- a/libc/src/math/trunc.h +++ b/libc/src/math/trunc.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -double trunc(double x); +double trunc(double x) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/truncf.h b/libc/src/math/truncf.h index b4f1cd7ea72f6..83f93b9dbf354 100644 --- a/libc/src/math/truncf.h +++ b/libc/src/math/truncf.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -float truncf(float x); +float truncf(float x) noexcept; } // namespace __llvm_libc diff --git a/libc/src/math/truncl.h b/libc/src/math/truncl.h index 2a78ffaa3c5ef..4b005c1e696ad 100644 --- a/libc/src/math/truncl.h +++ b/libc/src/math/truncl.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -long double truncl(long double x); +long double truncl(long double x) noexcept; } // namespace __llvm_libc From 857d6ccbc48c5b549b828c7cd15c963517acd188 Mon Sep 17 00:00:00 2001 From: Alfonso Gregory <83477269+gAlfonso-bit@users.noreply.github.com> Date: Mon, 26 Jul 2021 12:01:22 -0400 Subject: [PATCH 06/17] stdlib and signal --- libc/config/linux/x86_64/syscall.h.inc | 159 +++++++++++++------------ libc/src/signal/linux/sigaction.cpp | 2 +- libc/src/signal/linux/sigaddset.cpp | 4 +- libc/src/signal/linux/sigdelset.cpp | 4 +- libc/src/signal/linux/sigemptyset.cpp | 2 +- libc/src/signal/linux/sigfillset.cpp | 2 +- libc/src/signal/linux/signal.h | 4 +- libc/src/signal/raise.h | 2 +- libc/src/signal/sigaction.h | 2 +- libc/src/signal/sigaddset.h | 2 +- libc/src/signal/sigdelset.h | 2 +- libc/src/signal/sigemptyset.h | 2 +- libc/src/signal/sigfillset.h | 2 +- libc/src/signal/signal.h | 2 +- libc/src/signal/sigprocmask.h | 2 +- libc/src/stdio/FILE.h | 2 +- libc/src/stdio/fwrite.cpp | 4 +- libc/src/stdio/fwrite.h | 2 +- libc/src/stdlib/abort.cpp | 2 +- libc/src/stdlib/abs.h | 2 +- libc/src/stdlib/labs.h | 2 +- libc/src/stdlib/linux/_Exit.cpp | 2 +- libc/src/stdlib/llabs.h | 2 +- 23 files changed, 106 insertions(+), 105 deletions(-) diff --git a/libc/config/linux/x86_64/syscall.h.inc b/libc/config/linux/x86_64/syscall.h.inc index ee3b5e5bfc0d7..de34d8ed21625 100644 --- a/libc/config/linux/x86_64/syscall.h.inc +++ b/libc/config/linux/x86_64/syscall.h.inc @@ -14,92 +14,93 @@ namespace __llvm_libc { -__attribute__((always_inline)) inline long syscall(long __number) { - long retcode; - LIBC_INLINE_ASM("syscall" - : "=a"(retcode) - : "a"(__number) - : SYSCALL_CLOBBER_LIST); - return retcode; -} + __attribute__((always_inline)) inline long syscall(long __number) noexcept { + long retcode; + LIBC_INLINE_ASM("syscall" + : "=a"(retcode) + : "a"(__number) + : SYSCALL_CLOBBER_LIST); + return retcode; + } -__attribute__((always_inline)) inline long syscall(long __number, long __arg1) { - long retcode; - LIBC_INLINE_ASM("syscall" - : "=a"(retcode) - : "a"(__number), "D"(__arg1) - : SYSCALL_CLOBBER_LIST); - return retcode; -} + __attribute__((always_inline)) inline long syscall(long __number, + long __arg1) noexcept { + long retcode; + LIBC_INLINE_ASM("syscall" + : "=a"(retcode) + : "a"(__number), "D"(__arg1) + : SYSCALL_CLOBBER_LIST); + return retcode; + } -__attribute__((always_inline)) inline long syscall(long __number, long __arg1, - long __arg2) { - long retcode; - LIBC_INLINE_ASM("syscall" - : "=a"(retcode) - : "a"(__number), "D"(__arg1), "S"(__arg2) - : SYSCALL_CLOBBER_LIST); - return retcode; -} + __attribute__((always_inline)) inline long syscall(long __number, long __arg1, + long __arg2) noexcept { + long retcode; + LIBC_INLINE_ASM("syscall" + : "=a"(retcode) + : "a"(__number), "D"(__arg1), "S"(__arg2) + : SYSCALL_CLOBBER_LIST); + return retcode; + } -__attribute__((always_inline)) inline long syscall(long __number, long __arg1, - long __arg2, long __arg3) { - long retcode; - LIBC_INLINE_ASM("syscall" - : "=a"(retcode) - : "a"(__number), "D"(__arg1), "S"(__arg2), "d"(__arg3) - : SYSCALL_CLOBBER_LIST); - return retcode; -} + __attribute__((always_inline)) inline long syscall( + long __number, long __arg1, long __arg2, long __arg3) noexcept { + long retcode; + LIBC_INLINE_ASM("syscall" + : "=a"(retcode) + : "a"(__number), "D"(__arg1), "S"(__arg2), "d"(__arg3) + : SYSCALL_CLOBBER_LIST); + return retcode; + } -__attribute__((always_inline)) inline long -syscall(long __number, long __arg1, long __arg2, long __arg3, long __arg4) { - long retcode; - register long r10 __asm__("r10") = __arg4; - LIBC_INLINE_ASM("syscall" - : "=a"(retcode) - : "a"(__number), "D"(__arg1), "S"(__arg2), "d"(__arg3), - "r"(r10) - : SYSCALL_CLOBBER_LIST); - return retcode; -} + __attribute__((always_inline)) inline long syscall(long __number, long __arg1, + long __arg2, long __arg3, + long __arg4) noexcept { + long retcode; + register long r10 __asm__("r10") = __arg4; + LIBC_INLINE_ASM("syscall" + : "=a"(retcode) + : "a"(__number), "D"(__arg1), "S"(__arg2), "d"(__arg3), + "r"(r10) + : SYSCALL_CLOBBER_LIST); + return retcode; + } -__attribute__((always_inline)) inline long syscall(long __number, long __arg1, - long __arg2, long __arg3, - long __arg4, long __arg5) { - long retcode; - register long r10 __asm__("r10") = __arg4; - register long r8 __asm__("r8") = __arg5; - LIBC_INLINE_ASM("syscall" - : "=a"(retcode) - : "a"(__number), "D"(__arg1), "S"(__arg2), "d"(__arg3), - "r"(r10), "r"(r8) - : SYSCALL_CLOBBER_LIST); - return retcode; -} + __attribute__((always_inline)) inline long syscall( + long __number, long __arg1, long __arg2, long __arg3, long __arg4, + long __arg5) noexcept { + long retcode; + register long r10 __asm__("r10") = __arg4; + register long r8 __asm__("r8") = __arg5; + LIBC_INLINE_ASM("syscall" + : "=a"(retcode) + : "a"(__number), "D"(__arg1), "S"(__arg2), "d"(__arg3), + "r"(r10), "r"(r8) + : SYSCALL_CLOBBER_LIST); + return retcode; + } -__attribute__((always_inline)) inline long syscall(long __number, long __arg1, - long __arg2, long __arg3, - long __arg4, long __arg5, - long __arg6) { - long retcode; - register long r10 __asm__("r10") = __arg4; - register long r8 __asm__("r8") = __arg5; - register long r9 __asm__("r9") = __arg6; - LIBC_INLINE_ASM("syscall" - : "=a"(retcode) - : "a"(__number), "D"(__arg1), "S"(__arg2), "d"(__arg3), - "r"(r10), "r"(r8), "r"(r9) - : SYSCALL_CLOBBER_LIST); - return retcode; -} - -template -__attribute__((always_inline)) inline long syscall(long __number, Ts... ts) { - static_assert(sizeof...(Ts) <= 6, "Too many arguments for syscall"); - return syscall(__number, (long)ts...); -} + __attribute__((always_inline)) inline long syscall( + long __number, long __arg1, long __arg2, long __arg3, long __arg4, + long __arg5, long __arg6) noexcept { + long retcode; + register long r10 __asm__("r10") = __arg4; + register long r8 __asm__("r8") = __arg5; + register long r9 __asm__("r9") = __arg6; + LIBC_INLINE_ASM("syscall" + : "=a"(retcode) + : "a"(__number), "D"(__arg1), "S"(__arg2), "d"(__arg3), + "r"(r10), "r"(r8), "r"(r9) + : SYSCALL_CLOBBER_LIST); + return retcode; + } + template + __attribute__((always_inline)) inline long syscall(long __number, + Ts... ts) noexcept { + static_assert(sizeof...(Ts) <= 6, "Too many arguments for syscall"); + return syscall(__number, static_cast(ts...)); + } #undef SYSCALL_CLOBBER_LIST diff --git a/libc/src/signal/linux/sigaction.cpp b/libc/src/signal/linux/sigaction.cpp index 602fc71bf390c..8ecda77d6f8d3 100644 --- a/libc/src/signal/linux/sigaction.cpp +++ b/libc/src/signal/linux/sigaction.cpp @@ -21,7 +21,7 @@ namespace __llvm_libc { extern "C" void __restore_rt(); template -static void copySigaction(T &dest, const V &source) { +static void copySigaction(T &dest, const V &source) noexcept { dest.sa_handler = source.sa_handler; dest.sa_mask = source.sa_mask; dest.sa_flags = source.sa_flags; diff --git a/libc/src/signal/linux/sigaddset.cpp b/libc/src/signal/linux/sigaddset.cpp index bc51ef67e0b3a..a7732645dea9a 100644 --- a/libc/src/signal/linux/sigaddset.cpp +++ b/libc/src/signal/linux/sigaddset.cpp @@ -15,8 +15,8 @@ namespace __llvm_libc { -LLVM_LIBC_FUNCTION(int, sigaddset, (sigset_t * set, int signum)) { - if (!set || (unsigned)(signum - 1) >= (8 * sizeof(sigset_t))) { +LLVM_LIBC_FUNCTION(int, sigaddset, (sigset_t * set, int signum)) noexcept { + if (!set || static_cast(signum - 1) >= (8 * sizeof(sigset_t))) { llvmlibc_errno = EINVAL; return -1; } diff --git a/libc/src/signal/linux/sigdelset.cpp b/libc/src/signal/linux/sigdelset.cpp index f870f71560074..60b84a3f9865f 100644 --- a/libc/src/signal/linux/sigdelset.cpp +++ b/libc/src/signal/linux/sigdelset.cpp @@ -15,8 +15,8 @@ namespace __llvm_libc { -LLVM_LIBC_FUNCTION(int, sigdelset, (sigset_t * set, int signum)) { - if (!set || (unsigned)(signum - 1) >= (8 * sizeof(sigset_t))) { +LLVM_LIBC_FUNCTION(int, sigdelset, (sigset_t * set, int signum)) noexcept { + if (!set || static_cast(signum - 1) >= (8 * sizeof(sigset_t))) { llvmlibc_errno = EINVAL; return -1; } diff --git a/libc/src/signal/linux/sigemptyset.cpp b/libc/src/signal/linux/sigemptyset.cpp index bce5fea7c963b..542e2f8635b3f 100644 --- a/libc/src/signal/linux/sigemptyset.cpp +++ b/libc/src/signal/linux/sigemptyset.cpp @@ -15,7 +15,7 @@ namespace __llvm_libc { -LLVM_LIBC_FUNCTION(int, sigemptyset, (sigset_t * set)) { +LLVM_LIBC_FUNCTION(int, sigemptyset, (sigset_t * set)) noexcept { if (!set) { llvmlibc_errno = EINVAL; return -1; diff --git a/libc/src/signal/linux/sigfillset.cpp b/libc/src/signal/linux/sigfillset.cpp index 1b908f1992640..1377263c7b17b 100644 --- a/libc/src/signal/linux/sigfillset.cpp +++ b/libc/src/signal/linux/sigfillset.cpp @@ -15,7 +15,7 @@ namespace __llvm_libc { -LLVM_LIBC_FUNCTION(int, sigfillset, (sigset_t * set)) { +LLVM_LIBC_FUNCTION(int, sigfillset, (sigset_t * set)) noexcept { if (!set) { llvmlibc_errno = EINVAL; return -1; diff --git a/libc/src/signal/linux/signal.h b/libc/src/signal/linux/signal.h index 89b471b4079e4..d9687952713bd 100644 --- a/libc/src/signal/linux/signal.h +++ b/libc/src/signal/linux/signal.h @@ -35,7 +35,7 @@ struct Sigset { constexpr static Sigset all = Sigset::fullset(); -static inline int block_all_signals(Sigset &set) { +static inline int block_all_signals(Sigset &set) noexcept { sigset_t nativeSigset = all; sigset_t oldSet = set; int ret = __llvm_libc::syscall(SYS_rt_sigprocmask, SIG_BLOCK, &nativeSigset, @@ -44,7 +44,7 @@ static inline int block_all_signals(Sigset &set) { return ret; } -static inline int restore_signals(const Sigset &set) { +static inline int restore_signals(const Sigset &set) noexcept { sigset_t nativeSigset = set; return __llvm_libc::syscall(SYS_rt_sigprocmask, SIG_SETMASK, &nativeSigset, nullptr, sizeof(sigset_t)); diff --git a/libc/src/signal/raise.h b/libc/src/signal/raise.h index 00fd4c8fbda99..d477fca998090 100644 --- a/libc/src/signal/raise.h +++ b/libc/src/signal/raise.h @@ -13,7 +13,7 @@ namespace __llvm_libc { -int raise(int sig); +int raise(int sig) noexcept; } // namespace __llvm_libc diff --git a/libc/src/signal/sigaction.h b/libc/src/signal/sigaction.h index 105ab1b250cc6..c72902cd79946 100644 --- a/libc/src/signal/sigaction.h +++ b/libc/src/signal/sigaction.h @@ -15,7 +15,7 @@ namespace __llvm_libc { int sigaction(int signal, const struct __sigaction *__restrict libc_new, - struct __sigaction *__restrict libc_old); + struct __sigaction *__restrict libc_old) noexcept; } // namespace __llvm_libc diff --git a/libc/src/signal/sigaddset.h b/libc/src/signal/sigaddset.h index 40cec9f00c647..7eb76ccc92439 100644 --- a/libc/src/signal/sigaddset.h +++ b/libc/src/signal/sigaddset.h @@ -13,7 +13,7 @@ namespace __llvm_libc { -int sigaddset(sigset_t *set, int signum); +int sigaddset(sigset_t *set, int signum) noexcept; } // namespace __llvm_libc diff --git a/libc/src/signal/sigdelset.h b/libc/src/signal/sigdelset.h index a005d9c0aa138..c055d34010f35 100644 --- a/libc/src/signal/sigdelset.h +++ b/libc/src/signal/sigdelset.h @@ -13,7 +13,7 @@ namespace __llvm_libc { -int sigdelset(sigset_t *set, int signum); +int sigdelset(sigset_t *set, int signum) noexcept; } // namespace __llvm_libc diff --git a/libc/src/signal/sigemptyset.h b/libc/src/signal/sigemptyset.h index 0651c7302f992..7d418a06ade7e 100644 --- a/libc/src/signal/sigemptyset.h +++ b/libc/src/signal/sigemptyset.h @@ -13,7 +13,7 @@ namespace __llvm_libc { -int sigemptyset(sigset_t *set); +int sigemptyset(sigset_t *set) noexcept; } // namespace __llvm_libc diff --git a/libc/src/signal/sigfillset.h b/libc/src/signal/sigfillset.h index ed3612ce4ed5a..af60fb86694eb 100644 --- a/libc/src/signal/sigfillset.h +++ b/libc/src/signal/sigfillset.h @@ -13,7 +13,7 @@ namespace __llvm_libc { -int sigfillset(sigset_t *set); +int sigfillset(sigset_t *set) noexcept; } // namespace __llvm_libc diff --git a/libc/src/signal/signal.h b/libc/src/signal/signal.h index 4315497e2cf8c..bd10c6d61de4f 100644 --- a/libc/src/signal/signal.h +++ b/libc/src/signal/signal.h @@ -15,7 +15,7 @@ namespace __llvm_libc { using sighandler_t = __sighandler_t; -sighandler_t signal(int signum, sighandler_t handler); +sighandler_t signal(int signum, sighandler_t handler) noexcept; } // namespace __llvm_libc diff --git a/libc/src/signal/sigprocmask.h b/libc/src/signal/sigprocmask.h index 353c0c84b38a1..41a79f6a5706c 100644 --- a/libc/src/signal/sigprocmask.h +++ b/libc/src/signal/sigprocmask.h @@ -14,7 +14,7 @@ namespace __llvm_libc { int sigprocmask(int how, const sigset_t *__restrict set, - sigset_t *__restrict oldset); + sigset_t *__restrict oldset) noexcept; } // namespace __llvm_libc diff --git a/libc/src/stdio/FILE.h b/libc/src/stdio/FILE.h index 54bc9b2c87311..7051838af4945 100644 --- a/libc/src/stdio/FILE.h +++ b/libc/src/stdio/FILE.h @@ -19,7 +19,7 @@ struct FILE { using write_function_t = size_t(FILE *, const char *, size_t); - write_function_t *write; + write_function_t *write noexcept; }; } // namespace __llvm_libc diff --git a/libc/src/stdio/fwrite.cpp b/libc/src/stdio/fwrite.cpp index 80cf50ca376e4..d54aad2ec0934 100644 --- a/libc/src/stdio/fwrite.cpp +++ b/libc/src/stdio/fwrite.cpp @@ -14,13 +14,13 @@ namespace __llvm_libc { size_t fwrite_unlocked(const void *__restrict ptr, size_t size, size_t nmeb, - __llvm_libc::FILE *__restrict stream) { + __llvm_libc::FILE *__restrict stream) noexcept { return stream->write(stream, reinterpret_cast(ptr), size * nmeb); } size_t fwrite(const void *__restrict ptr, size_t size, size_t nmeb, - __llvm_libc::FILE *__restrict stream) { + __llvm_libc::FILE *__restrict stream) noexcept { __llvm_libc::mtx_lock(&stream->lock); size_t written = fwrite_unlocked(ptr, size, nmeb, stream); __llvm_libc::mtx_unlock(&stream->lock); diff --git a/libc/src/stdio/fwrite.h b/libc/src/stdio/fwrite.h index 8a71ca105bb08..7dd03da033434 100644 --- a/libc/src/stdio/fwrite.h +++ b/libc/src/stdio/fwrite.h @@ -15,7 +15,7 @@ namespace __llvm_libc { size_t fwrite(const void *__restrict ptr, size_t size, size_t nmeb, - __llvm_libc::FILE *__restrict stream); + __llvm_libc::FILE *__restrict stream) noexcept; } // namespace __llvm_libc diff --git a/libc/src/stdlib/abort.cpp b/libc/src/stdlib/abort.cpp index 1da81611273de..0dfab6ebbeded 100644 --- a/libc/src/stdlib/abort.cpp +++ b/libc/src/stdlib/abort.cpp @@ -14,7 +14,7 @@ namespace __llvm_libc { -LLVM_LIBC_FUNCTION(void, abort, ()) { +[[noreturn]] LLVM_LIBC_FUNCTION(void, abort, ()) { // TODO: When sigprocmask and sigaction land: // Unblock SIGABRT, raise it, if it was ignored or the handler returned, // change its action to SIG_DFL, raise it again. diff --git a/libc/src/stdlib/abs.h b/libc/src/stdlib/abs.h index 42ef7f885ed65..d7fc1fd91f522 100644 --- a/libc/src/stdlib/abs.h +++ b/libc/src/stdlib/abs.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -int abs(int n); +int abs(int n) noexcept; } // namespace __llvm_libc diff --git a/libc/src/stdlib/labs.h b/libc/src/stdlib/labs.h index 0f0ea99dc22a7..5d52ca9701de6 100644 --- a/libc/src/stdlib/labs.h +++ b/libc/src/stdlib/labs.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -long labs(long n); +long labs(long n) noexcept; } // namespace __llvm_libc diff --git a/libc/src/stdlib/linux/_Exit.cpp b/libc/src/stdlib/linux/_Exit.cpp index 7fdd60ffe9bc6..89b223b35a6ba 100644 --- a/libc/src/stdlib/linux/_Exit.cpp +++ b/libc/src/stdlib/linux/_Exit.cpp @@ -14,7 +14,7 @@ namespace __llvm_libc { -LLVM_LIBC_FUNCTION(void, _Exit, (int status)) { +[[noreturn]] LLVM_LIBC_FUNCTION(void, _Exit, (int status)) { for (;;) { __llvm_libc::syscall(SYS_exit_group, status); __llvm_libc::syscall(SYS_exit, status); diff --git a/libc/src/stdlib/llabs.h b/libc/src/stdlib/llabs.h index f173431a14f15..fcbe64ca45682 100644 --- a/libc/src/stdlib/llabs.h +++ b/libc/src/stdlib/llabs.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -long long llabs(long long n); +long long llabs(long long n) noexcept; } // namespace __llvm_libc From 690324b85eb3af5f5c114433b6a69a54e2fa7523 Mon Sep 17 00:00:00 2001 From: Alfonso Gregory <83477269+gAlfonso-bit@users.noreply.github.com> Date: Mon, 26 Jul 2021 12:47:41 -0400 Subject: [PATCH 07/17] Done --- libc/src/sys/mman/mmap.h | 3 +- libc/src/sys/mman/munmap.h | 2 +- libc/src/threads/call_once.h | 2 +- libc/src/threads/linux/thrd_create.cpp | 2 +- .../linux/x86_64/thread_start_args.h.in | 2 +- libc/src/threads/mtx_init.h | 2 +- libc/src/threads/mtx_lock.h | 2 +- libc/src/threads/mtx_unlock.h | 2 +- libc/src/threads/thrd_create.h | 2 +- libc/src/threads/thrd_join.h | 2 +- libc/src/time/asctime.h | 2 +- libc/src/time/asctime_r.h | 2 +- libc/src/time/gmtime.h | 2 +- libc/src/time/gmtime_r.h | 2 +- libc/src/time/mktime.h | 2 +- libc/src/time/time_utils.h | 8 +-- libc/src/unistd/write.h | 2 +- libc/utils/CPP/Array.h | 2 +- libc/utils/CPP/ArrayRef.h | 26 +++++---- libc/utils/FPUtil/BasicOperations.h | 6 +- .../FPUtil/DivisionAndRemainderOperations.h | 2 +- libc/utils/FPUtil/FPBits.h | 40 +++++++------ libc/utils/FPUtil/Hypot.h | 8 +-- libc/utils/FPUtil/LongDoubleBitsX86.h | 40 +++++++------ libc/utils/FPUtil/ManipulationFunctions.h | 14 ++--- libc/utils/FPUtil/NearestIntegerOperations.h | 16 +++--- libc/utils/FPUtil/NextAfterLongDoubleX86.h | 2 +- libc/utils/FPUtil/NormalFloat.h | 12 ++-- libc/utils/FPUtil/PolyEval.h | 12 ++-- libc/utils/FPUtil/Sqrt.h | 15 +++-- libc/utils/FPUtil/SqrtLongDoubleX86.h | 5 +- llvm/include/llvm/Support/Compiler.h | 4 +- llvm/lib/TableGen/Error.cpp | 57 +++++++++++-------- 33 files changed, 166 insertions(+), 136 deletions(-) diff --git a/libc/src/sys/mman/mmap.h b/libc/src/sys/mman/mmap.h index c7aa404f65857..1cae4a7983d9d 100644 --- a/libc/src/sys/mman/mmap.h +++ b/libc/src/sys/mman/mmap.h @@ -13,7 +13,8 @@ namespace __llvm_libc { -void *mmap(void *addr, size_t size, int prot, int flags, int fd, off_t offset); +void *mmap(void *addr, size_t size, int prot, int flags, int fd, + off_t offset) noexcept; } // namespace __llvm_libc diff --git a/libc/src/sys/mman/munmap.h b/libc/src/sys/mman/munmap.h index ba272dc45e15f..72cd7508be9d0 100644 --- a/libc/src/sys/mman/munmap.h +++ b/libc/src/sys/mman/munmap.h @@ -13,7 +13,7 @@ namespace __llvm_libc { -int munmap(void *addr, size_t size); +int munmap(void *addr, size_t size) noexcept; } // namespace __llvm_libc diff --git a/libc/src/threads/call_once.h b/libc/src/threads/call_once.h index f6602df68197c..a4a8363594097 100644 --- a/libc/src/threads/call_once.h +++ b/libc/src/threads/call_once.h @@ -13,7 +13,7 @@ namespace __llvm_libc { -void call_once(once_flag *flag, __call_once_func_t func); +void call_once(once_flag *flag, __call_once_func_t func) noexcept; } // namespace __llvm_libc diff --git a/libc/src/threads/linux/thrd_create.cpp b/libc/src/threads/linux/thrd_create.cpp index 8b68f2a48688d..449b4a4f25f98 100644 --- a/libc/src/threads/linux/thrd_create.cpp +++ b/libc/src/threads/linux/thrd_create.cpp @@ -30,7 +30,7 @@ struct StartArgs { void *arg; }; -static __attribute__((noinline)) void start_thread() { +static __attribute__((noinline)) void start_thread() noexcept { StartArgs *start_args = reinterpret_cast(get_start_args_addr()); __llvm_libc::syscall(SYS_exit, start_args->thread->__retval = start_args->func(start_args->arg)); diff --git a/libc/src/threads/linux/x86_64/thread_start_args.h.in b/libc/src/threads/linux/x86_64/thread_start_args.h.in index 36365b98bb214..43e04ce4d34d5 100644 --- a/libc/src/threads/linux/x86_64/thread_start_args.h.in +++ b/libc/src/threads/linux/x86_64/thread_start_args.h.in @@ -10,7 +10,7 @@ namespace __llvm_libc { -__attribute__((always_inline)) inline uintptr_t get_start_args_addr() { +__attribute__((always_inline)) inline uintptr_t get_start_args_addr() noexcept { // NOTE: For __builtin_frame_address to work reliably across compilers, // architectures and various optimization levels, the TU including this file // should be compiled with -fno-omit-frame-pointer. diff --git a/libc/src/threads/mtx_init.h b/libc/src/threads/mtx_init.h index 7eed5ece6d5e7..a7302746a8ef5 100644 --- a/libc/src/threads/mtx_init.h +++ b/libc/src/threads/mtx_init.h @@ -13,7 +13,7 @@ namespace __llvm_libc { -int mtx_init(mtx_t *mutex, int type); +int mtx_init(mtx_t *mutex, int type) noexcept; } // namespace __llvm_libc diff --git a/libc/src/threads/mtx_lock.h b/libc/src/threads/mtx_lock.h index 5086f773f0fe6..6afd9d6da5ad4 100644 --- a/libc/src/threads/mtx_lock.h +++ b/libc/src/threads/mtx_lock.h @@ -13,7 +13,7 @@ namespace __llvm_libc { -int mtx_lock(mtx_t *mutex); +int mtx_lock(mtx_t *mutex) noexcept; } // namespace __llvm_libc diff --git a/libc/src/threads/mtx_unlock.h b/libc/src/threads/mtx_unlock.h index 55f0b4a7a6655..a28679993b495 100644 --- a/libc/src/threads/mtx_unlock.h +++ b/libc/src/threads/mtx_unlock.h @@ -13,7 +13,7 @@ namespace __llvm_libc { -int mtx_unlock(mtx_t *mutex); +int mtx_unlock(mtx_t *mutex) noexcept; } // namespace __llvm_libc diff --git a/libc/src/threads/thrd_create.h b/libc/src/threads/thrd_create.h index d2bb7dfad41c5..859d2cbec7eb0 100644 --- a/libc/src/threads/thrd_create.h +++ b/libc/src/threads/thrd_create.h @@ -13,7 +13,7 @@ namespace __llvm_libc { -int thrd_create(thrd_t *thread, thrd_start_t func, void *arg); +int thrd_create(thrd_t *thread, thrd_start_t func, void *arg) noexcept; } // namespace __llvm_libc diff --git a/libc/src/threads/thrd_join.h b/libc/src/threads/thrd_join.h index fc36503dc521c..fa9f6ebc0a806 100644 --- a/libc/src/threads/thrd_join.h +++ b/libc/src/threads/thrd_join.h @@ -13,7 +13,7 @@ namespace __llvm_libc { -int thrd_join(thrd_t *thread, int *retval); +int thrd_join(thrd_t *thread, int *retval) noexcept; } // namespace __llvm_libc diff --git a/libc/src/time/asctime.h b/libc/src/time/asctime.h index 9d75b40148afd..c0c6bfa258794 100644 --- a/libc/src/time/asctime.h +++ b/libc/src/time/asctime.h @@ -13,7 +13,7 @@ namespace __llvm_libc { -char *asctime(const struct tm *timeptr); +char *asctime(const struct tm *timeptr) noexcept; } // namespace __llvm_libc diff --git a/libc/src/time/asctime_r.h b/libc/src/time/asctime_r.h index 8521e782a509d..56c75826bf4bc 100644 --- a/libc/src/time/asctime_r.h +++ b/libc/src/time/asctime_r.h @@ -13,7 +13,7 @@ namespace __llvm_libc { -char *asctime_r(const struct tm *timeptr, char *buffer); +char *asctime_r(const struct tm *timeptr, char *buffer) noexcept; } // namespace __llvm_libc diff --git a/libc/src/time/gmtime.h b/libc/src/time/gmtime.h index 8891a8c917ac5..7203c743fc02b 100644 --- a/libc/src/time/gmtime.h +++ b/libc/src/time/gmtime.h @@ -13,7 +13,7 @@ namespace __llvm_libc { -struct tm *gmtime(const time_t *timer); +struct tm *gmtime(const time_t *timer) noexcept; } // namespace __llvm_libc diff --git a/libc/src/time/gmtime_r.h b/libc/src/time/gmtime_r.h index 8e9fc94b5ceed..9476b6d82353d 100644 --- a/libc/src/time/gmtime_r.h +++ b/libc/src/time/gmtime_r.h @@ -13,7 +13,7 @@ namespace __llvm_libc { -struct tm *gmtime_r(const time_t *timer, struct tm *result); +struct tm *gmtime_r(const time_t *timer, struct tm *result) noexcept; } // namespace __llvm_libc diff --git a/libc/src/time/mktime.h b/libc/src/time/mktime.h index ecd604c12fc35..b153cd24937a6 100644 --- a/libc/src/time/mktime.h +++ b/libc/src/time/mktime.h @@ -14,7 +14,7 @@ namespace __llvm_libc { -time_t mktime(struct tm *t1); +time_t mktime(struct tm *t1) noexcept; } // namespace __llvm_libc diff --git a/libc/src/time/time_utils.h b/libc/src/time/time_utils.h index c1c7735f49060..327a6538a170c 100644 --- a/libc/src/time/time_utils.h +++ b/libc/src/time/time_utils.h @@ -68,15 +68,15 @@ struct TimeConstants { extern int64_t UpdateFromSeconds(int64_t total_seconds, struct tm *tm); // POSIX.1-2017 requires this. -static inline time_t OutOfRange() { +static inline time_t OutOfRange() noexcept { llvmlibc_errno = EOVERFLOW; return static_cast(-1); } -static inline void InvalidValue() { llvmlibc_errno = EINVAL; } +static inline void InvalidValue() noexcept { llvmlibc_errno = EINVAL; } static inline char *asctime(const struct tm *timeptr, char *buffer, - size_t bufferLength) { + size_t bufferLength) noexcept { if (timeptr == nullptr || buffer == nullptr) { InvalidValue(); return nullptr; @@ -114,7 +114,7 @@ static inline char *asctime(const struct tm *timeptr, char *buffer, } static inline struct tm *gmtime_internal(const time_t *timer, - struct tm *result) { + struct tm *result) noexcept { int64_t seconds = *timer; // Update the tm structure's year, month, day, etc. from seconds. if (UpdateFromSeconds(seconds, result) < 0) { diff --git a/libc/src/unistd/write.h b/libc/src/unistd/write.h index d69c10a66f0f1..0ad6981645604 100644 --- a/libc/src/unistd/write.h +++ b/libc/src/unistd/write.h @@ -14,7 +14,7 @@ namespace __llvm_libc { -ssize_t write(int fd, const void *buf, size_t count); +ssize_t write(int fd, const void *buf, size_t count) noexcept; } // namespace __llvm_libc diff --git a/libc/utils/CPP/Array.h b/libc/utils/CPP/Array.h index c774a9f793d8c..9085ebd66f054 100644 --- a/libc/utils/CPP/Array.h +++ b/libc/utils/CPP/Array.h @@ -43,7 +43,7 @@ template struct Array { constexpr const_iterator begin() const { return Data; } constexpr iterator end() { return Data + N; } - const_iterator end() const { return Data + N; } + const_iterator end() const noexcept { return Data + N; } }; } // namespace cpp diff --git a/libc/utils/CPP/ArrayRef.h b/libc/utils/CPP/ArrayRef.h index cad7db9d3b663..9df6b7d7e2c4e 100644 --- a/libc/utils/CPP/ArrayRef.h +++ b/libc/utils/CPP/ArrayRef.h @@ -50,44 +50,46 @@ template class ArrayRefBase { template constexpr ArrayRefBase(QualifiedT (&Arr)[N]) : Data(Arr), Length(N) {} - QualifiedT *data() const { return Data; } - size_t size() const { return Length; } + QualifiedT *data() const noexcept { return Data; } + size_t size() const noexcept { return Length; } - auto begin() const { return data(); } - auto end() const { return data() + size(); } + auto begin() const noexcept { return data(); } + auto end() const noexcept { return data() + size(); } - bool empty() const { return size() == 0; } + bool empty() const noexcept { return size() == 0; } auto operator[](size_t Index) const { return data()[Index]; } // slice(n, m) - Chop off the first N elements of the array, and keep M // elements in the array. - auto slice(size_t N, size_t M) const { return ArrayRefBase(data() + N, M); } + auto slice(size_t N, size_t M) const noexcept { + return ArrayRefBase(data() + N, M); + } // slice(n) - Chop off the first N elements of the array. - auto slice(size_t N) const { return slice(N, size() - N); } + auto slice(size_t N) const noexcept { return slice(N, size() - N); } // Drop the first \p N elements of the array. - auto drop_front(size_t N = 1) const { return slice(N, size() - N); } + auto drop_front(size_t N = 1) const noexcept { return slice(N, size() - N); } // Drop the last \p N elements of the array. - auto drop_back(size_t N = 1) const { return slice(0, size() - N); } + auto drop_back(size_t N = 1) const noexcept { return slice(0, size() - N); } // Return a copy of *this with only the first \p N elements. - auto take_front(size_t N = 1) const { + auto take_front(size_t N = 1) const noexcept { if (N >= size()) return *this; return drop_back(size() - N); } // Return a copy of *this with only the last \p N elements. - auto take_back(size_t N = 1) const { + auto take_back(size_t N = 1) const noexcept { if (N >= size()) return *this; return drop_front(size() - N); } // equals - Check for element-wise equality. - bool equals(ArrayRefBase RHS) const { + bool equals(ArrayRefBase RHS) const noexcept { if (Length != RHS.Length) return false; auto First1 = begin(); diff --git a/libc/utils/FPUtil/BasicOperations.h b/libc/utils/FPUtil/BasicOperations.h index 43ccd12fdb70e..877119dea5e69 100644 --- a/libc/utils/FPUtil/BasicOperations.h +++ b/libc/utils/FPUtil/BasicOperations.h @@ -18,7 +18,7 @@ namespace fputil { template ::Value, int> = 0> -static inline T abs(T x) { +static inline T abs(T x) noexcept { FPBits bits(x); bits.setSign(0); return T(bits); @@ -26,7 +26,7 @@ static inline T abs(T x) { template ::Value, int> = 0> -static inline T fmin(T x, T y) { +static inline T fmin(T x, T y) noexcept { FPBits bitx(x), bity(y); if (bitx.isNaN()) { @@ -45,7 +45,7 @@ static inline T fmin(T x, T y) { template ::Value, int> = 0> -static inline T fmax(T x, T y) { +static inline T fmax(T x, T y) noexcept { FPBits bitx(x), bity(y); if (bitx.isNaN()) { diff --git a/libc/utils/FPUtil/DivisionAndRemainderOperations.h b/libc/utils/FPUtil/DivisionAndRemainderOperations.h index d23a8daabbe63..9493b408b547a 100644 --- a/libc/utils/FPUtil/DivisionAndRemainderOperations.h +++ b/libc/utils/FPUtil/DivisionAndRemainderOperations.h @@ -24,7 +24,7 @@ static constexpr int quotientLSBBits = 3; // to evaluate the quotient and remainder. template ::Value, int> = 0> -static inline T remquo(T x, T y, int &q) { +static inline T remquo(T x, T y, int &q) noexcept { FPBits xbits(x), ybits(y); if (xbits.isNaN()) return x; diff --git a/libc/utils/FPUtil/FPBits.h b/libc/utils/FPUtil/FPBits.h index 9ee870dc9983d..fca93cfc04081 100644 --- a/libc/utils/FPUtil/FPBits.h +++ b/libc/utils/FPUtil/FPBits.h @@ -48,32 +48,34 @@ template union FPBits { UIntType bits; - void setMantissa(UIntType mantVal) { + void setMantissa(UIntType mantVal) noexcept { mantVal &= (FloatProp::mantissaMask); bits &= ~(FloatProp::mantissaMask); bits |= mantVal; } - UIntType getMantissa() const { return bits & FloatProp::mantissaMask; } + UIntType getMantissa() const noexcept { + return bits & FloatProp::mantissaMask; + } - void setUnbiasedExponent(UIntType expVal) { + void setUnbiasedExponent(UIntType expVal) noexcept { expVal = (expVal << (FloatProp::mantissaWidth)) & FloatProp::exponentMask; bits &= ~(FloatProp::exponentMask); bits |= expVal; } - uint16_t getUnbiasedExponent() const { + uint16_t getUnbiasedExponent() const noexcept { return uint16_t((bits & FloatProp::exponentMask) >> (FloatProp::mantissaWidth)); } - void setSign(bool signVal) { + void setSign(bool signVal) noexcept { bits &= ~(FloatProp::signMask); UIntType sign = UIntType(signVal) << (FloatProp::bitWidth - 1); bits |= sign; } - bool getSign() const { + bool getSign() const noexcept { return ((bits & FloatProp::signMask) >> (FloatProp::bitWidth - 1)); } T val; @@ -106,43 +108,47 @@ template union FPBits { explicit operator T() { return val; } - UIntType uintval() const { return bits; } + UIntType uintval() const noexcept { return bits; } - int getExponent() const { return int(getUnbiasedExponent()) - exponentBias; } + int getExponent() const noexcept { + return int(getUnbiasedExponent()) - exponentBias; + } - bool isZero() const { + bool isZero() const noexcept { return getMantissa() == 0 && getUnbiasedExponent() == 0; } - bool isInf() const { + bool isInf() const noexcept { return getMantissa() == 0 && getUnbiasedExponent() == maxExponent; } - bool isNaN() const { + bool isNaN() const noexcept { return getUnbiasedExponent() == maxExponent && getMantissa() != 0; } - bool isInfOrNaN() const { return getUnbiasedExponent() == maxExponent; } + bool isInfOrNaN() const noexcept { + return getUnbiasedExponent() == maxExponent; + } - static FPBits zero() { return FPBits(); } + static FPBits zero() noexcept { return FPBits(); } - static FPBits negZero() { + static FPBits negZero() noexcept { return FPBits(UIntType(1) << (sizeof(UIntType) * 8 - 1)); } - static FPBits inf() { + static FPBits inf() noexcept { FPBits bits; bits.setUnbiasedExponent(maxExponent); return bits; } - static FPBits negInf() { + static FPBits negInf() noexcept { FPBits bits = inf(); bits.setSign(1); return bits; } - static T buildNaN(UIntType v) { + static T buildNaN(UIntType v) noexcept { FPBits bits = inf(); bits.setMantissa(v); return T(bits); diff --git a/libc/utils/FPUtil/Hypot.h b/libc/utils/FPUtil/Hypot.h index 8d108a74761de..a3983dafc6ce8 100644 --- a/libc/utils/FPUtil/Hypot.h +++ b/libc/utils/FPUtil/Hypot.h @@ -18,10 +18,10 @@ namespace fputil { namespace internal { -template static inline T findLeadingOne(T mant, int &shift_length); +template static inline T findLeadingOne(T mant, int &shift_length) noexcept; template <> -inline uint32_t findLeadingOne(uint32_t mant, int &shift_length) { +inline uint32_t findLeadingOne(uint32_t mant, int &shift_length) noexcept { shift_length = 0; constexpr int nsteps = 5; constexpr uint32_t bounds[nsteps] = {1 << 16, 1 << 8, 1 << 4, 1 << 2, 1 << 1}; @@ -36,7 +36,7 @@ inline uint32_t findLeadingOne(uint32_t mant, int &shift_length) { } template <> -inline uint64_t findLeadingOne(uint64_t mant, int &shift_length) { +inline uint64_t findLeadingOne(uint64_t mant, int &shift_length) noexcept { shift_length = 0; constexpr int nsteps = 6; constexpr uint64_t bounds[nsteps] = {1ULL << 32, 1ULL << 16, 1ULL << 8, @@ -117,7 +117,7 @@ template <> struct DoubleLength { using Type = __uint128_t; }; // template ::Value, int> = 0> -static inline T hypot(T x, T y) { +static inline T hypot(T x, T y) noexcept { using FPBits_t = FPBits; using UIntType = typename FPBits::UIntType; using DUIntType = typename DoubleLength::Type; diff --git a/libc/utils/FPUtil/LongDoubleBitsX86.h b/libc/utils/FPUtil/LongDoubleBitsX86.h index ce7fdb1b0fa8a..04c155b48a41f 100644 --- a/libc/utils/FPUtil/LongDoubleBitsX86.h +++ b/libc/utils/FPUtil/LongDoubleBitsX86.h @@ -43,43 +43,45 @@ template <> union FPBits { UIntType bits; - void setMantissa(UIntType mantVal) { + void setMantissa(UIntType mantVal) noexcept { mantVal &= (FloatProp::mantissaMask); bits &= ~(FloatProp::mantissaMask); bits |= mantVal; } - UIntType getMantissa() const { return bits & FloatProp::mantissaMask; } + UIntType getMantissa() const noexcept { + return bits & FloatProp::mantissaMask; + } - void setUnbiasedExponent(UIntType expVal) { + void setUnbiasedExponent(UIntType expVal) noexcept { expVal = (expVal << (FloatProp::bitWidth - 1 - FloatProp::exponentWidth)) & FloatProp::exponentMask; bits &= ~(FloatProp::exponentMask); bits |= expVal; } - uint16_t getUnbiasedExponent() const { + uint16_t getUnbiasedExponent() const noexcept { return uint16_t((bits & FloatProp::exponentMask) >> (FloatProp::bitWidth - 1 - FloatProp::exponentWidth)); } - void setImplicitBit(bool implicitVal) { + void setImplicitBit(bool implicitVal) noexcept { bits &= ~(UIntType(1) << FloatProp::mantissaWidth); bits |= (UIntType(implicitVal) << FloatProp::mantissaWidth); } - bool getImplicitBit() const { + bool getImplicitBit() const noexcept { return ((bits & (UIntType(1) << FloatProp::mantissaWidth)) >> FloatProp::mantissaWidth); } - void setSign(bool signVal) { + void setSign(bool signVal) noexcept { bits &= ~(FloatProp::signMask); UIntType sign1 = UIntType(signVal) << (FloatProp::bitWidth - 1); bits |= sign1; } - bool getSign() const { + bool getSign() const noexcept { return ((bits & FloatProp::signMask) >> (FloatProp::bitWidth - 1)); } @@ -106,23 +108,23 @@ template <> union FPBits { return bits & mask; } - int getExponent() const { + int getExponent() const noexcept { if (getUnbiasedExponent() == 0) return int(1) - exponentBias; return int(getUnbiasedExponent()) - exponentBias; } - bool isZero() const { + bool isZero() const noexcept { return getUnbiasedExponent() == 0 && getMantissa() == 0 && getImplicitBit() == 0; } - bool isInf() const { + bool isInf() const noexcept { return getUnbiasedExponent() == maxExponent && getMantissa() == 0 && getImplicitBit() == 1; } - bool isNaN() const { + bool isNaN() const noexcept { if (getUnbiasedExponent() == maxExponent) { return (getImplicitBit() == 0) || getMantissa() != 0; } else if (getUnbiasedExponent() != 0) { @@ -131,29 +133,31 @@ template <> union FPBits { return false; } - bool isInfOrNaN() const { + bool isInfOrNaN() const noexcept { return (getUnbiasedExponent() == maxExponent) || (getUnbiasedExponent() != 0 && getImplicitBit() == 0); } // Methods below this are used by tests. - static FPBits zero() { return FPBits(0.0l); } + static FPBits zero() noexcept { + return FPBits(0.0l); + } - static FPBits negZero() { + static FPBits negZero() noexcept { FPBits bits(0.0l); bits.setSign(1); return bits; } - static FPBits inf() { + static FPBits inf() noexcept { FPBits bits(0.0l); bits.setUnbiasedExponent(maxExponent); bits.setImplicitBit(1); return bits; } - static FPBits negInf() { + static FPBits negInf() noexcept { FPBits bits(0.0l); bits.setUnbiasedExponent(maxExponent); bits.setImplicitBit(1); @@ -161,7 +165,7 @@ template <> union FPBits { return bits; } - static long double buildNaN(UIntType v) { + static long double buildNaN(UIntType v) noexcept { FPBits bits(0.0l); bits.setUnbiasedExponent(maxExponent); bits.setImplicitBit(1); diff --git a/libc/utils/FPUtil/ManipulationFunctions.h b/libc/utils/FPUtil/ManipulationFunctions.h index 545e5f0f24288..ee06166c46b1a 100644 --- a/libc/utils/FPUtil/ManipulationFunctions.h +++ b/libc/utils/FPUtil/ManipulationFunctions.h @@ -24,7 +24,7 @@ namespace fputil { template ::Value, int> = 0> -static inline T frexp(T x, int &exp) { +static inline T frexp(T x, int &exp) noexcept { FPBits bits(x); if (bits.isInfOrNaN()) return x; @@ -41,7 +41,7 @@ static inline T frexp(T x, int &exp) { template ::Value, int> = 0> -static inline T modf(T x, T &iptr) { +static inline T modf(T x, T &iptr) noexcept { FPBits bits(x); if (bits.isZero() || bits.isNaN()) { iptr = x; @@ -63,7 +63,7 @@ static inline T modf(T x, T &iptr) { template ::Value, int> = 0> -static inline T copysign(T x, T y) { +static inline T copysign(T x, T y) noexcept { FPBits xbits(x); xbits.setSign(FPBits(y).getSign()); return T(xbits); @@ -71,7 +71,7 @@ static inline T copysign(T x, T y) { template ::Value, int> = 0> -static inline int ilogb(T x) { +static inline int ilogb(T x) noexcept { // TODO: Raise appropriate floating point exceptions and set errno to the // an appropriate error value wherever relevant. FPBits bits(x); @@ -100,7 +100,7 @@ static inline int ilogb(T x) { template ::Value, int> = 0> -static inline T logb(T x) { +static inline T logb(T x) noexcept { FPBits bits(x); if (bits.isZero()) { // TODO(Floating point exception): Raise div-by-zero exception. @@ -119,7 +119,7 @@ static inline T logb(T x) { template ::Value, int> = 0> -static inline T ldexp(T x, int exp) { +static inline T ldexp(T x, int exp) noexcept { FPBits bits(x); if (bits.isZero() || bits.isInfOrNaN() || exp == 0) return x; @@ -146,7 +146,7 @@ static inline T ldexp(T x, int exp) { template ::Value, int> = 0> -static inline T nextafter(T from, T to) { +static inline T nextafter(T from, T to) noexcept { FPBits fromBits(from); if (fromBits.isNaN()) return from; diff --git a/libc/utils/FPUtil/NearestIntegerOperations.h b/libc/utils/FPUtil/NearestIntegerOperations.h index 8dc4e23ce75c1..cc0b5142197ba 100644 --- a/libc/utils/FPUtil/NearestIntegerOperations.h +++ b/libc/utils/FPUtil/NearestIntegerOperations.h @@ -24,7 +24,7 @@ namespace fputil { template ::Value, int> = 0> -static inline T trunc(T x) { +static inline T trunc(T x) noexcept { FPBits bits(x); // If x is infinity or NaN, return it. @@ -56,7 +56,7 @@ static inline T trunc(T x) { template ::Value, int> = 0> -static inline T ceil(T x) { +static inline T ceil(T x) noexcept { FPBits bits(x); // If x is infinity NaN or zero, return it. @@ -95,7 +95,7 @@ static inline T ceil(T x) { template ::Value, int> = 0> -static inline T floor(T x) { +static inline T floor(T x) noexcept { FPBits bits(x); if (bits.getSign()) { return -ceil(-x); @@ -106,7 +106,7 @@ static inline T floor(T x) { template ::Value, int> = 0> -static inline T round(T x) { +static inline T round(T x) noexcept { using UIntType = typename FPBits::UIntType; FPBits bits(x); @@ -158,7 +158,7 @@ static inline T round(T x) { template ::Value, int> = 0> -static inline T roundUsingCurrentRoundingMode(T x) { +static inline T roundUsingCurrentRoundingMode(T x) noexcept { using UIntType = typename FPBits::UIntType; FPBits bits(x); @@ -240,7 +240,7 @@ template ::Value && cpp::IsIntegral::Value, int> = 0> -static inline I roundedFloatToSignedInteger(F x) { +static inline I roundedFloatToSignedInteger(F x) noexcept { constexpr I IntegerMin = (I(1) << (sizeof(I) * 8 - 1)); constexpr I IntegerMax = -(IntegerMin + 1); FPBits bits(x); @@ -284,7 +284,7 @@ template ::Value && cpp::IsIntegral::Value, int> = 0> -static inline I roundToSignedInteger(F x) { +static inline I roundToSignedInteger(F x) noexcept { return internal::roundedFloatToSignedInteger(round(x)); } @@ -292,7 +292,7 @@ template ::Value && cpp::IsIntegral::Value, int> = 0> -static inline I roundToSignedIntegerUsingCurrentRoundingMode(F x) { +static inline I roundToSignedIntegerUsingCurrentRoundingMode(F x) noexcept { return internal::roundedFloatToSignedInteger( roundUsingCurrentRoundingMode(x)); } diff --git a/libc/utils/FPUtil/NextAfterLongDoubleX86.h b/libc/utils/FPUtil/NextAfterLongDoubleX86.h index 80ca9ad084cb2..ea91c02140ffa 100644 --- a/libc/utils/FPUtil/NextAfterLongDoubleX86.h +++ b/libc/utils/FPUtil/NextAfterLongDoubleX86.h @@ -16,7 +16,7 @@ namespace __llvm_libc { namespace fputil { -static inline long double nextafter(long double from, long double to) { +static inline long double nextafter(long double from, long double to) noexcept { using FPBits = FPBits; FPBits fromBits(from); if (fromBits.isNaN()) diff --git a/libc/utils/FPUtil/NormalFloat.h b/libc/utils/FPUtil/NormalFloat.h index 2d50e88db9167..024d3e6f8f0d2 100644 --- a/libc/utils/FPUtil/NormalFloat.h +++ b/libc/utils/FPUtil/NormalFloat.h @@ -45,7 +45,7 @@ template struct NormalFloat { bool sign; NormalFloat(int32_t e, UIntType m, bool s) - : exponent(e), mantissa(m), sign(s) { + : exponent(e), mantissa(m), sign(s) noexcept { if (mantissa >= one) return; @@ -61,7 +61,7 @@ template struct NormalFloat { // Compares this normalized number with another normalized number. // Returns -1 is this number is less than |other|, 0 if this number is equal // to |other|, and 1 if this number is greater than |other|. - int cmp(const NormalFloat &other) const { + int cmp(const NormalFloat &other) const noexcept { if (sign != other.sign) return sign ? -1 : 1; @@ -82,7 +82,7 @@ template struct NormalFloat { // Returns a new normalized floating point number which is equal in value // to this number multiplied by 2^e. That is: // new = this * 2^e - NormalFloat mul2(int e) const { + NormalFloat mul2(int e) const noexcept { NormalFloat result = *this; result.exponent += e; return result; @@ -138,7 +138,7 @@ template struct NormalFloat { } private: - void initFromBits(FPBits bits) { + void initFromBits(FPBits bits) noexcept { sign = bits.getSign(); if (bits.isInfOrNaN() || bits.isZero()) { @@ -160,7 +160,7 @@ template struct NormalFloat { } } - unsigned evaluateNormalizationShift(UIntType m) { + unsigned evaluateNormalizationShift(UIntType m) noexcept { unsigned shift = 0; for (; (one & m) == 0 && (shift < MantissaWidth::value); m <<= 1, ++shift) @@ -171,7 +171,7 @@ template struct NormalFloat { #ifdef SPECIAL_X86_LONG_DOUBLE template <> -inline void NormalFloat::initFromBits(FPBits bits) { +inline void NormalFloat::initFromBits(FPBits bits) noexcept { sign = bits.getSign(); if (bits.isInfOrNaN() || bits.isZero()) { diff --git a/libc/utils/FPUtil/PolyEval.h b/libc/utils/FPUtil/PolyEval.h index ce8377fe895a1..313f57bcd032c 100644 --- a/libc/utils/FPUtil/PolyEval.h +++ b/libc/utils/FPUtil/PolyEval.h @@ -24,10 +24,12 @@ namespace __llvm_libc { namespace fputil { -template static inline T polyeval(T x, T a0) { return a0; } +template static inline T polyeval(T x, T a0) noexcept { + return a0; +} template -static inline T polyeval(T x, T a0, Ts... a) { +static inline T polyeval(T x, T a0, Ts... a) noexcept { return fma(x, polyeval(x, a...), a0); } @@ -39,10 +41,12 @@ static inline T polyeval(T x, T a0, Ts... a) { namespace __llvm_libc { namespace fputil { -template static inline T polyeval(T x, T a0) { return a0; } +template static inline T polyeval(T x, T a0) noexcept { + return a0; +} template -static inline T polyeval(T x, T a0, Ts... a) { +static inline T polyeval(T x, T a0, Ts... a) noexcept { return x * polyeval(x, a...) + a0; } diff --git a/libc/utils/FPUtil/Sqrt.h b/libc/utils/FPUtil/Sqrt.h index b977bc2ef8773..a15a0eb4cf9cb 100644 --- a/libc/utils/FPUtil/Sqrt.h +++ b/libc/utils/FPUtil/Sqrt.h @@ -21,9 +21,10 @@ namespace internal { template static inline void normalize(int &exponent, - typename FPBits::UIntType &mantissa); + typename FPBits::UIntType &mantissa) noexcept; -template <> inline void normalize(int &exponent, uint32_t &mantissa) { +template <> +inline void normalize(int &exponent, uint32_t &mantissa) noexcept { // Use binary search to shift the leading 1 bit. // With MantissaWidth = 23, it will take // ceil(log2(23)) = 5 steps checking the mantissa bits as followed: @@ -45,7 +46,8 @@ template <> inline void normalize(int &exponent, uint32_t &mantissa) { } } -template <> inline void normalize(int &exponent, uint64_t &mantissa) { +template <> +inline void normalize(int &exponent, uint64_t &mantissa) noexcept { // Use binary search to shift the leading 1 bit similar to float. // With MantissaWidth = 52, it will take // ceil(log2(52)) = 6 steps checking the mantissa bits. @@ -64,12 +66,13 @@ template <> inline void normalize(int &exponent, uint64_t &mantissa) { #ifdef LONG_DOUBLE_IS_DOUBLE template <> -inline void normalize(int &exponent, uint64_t &mantissa) { +inline void normalize(int &exponent, uint64_t &mantissa) noexcept { normalize(exponent, mantissa); } #elif !defined(SPECIAL_X86_LONG_DOUBLE) template <> -inline void normalize(int &exponent, __uint128_t &mantissa) { +inline void normalize(int &exponent, + __uint128_t &mantissa) noexcept { // Use binary search to shift the leading 1 bit similar to float. // With MantissaWidth = 112, it will take // ceil(log2(112)) = 7 steps checking the mantissa bits. @@ -95,7 +98,7 @@ inline void normalize(int &exponent, __uint128_t &mantissa) { // Shift-and-add algorithm. template ::Value, int> = 0> -static inline T sqrt(T x) { +static inline T sqrt(T x) noexcept { using UIntType = typename FPBits::UIntType; constexpr UIntType One = UIntType(1) << MantissaWidth::value; diff --git a/libc/utils/FPUtil/SqrtLongDoubleX86.h b/libc/utils/FPUtil/SqrtLongDoubleX86.h index 58326183678b8..2b21647550f3c 100644 --- a/libc/utils/FPUtil/SqrtLongDoubleX86.h +++ b/libc/utils/FPUtil/SqrtLongDoubleX86.h @@ -20,7 +20,8 @@ namespace fputil { namespace internal { template <> -inline void normalize(int &exponent, __uint128_t &mantissa) { +inline void normalize(int &exponent, + __uint128_t &mantissa) noexcept { // Use binary search to shift the leading 1 bit similar to float. // With MantissaWidth = 63, it will take // ceil(log2(63)) = 6 steps checking the mantissa bits. @@ -42,7 +43,7 @@ inline void normalize(int &exponent, __uint128_t &mantissa) { // Correctly rounded SQRT with round to nearest, ties to even. // Shift-and-add algorithm. -template <> inline long double sqrt(long double x) { +template <> inline long double sqrt(long double x) noexcept { using UIntType = typename FPBits::UIntType; constexpr UIntType One = UIntType(1) << int(MantissaWidth::value); diff --git a/llvm/include/llvm/Support/Compiler.h b/llvm/include/llvm/Support/Compiler.h index 57052b596edbe..ec90f75719470 100644 --- a/llvm/include/llvm/Support/Compiler.h +++ b/llvm/include/llvm/Support/Compiler.h @@ -246,8 +246,10 @@ #define LLVM_ATTRIBUTE_NORETURN __attribute__((noreturn)) #elif defined(_MSC_VER) #define LLVM_ATTRIBUTE_NORETURN __declspec(noreturn) +#elif __cplusplus +#define LLVM_ATTRIBUTE_NORETURN [[noreturn]] #else -#define LLVM_ATTRIBUTE_NORETURN +#define LLVM_ATTRIBUTE_NORETURN _Noreturn #endif #if __has_attribute(returns_nonnull) || LLVM_GNUC_PREREQ(4, 9, 0) diff --git a/llvm/lib/TableGen/Error.cpp b/llvm/lib/TableGen/Error.cpp index 6104573b4b25b..cf7c4dd129499 100644 --- a/llvm/lib/TableGen/Error.cpp +++ b/llvm/lib/TableGen/Error.cpp @@ -11,11 +11,11 @@ // //===----------------------------------------------------------------------===// +#include "llvm/TableGen/Error.h" #include "llvm/ADT/Twine.h" -#include "llvm/Support/raw_ostream.h" #include "llvm/Support/Signals.h" #include "llvm/Support/WithColor.h" -#include "llvm/TableGen/Error.h" +#include "llvm/Support/raw_ostream.h" #include "llvm/TableGen/Record.h" #include @@ -25,7 +25,7 @@ SourceMgr SrcMgr; unsigned ErrorsPrinted = 0; static void PrintMessage(ArrayRef Loc, SourceMgr::DiagKind Kind, - const Twine &Msg) { + const Twine &Msg) noexcept { // Count the total number of errors printed. // This is used to exit with an error code if there were any errors. if (Kind == SourceMgr::DK_Error) @@ -42,24 +42,23 @@ static void PrintMessage(ArrayRef Loc, SourceMgr::DiagKind Kind, // Functions to print notes. -void PrintNote(const Twine &Msg) { - WithColor::note() << Msg << "\n"; -} +void PrintNote(const Twine &Msg) noexcept { WithColor::note() << Msg << "\n"; } -void PrintNote(ArrayRef NoteLoc, const Twine &Msg) { +void PrintNote(ArrayRef NoteLoc, const Twine &Msg) noexcept { PrintMessage(NoteLoc, SourceMgr::DK_Note, Msg); } // Functions to print fatal notes. -void PrintFatalNote(const Twine &Msg) { +LLVM_ATTRIBUTE_NORETURN void PrintFatalNote(const Twine &Msg) noexcept { PrintNote(Msg); // The following call runs the file cleanup handlers. sys::RunInterruptHandlers(); std::exit(1); } -void PrintFatalNote(ArrayRef NoteLoc, const Twine &Msg) { +LLVM_ATTRIBUTE_NORETURN void PrintFatalNote(ArrayRef NoteLoc, + const Twine &Msg) noexcept { PrintNote(NoteLoc, Msg); // The following call runs the file cleanup handlers. sys::RunInterruptHandlers(); @@ -68,7 +67,7 @@ void PrintFatalNote(ArrayRef NoteLoc, const Twine &Msg) { // This method takes a Record and uses the source location // stored in it. -void PrintFatalNote(const Record *Rec, const Twine &Msg) { +LLVM_ATTRIBUTE_NORETURN void PrintFatalNote(const Record *Rec, const Twine &Msg) noexcept { PrintNote(Rec->getLoc(), Msg); // The following call runs the file cleanup handlers. sys::RunInterruptHandlers(); @@ -77,7 +76,8 @@ void PrintFatalNote(const Record *Rec, const Twine &Msg) { // This method takes a RecordVal and uses the source location // stored in it. -void PrintFatalNote(const RecordVal *RecVal, const Twine &Msg) { +LLVM_ATTRIBUTE_NORETURN void PrintFatalNote(const RecordVal *RecVal, + const Twine &Msg) noexcept { PrintNote(RecVal->getLoc(), Msg); // The following call runs the file cleanup handlers. sys::RunInterruptHandlers(); @@ -86,50 +86,55 @@ void PrintFatalNote(const RecordVal *RecVal, const Twine &Msg) { // Functions to print warnings. -void PrintWarning(const Twine &Msg) { WithColor::warning() << Msg << "\n"; } +void PrintWarning(const Twine &Msg) noexcept { + WithColor::warning() << Msg << "\n"; +} -void PrintWarning(ArrayRef WarningLoc, const Twine &Msg) { +void PrintWarning(ArrayRef WarningLoc, const Twine &Msg) noexcept { PrintMessage(WarningLoc, SourceMgr::DK_Warning, Msg); } -void PrintWarning(const char *Loc, const Twine &Msg) { +void PrintWarning(const char *Loc, const Twine &Msg) noexcept { SrcMgr.PrintMessage(SMLoc::getFromPointer(Loc), SourceMgr::DK_Warning, Msg); } // Functions to print errors. -void PrintError(const Twine &Msg) { WithColor::error() << Msg << "\n"; } +void PrintError(const Twine &Msg) noexcept { + WithColor::error() << Msg << "\n"; +} -void PrintError(ArrayRef ErrorLoc, const Twine &Msg) { +void PrintError(ArrayRef ErrorLoc, const Twine &Msg) noexcept { PrintMessage(ErrorLoc, SourceMgr::DK_Error, Msg); } -void PrintError(const char *Loc, const Twine &Msg) { +void PrintError(const char *Loc, const Twine &Msg) noexcept { SrcMgr.PrintMessage(SMLoc::getFromPointer(Loc), SourceMgr::DK_Error, Msg); } // This method takes a Record and uses the source location // stored in it. -void PrintError(const Record *Rec, const Twine &Msg) { +void PrintError(const Record *Rec, const Twine &Msg) noexcept { PrintMessage(Rec->getLoc(), SourceMgr::DK_Error, Msg); } // This method takes a RecordVal and uses the source location // stored in it. -void PrintError(const RecordVal *RecVal, const Twine &Msg) { +void PrintError(const RecordVal *RecVal, const Twine &Msg) noexcept { PrintMessage(RecVal->getLoc(), SourceMgr::DK_Error, Msg); } // Functions to print fatal errors. -void PrintFatalError(const Twine &Msg) { +[[noreturn]] void PrintFatalError(const Twine &Msg) noexcept { PrintError(Msg); // The following call runs the file cleanup handlers. sys::RunInterruptHandlers(); std::exit(1); } -void PrintFatalError(ArrayRef ErrorLoc, const Twine &Msg) { +[[noreturn]] void PrintFatalError(ArrayRef ErrorLoc, + const Twine &Msg) noexcept { PrintError(ErrorLoc, Msg); // The following call runs the file cleanup handlers. sys::RunInterruptHandlers(); @@ -138,7 +143,8 @@ void PrintFatalError(ArrayRef ErrorLoc, const Twine &Msg) { // This method takes a Record and uses the source location // stored in it. -void PrintFatalError(const Record *Rec, const Twine &Msg) { +[[noreturn]] void PrintFatalError(const Record *Rec, + const Twine &Msg) noexcept { PrintError(Rec->getLoc(), Msg); // The following call runs the file cleanup handlers. sys::RunInterruptHandlers(); @@ -147,7 +153,8 @@ void PrintFatalError(const Record *Rec, const Twine &Msg) { // This method takes a RecordVal and uses the source location // stored in it. -void PrintFatalError(const RecordVal *RecVal, const Twine &Msg) { +[[noreturn]] void PrintFatalError(const RecordVal *RecVal, + const Twine &Msg) noexcept { PrintError(RecVal->getLoc(), Msg); // The following call runs the file cleanup handlers. sys::RunInterruptHandlers(); @@ -156,9 +163,9 @@ void PrintFatalError(const RecordVal *RecVal, const Twine &Msg) { // Check an assertion: Obtain the condition value and be sure it is true. // If not, print a nonfatal error along with the message. -void CheckAssert(SMLoc Loc, Init *Condition, Init *Message) { +void CheckAssert(SMLoc Loc, Init *Condition, Init *Message) noexcept { auto *CondValue = dyn_cast_or_null( - Condition->convertInitializerTo(IntRecTy::get())); + Condition->convertInitializerTo(IntRecTy::get())); if (!CondValue) PrintError(Loc, "assert condition must of type bit, bits, or int."); else if (!CondValue->getValue()) { From a287b4d1ac7756ca224b28a5aea38c2f5a8d579f Mon Sep 17 00:00:00 2001 From: Alfonso Gregory <83477269+gAlfonso-bit@users.noreply.github.com> Date: Mon, 26 Jul 2021 13:28:33 -0400 Subject: [PATCH 08/17] Revert "math" This reverts commit ca034214fcc63fe50d909dacb909fc51a7960b32. --- libc/src/math/ceil.h | 2 +- libc/src/math/ceilf.h | 2 +- libc/src/math/ceill.h | 2 +- libc/src/math/copysign.h | 2 +- libc/src/math/copysignf.h | 2 +- libc/src/math/copysignl.h | 2 +- libc/src/math/cos.h | 2 +- libc/src/math/cosf.h | 2 +- libc/src/math/exp2f.h | 2 +- libc/src/math/expf.h | 2 +- libc/src/math/expm1f.h | 2 +- libc/src/math/fabs.h | 2 +- libc/src/math/fabsf.h | 2 +- libc/src/math/fabsl.h | 2 +- libc/src/math/fdim.h | 2 +- libc/src/math/fdimf.h | 2 +- libc/src/math/fdiml.h | 2 +- libc/src/math/floor.h | 2 +- libc/src/math/floorf.h | 2 +- libc/src/math/floorl.h | 2 +- libc/src/math/fma.h | 2 +- libc/src/math/fmaf.h | 2 +- libc/src/math/fmax.h | 2 +- libc/src/math/fmaxf.h | 2 +- libc/src/math/fmaxl.h | 2 +- libc/src/math/fmin.h | 2 +- libc/src/math/fminf.h | 2 +- libc/src/math/fminl.h | 2 +- libc/src/math/frexp.h | 2 +- libc/src/math/frexpf.h | 2 +- libc/src/math/frexpl.h | 2 +- libc/src/math/generic/math_utils.h | 34 +++++++++++---------------- libc/src/math/generic/sincosf_utils.h | 12 ++++------ libc/src/math/hypot.h | 2 +- libc/src/math/hypotf.h | 2 +- libc/src/math/ilogb.h | 2 +- libc/src/math/ilogbf.h | 2 +- libc/src/math/ilogbl.h | 2 +- libc/src/math/ldexp.h | 2 +- libc/src/math/ldexpf.h | 2 +- libc/src/math/ldexpl.h | 2 +- libc/src/math/llrint.h | 2 +- libc/src/math/llrintf.h | 2 +- libc/src/math/llrintl.h | 2 +- libc/src/math/llround.h | 2 +- libc/src/math/llroundf.h | 2 +- libc/src/math/llroundl.h | 2 +- libc/src/math/logb.h | 2 +- libc/src/math/logbf.h | 2 +- libc/src/math/logbl.h | 2 +- libc/src/math/lrint.h | 2 +- libc/src/math/lrintf.h | 2 +- libc/src/math/lrintl.h | 2 +- libc/src/math/lround.h | 2 +- libc/src/math/lroundf.h | 2 +- libc/src/math/lroundl.h | 2 +- libc/src/math/modf.h | 2 +- libc/src/math/modff.h | 2 +- libc/src/math/modfl.h | 2 +- libc/src/math/nearbyint.h | 2 +- libc/src/math/nearbyintf.h | 2 +- libc/src/math/nearbyintl.h | 2 +- libc/src/math/nextafter.h | 2 +- libc/src/math/nextafterf.h | 2 +- libc/src/math/nextafterl.h | 2 +- libc/src/math/remainder.h | 2 +- libc/src/math/remainderf.h | 2 +- libc/src/math/remainderl.h | 2 +- libc/src/math/remquo.h | 2 +- libc/src/math/remquof.h | 2 +- libc/src/math/remquol.h | 2 +- libc/src/math/rint.h | 2 +- libc/src/math/rintf.h | 2 +- libc/src/math/rintl.h | 2 +- libc/src/math/round.h | 2 +- libc/src/math/roundf.h | 2 +- libc/src/math/roundl.h | 2 +- libc/src/math/sin.h | 2 +- libc/src/math/sincosf.h | 2 +- libc/src/math/sinf.h | 2 +- libc/src/math/sqrt.h | 2 +- libc/src/math/sqrtf.h | 2 +- libc/src/math/sqrtl.h | 2 +- libc/src/math/tan.h | 2 +- libc/src/math/trunc.h | 2 +- libc/src/math/truncf.h | 2 +- libc/src/math/truncl.h | 2 +- 87 files changed, 104 insertions(+), 112 deletions(-) diff --git a/libc/src/math/ceil.h b/libc/src/math/ceil.h index b1a7e9b0fb70a..98188de20e405 100644 --- a/libc/src/math/ceil.h +++ b/libc/src/math/ceil.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -double ceil(double x) noexcept; +double ceil(double x); } // namespace __llvm_libc diff --git a/libc/src/math/ceilf.h b/libc/src/math/ceilf.h index 6f2add587808d..e8e64565052a6 100644 --- a/libc/src/math/ceilf.h +++ b/libc/src/math/ceilf.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -float ceilf(float x) noexcept; +float ceilf(float x); } // namespace __llvm_libc diff --git a/libc/src/math/ceill.h b/libc/src/math/ceill.h index 22184f4b55e3d..8bf4c565c7d3b 100644 --- a/libc/src/math/ceill.h +++ b/libc/src/math/ceill.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -long double ceill(long double x) noexcept; +long double ceill(long double x); } // namespace __llvm_libc diff --git a/libc/src/math/copysign.h b/libc/src/math/copysign.h index 21929390c36e2..edffe1b082fe0 100644 --- a/libc/src/math/copysign.h +++ b/libc/src/math/copysign.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -double copysign(double x, double y) noexcept; +double copysign(double x, double y); } // namespace __llvm_libc diff --git a/libc/src/math/copysignf.h b/libc/src/math/copysignf.h index 5affaa796553a..5b7f1132252d6 100644 --- a/libc/src/math/copysignf.h +++ b/libc/src/math/copysignf.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -float copysignf(float x, float y) noexcept; +float copysignf(float x, float y); } // namespace __llvm_libc diff --git a/libc/src/math/copysignl.h b/libc/src/math/copysignl.h index e815c52708d38..4f48323c70141 100644 --- a/libc/src/math/copysignl.h +++ b/libc/src/math/copysignl.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -long double copysignl(long double x, long double y) noexcept; +long double copysignl(long double x, long double y); } // namespace __llvm_libc diff --git a/libc/src/math/cos.h b/libc/src/math/cos.h index 71cb5504caabb..aca1d6d1e2281 100644 --- a/libc/src/math/cos.h +++ b/libc/src/math/cos.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -double cos(double x) noexcept; +double cos(double x); } // namespace __llvm_libc diff --git a/libc/src/math/cosf.h b/libc/src/math/cosf.h index f1b2e4f8b4a9a..1aaabe900ba88 100644 --- a/libc/src/math/cosf.h +++ b/libc/src/math/cosf.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -float cosf(float x) noexcept; +float cosf(float x); } // namespace __llvm_libc diff --git a/libc/src/math/exp2f.h b/libc/src/math/exp2f.h index 9a7496d693331..c1f72b1b80fa8 100644 --- a/libc/src/math/exp2f.h +++ b/libc/src/math/exp2f.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -float exp2f(float x) noexcept; +float exp2f(float x); } // namespace __llvm_libc diff --git a/libc/src/math/expf.h b/libc/src/math/expf.h index 6dc96333d3d66..c61ce98e9ddcf 100644 --- a/libc/src/math/expf.h +++ b/libc/src/math/expf.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -float expf(float x) noexcept; +float expf(float x); } // namespace __llvm_libc diff --git a/libc/src/math/expm1f.h b/libc/src/math/expm1f.h index d52fc9e1497e8..2577e4a492980 100644 --- a/libc/src/math/expm1f.h +++ b/libc/src/math/expm1f.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -float expm1f(float x) noexcept; +float expm1f(float x); } // namespace __llvm_libc diff --git a/libc/src/math/fabs.h b/libc/src/math/fabs.h index e4894213e90bc..424d2e01646b0 100644 --- a/libc/src/math/fabs.h +++ b/libc/src/math/fabs.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -double fabs(double x) noexcept; +double fabs(double x); } // namespace __llvm_libc diff --git a/libc/src/math/fabsf.h b/libc/src/math/fabsf.h index 0379397f9a95c..0ad97a027c6c8 100644 --- a/libc/src/math/fabsf.h +++ b/libc/src/math/fabsf.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -float fabsf(float x) noexcept; +float fabsf(float x); } // namespace __llvm_libc diff --git a/libc/src/math/fabsl.h b/libc/src/math/fabsl.h index 5625dea600184..fa25b1ab564d7 100644 --- a/libc/src/math/fabsl.h +++ b/libc/src/math/fabsl.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -long double fabsl(long double x) noexcept; +long double fabsl(long double x); } // namespace __llvm_libc diff --git a/libc/src/math/fdim.h b/libc/src/math/fdim.h index 1dbabb3e2980a..f838c121e291c 100644 --- a/libc/src/math/fdim.h +++ b/libc/src/math/fdim.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -double fdim(double x, double y) noexcept; +double fdim(double x, double y); } // namespace __llvm_libc diff --git a/libc/src/math/fdimf.h b/libc/src/math/fdimf.h index 8e5a650875efb..50c586c49cc39 100644 --- a/libc/src/math/fdimf.h +++ b/libc/src/math/fdimf.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -float fdimf(float x, float y) noexcept; +float fdimf(float x, float y); } // namespace __llvm_libc diff --git a/libc/src/math/fdiml.h b/libc/src/math/fdiml.h index 36b936054ec4c..6de261fe861a0 100644 --- a/libc/src/math/fdiml.h +++ b/libc/src/math/fdiml.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -long double fdiml(long double x, long double y) noexcept; +long double fdiml(long double x, long double y); } // namespace __llvm_libc diff --git a/libc/src/math/floor.h b/libc/src/math/floor.h index 7542f0f184f05..88a76ebf7d805 100644 --- a/libc/src/math/floor.h +++ b/libc/src/math/floor.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -double floor(double x) noexcept; +double floor(double x); } // namespace __llvm_libc diff --git a/libc/src/math/floorf.h b/libc/src/math/floorf.h index 2e4be43a63265..029df3ac5c9fe 100644 --- a/libc/src/math/floorf.h +++ b/libc/src/math/floorf.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -float floorf(float x) noexcept; +float floorf(float x); } // namespace __llvm_libc diff --git a/libc/src/math/floorl.h b/libc/src/math/floorl.h index 96895f54438d1..224cc13ec6fa6 100644 --- a/libc/src/math/floorl.h +++ b/libc/src/math/floorl.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -long double floorl(long double x) noexcept; +long double floorl(long double x); } // namespace __llvm_libc diff --git a/libc/src/math/fma.h b/libc/src/math/fma.h index f8346f604ba70..fbc7f09ee2c74 100644 --- a/libc/src/math/fma.h +++ b/libc/src/math/fma.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -double fma(double x, double y, double z) noexcept; +double fma(double x, double y, double z); } // namespace __llvm_libc diff --git a/libc/src/math/fmaf.h b/libc/src/math/fmaf.h index 89463d4999595..48fbb65d66506 100644 --- a/libc/src/math/fmaf.h +++ b/libc/src/math/fmaf.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -float fmaf(float x, float y, float z) noexcept; +float fmaf(float x, float y, float z); } // namespace __llvm_libc diff --git a/libc/src/math/fmax.h b/libc/src/math/fmax.h index b9697c8ecb8b7..9f057983d28bb 100644 --- a/libc/src/math/fmax.h +++ b/libc/src/math/fmax.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -double fmax(double x, double y) noexcept; +double fmax(double x, double y); } // namespace __llvm_libc diff --git a/libc/src/math/fmaxf.h b/libc/src/math/fmaxf.h index dfaebf014f40c..e37df5cf9565d 100644 --- a/libc/src/math/fmaxf.h +++ b/libc/src/math/fmaxf.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -float fmaxf(float x, float y) noexcept; +float fmaxf(float x, float y); } // namespace __llvm_libc diff --git a/libc/src/math/fmaxl.h b/libc/src/math/fmaxl.h index 78f52a8893de8..41d80ba4aa52c 100644 --- a/libc/src/math/fmaxl.h +++ b/libc/src/math/fmaxl.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -long double fmaxl(long double x, long double y) noexcept; +long double fmaxl(long double x, long double y); } // namespace __llvm_libc diff --git a/libc/src/math/fmin.h b/libc/src/math/fmin.h index 15c967f68120c..52334ee8e4560 100644 --- a/libc/src/math/fmin.h +++ b/libc/src/math/fmin.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -double fmin(double x, double y) noexcept; +double fmin(double x, double y); } // namespace __llvm_libc diff --git a/libc/src/math/fminf.h b/libc/src/math/fminf.h index cf30993743874..62dad57d852aa 100644 --- a/libc/src/math/fminf.h +++ b/libc/src/math/fminf.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -float fminf(float x, float y) noexcept; +float fminf(float x, float y); } // namespace __llvm_libc diff --git a/libc/src/math/fminl.h b/libc/src/math/fminl.h index eae2d0d607e51..c19505c018283 100644 --- a/libc/src/math/fminl.h +++ b/libc/src/math/fminl.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -long double fminl(long double x, long double y) noexcept; +long double fminl(long double x, long double y); } // namespace __llvm_libc diff --git a/libc/src/math/frexp.h b/libc/src/math/frexp.h index 71fe10fd1532c..9258243188360 100644 --- a/libc/src/math/frexp.h +++ b/libc/src/math/frexp.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -double frexp(double x, int *exp) noexcept; +double frexp(double x, int *exp); } // namespace __llvm_libc diff --git a/libc/src/math/frexpf.h b/libc/src/math/frexpf.h index 534effa24b2e9..ed303d2c76dd5 100644 --- a/libc/src/math/frexpf.h +++ b/libc/src/math/frexpf.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -float frexpf(float x, int *exp) noexcept; +float frexpf(float x, int *exp); } // namespace __llvm_libc diff --git a/libc/src/math/frexpl.h b/libc/src/math/frexpl.h index e5e96494a2b8f..9f75c82b9034a 100644 --- a/libc/src/math/frexpl.h +++ b/libc/src/math/frexpl.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -long double frexpl(long double x, int *exp) noexcept; +long double frexpl(long double x, int *exp); } // namespace __llvm_libc diff --git a/libc/src/math/generic/math_utils.h b/libc/src/math/generic/math_utils.h index e96b36f3e974c..4afddb04d6e43 100644 --- a/libc/src/math/generic/math_utils.h +++ b/libc/src/math/generic/math_utils.h @@ -18,29 +18,25 @@ namespace __llvm_libc { -static inline uint32_t as_uint32_bits(float x) noexcept { +static inline uint32_t as_uint32_bits(float x) { return *reinterpret_cast(&x); } -static inline uint64_t as_uint64_bits(double x) noexcept { +static inline uint64_t as_uint64_bits(double x) { return *reinterpret_cast(&x); } -static inline float as_float(uint32_t x) noexcept { +static inline float as_float(uint32_t x) { return *reinterpret_cast(&x); } -static inline double as_double(uint64_t x) noexcept { +static inline double as_double(uint64_t x) { return *reinterpret_cast(&x); } -static inline uint32_t top12_bits(float x) noexcept { - return as_uint32_bits(x) >> 20; -} +static inline uint32_t top12_bits(float x) { return as_uint32_bits(x) >> 20; } -static inline uint32_t top12_bits(double x) noexcept { - return as_uint64_bits(x) >> 52; -} +static inline uint32_t top12_bits(double x) { return as_uint64_bits(x) >> 52; } // Values to trigger underflow and overflow. template struct XFlowValues; @@ -57,17 +53,17 @@ template <> struct XFlowValues { static const double may_underflow_value; }; -template static inline T with_errno(T x, int err) noexcept { +template static inline T with_errno(T x, int err) { if (math_errhandling & MATH_ERRNO) errno = err; // NOLINT return x; } -template static inline void force_eval(T x) noexcept { +template static inline void force_eval(T x) { volatile T y UNUSED = x; } -template static inline T opt_barrier(T x) noexcept { +template static inline T opt_barrier(T x) { volatile T y = x; return y; } @@ -81,30 +77,28 @@ template using EnableIfFloatOrDouble = cpp::EnableIfType::Value, int>; template = 0> -T xflow(uint32_t sign, T y) noexcept { +T xflow(uint32_t sign, T y) { // Underflow happens when two extremely small values are multiplied. // Likewise, overflow happens when two large values are multiplied. y = opt_barrier(sign ? -y : y) * y; return with_errno(y, ERANGE); } -template = 0> -T overflow(uint32_t sign) noexcept { +template = 0> T overflow(uint32_t sign) { return xflow(sign, XFlowValues::overflow_value); } -template = 0> -T underflow(uint32_t sign) noexcept { +template = 0> T underflow(uint32_t sign) { return xflow(sign, XFlowValues::underflow_value); } template = 0> -T may_underflow(uint32_t sign) noexcept { +T may_underflow(uint32_t sign) { return xflow(sign, XFlowValues::may_underflow_value); } template = 0> -static constexpr float invalid(T x) { +static inline constexpr float invalid(T x) { T y = (x - x) / (x - x); return isnan(x) ? y : with_errno(y, EDOM); } diff --git a/libc/src/math/generic/sincosf_utils.h b/libc/src/math/generic/sincosf_utils.h index a6fbb18a9214e..8c54cb9c1d904 100644 --- a/libc/src/math/generic/sincosf_utils.h +++ b/libc/src/math/generic/sincosf_utils.h @@ -36,7 +36,7 @@ extern const sincos_t __sincosf_table[2]; extern const uint32_t __inv_pio4[]; // Top 12 bits of the float representation with the sign bit cleared. -static inline uint32_t abstop12(float x) noexcept { +static inline uint32_t abstop12(float x) { return (as_uint32_bits(x) >> 20) & 0x7ff; } @@ -44,7 +44,7 @@ static inline uint32_t abstop12(float x) noexcept { // polynomial P and store the results in SINP and COSP. N is the quadrant, // if odd the cosine and sine polynomials are swapped. static inline void sincosf_poly(double x, double x2, const sincos_t *p, int n, - float *sinp, float *cosp) noexcept { + float *sinp, float *cosp) { double x3, x4, x5, x6, s, c, c1, c2, s1; x4 = x2 * x2; @@ -70,8 +70,7 @@ static inline void sincosf_poly(double x, double x2, const sincos_t *p, int n, // Return the sine of inputs X and X2 (X squared) using the polynomial P. // N is the quadrant, and if odd the cosine polynomial is used. -static inline float sinf_poly(double x, double x2, const sincos_t *p, - int n) noexcept { +static inline float sinf_poly(double x, double x2, const sincos_t *p, int n) { double x3, x4, x6, x7, s, c, c1, c2, s1; if ((n & 1) == 0) { @@ -99,8 +98,7 @@ static inline float sinf_poly(double x, double x2, const sincos_t *p, // The values for PI/2 and 2/PI are accessed via P. Since PI/2 as a double // is accurate to 55 bits and the worst-case cancellation happens at 6 * PI/4, // the result is accurate for |X| <= 120.0. -static inline double reduce_fast(double x, const sincos_t *p, - int *np) noexcept { +static inline double reduce_fast(double x, const sincos_t *p, int *np) { double r; // Use scaled float to int conversion with explicit rounding. // hpi_inv is prescaled by 2^24 so the quadrant ends up in bits 24..31. @@ -118,7 +116,7 @@ static inline double reduce_fast(double x, const sincos_t *p, // multiply computes the exact 2.62-bit fixed-point modulo. Since the result // can have at most 29 leading zeros after the binary point, the double // precision result is accurate to 33 bits. -static inline double reduce_large(uint32_t xi, int *np) noexcept { +static inline double reduce_large(uint32_t xi, int *np) { const uint32_t *arr = &__inv_pio4[(xi >> 26) & 15]; int shift = (xi >> 23) & 7; uint64_t n, res0, res1, res2; diff --git a/libc/src/math/hypot.h b/libc/src/math/hypot.h index 5778813123a59..6c901ee8f4c0c 100644 --- a/libc/src/math/hypot.h +++ b/libc/src/math/hypot.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -double hypot(double x, double y) noexcept; +double hypot(double x, double y); } // namespace __llvm_libc diff --git a/libc/src/math/hypotf.h b/libc/src/math/hypotf.h index a64fa211477ab..084fd7f3ef814 100644 --- a/libc/src/math/hypotf.h +++ b/libc/src/math/hypotf.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -float hypotf(float x, float y) noexcept; +float hypotf(float x, float y); } // namespace __llvm_libc diff --git a/libc/src/math/ilogb.h b/libc/src/math/ilogb.h index 951dd44d30837..96672077865a9 100644 --- a/libc/src/math/ilogb.h +++ b/libc/src/math/ilogb.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -int ilogb(double x) noexcept; +int ilogb(double x); } // namespace __llvm_libc diff --git a/libc/src/math/ilogbf.h b/libc/src/math/ilogbf.h index d84c64f23b489..1afb76a107c1c 100644 --- a/libc/src/math/ilogbf.h +++ b/libc/src/math/ilogbf.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -int ilogbf(float x) noexcept; +int ilogbf(float x); } // namespace __llvm_libc diff --git a/libc/src/math/ilogbl.h b/libc/src/math/ilogbl.h index 24d9c5cb0da10..4d1cc1995341b 100644 --- a/libc/src/math/ilogbl.h +++ b/libc/src/math/ilogbl.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -int ilogbl(long double x) noexcept; +int ilogbl(long double x); } // namespace __llvm_libc diff --git a/libc/src/math/ldexp.h b/libc/src/math/ldexp.h index 6a3f486102037..74f9a600666fa 100644 --- a/libc/src/math/ldexp.h +++ b/libc/src/math/ldexp.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -double ldexp(double x, int exp) noexcept; +double ldexp(double x, int exp); } // namespace __llvm_libc diff --git a/libc/src/math/ldexpf.h b/libc/src/math/ldexpf.h index 9a79f0cfda724..f30d60155f1fd 100644 --- a/libc/src/math/ldexpf.h +++ b/libc/src/math/ldexpf.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -float ldexpf(float x, int exp) noexcept; +float ldexpf(float x, int exp); } // namespace __llvm_libc diff --git a/libc/src/math/ldexpl.h b/libc/src/math/ldexpl.h index ac1c6664d45d9..bf8435b1a21d8 100644 --- a/libc/src/math/ldexpl.h +++ b/libc/src/math/ldexpl.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -long double ldexpl(long double x, int exp) noexcept; +long double ldexpl(long double x, int exp); } // namespace __llvm_libc diff --git a/libc/src/math/llrint.h b/libc/src/math/llrint.h index 8a9c37022c22e..96bd7b8cc9e1c 100644 --- a/libc/src/math/llrint.h +++ b/libc/src/math/llrint.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -long long llrint(double x) noexcept; +long long llrint(double x); } // namespace __llvm_libc diff --git a/libc/src/math/llrintf.h b/libc/src/math/llrintf.h index eedd748c15c78..eecf380f5e94d 100644 --- a/libc/src/math/llrintf.h +++ b/libc/src/math/llrintf.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -long long llrintf(float x) noexcept; +long long llrintf(float x); } // namespace __llvm_libc diff --git a/libc/src/math/llrintl.h b/libc/src/math/llrintl.h index e6e5d46edf6a4..94dfba7080aa9 100644 --- a/libc/src/math/llrintl.h +++ b/libc/src/math/llrintl.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -long long llrintl(long double x) noexcept; +long long llrintl(long double x); } // namespace __llvm_libc diff --git a/libc/src/math/llround.h b/libc/src/math/llround.h index eae50a7d37dd7..5b2b7fc96df87 100644 --- a/libc/src/math/llround.h +++ b/libc/src/math/llround.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -long long llround(double x) noexcept; +long long llround(double x); } // namespace __llvm_libc diff --git a/libc/src/math/llroundf.h b/libc/src/math/llroundf.h index b65a8ddc0a285..65faad1e07a61 100644 --- a/libc/src/math/llroundf.h +++ b/libc/src/math/llroundf.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -long long llroundf(float x) noexcept; +long long llroundf(float x); } // namespace __llvm_libc diff --git a/libc/src/math/llroundl.h b/libc/src/math/llroundl.h index 7cdf620746b24..f859485a730bd 100644 --- a/libc/src/math/llroundl.h +++ b/libc/src/math/llroundl.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -long long llroundl(long double x) noexcept; +long long llroundl(long double x); } // namespace __llvm_libc diff --git a/libc/src/math/logb.h b/libc/src/math/logb.h index 6debaa8923632..b875dcd702bab 100644 --- a/libc/src/math/logb.h +++ b/libc/src/math/logb.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -double logb(double x) noexcept; +double logb(double x); } // namespace __llvm_libc diff --git a/libc/src/math/logbf.h b/libc/src/math/logbf.h index 7225b0252ad04..46dcd3c91d628 100644 --- a/libc/src/math/logbf.h +++ b/libc/src/math/logbf.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -float logbf(float x) noexcept; +float logbf(float x); } // namespace __llvm_libc diff --git a/libc/src/math/logbl.h b/libc/src/math/logbl.h index 07d2aa6f83801..3630e52c92d29 100644 --- a/libc/src/math/logbl.h +++ b/libc/src/math/logbl.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -long double logbl(long double x) noexcept; +long double logbl(long double x); } // namespace __llvm_libc diff --git a/libc/src/math/lrint.h b/libc/src/math/lrint.h index 565cae847e3d4..62df79a1de230 100644 --- a/libc/src/math/lrint.h +++ b/libc/src/math/lrint.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -long lrint(double x) noexcept; +long lrint(double x); } // namespace __llvm_libc diff --git a/libc/src/math/lrintf.h b/libc/src/math/lrintf.h index 604f53d76e5d3..af5159437532b 100644 --- a/libc/src/math/lrintf.h +++ b/libc/src/math/lrintf.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -long lrintf(float x) noexcept; +long lrintf(float x); } // namespace __llvm_libc diff --git a/libc/src/math/lrintl.h b/libc/src/math/lrintl.h index e16070f7c220e..812acecadafad 100644 --- a/libc/src/math/lrintl.h +++ b/libc/src/math/lrintl.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -long lrintl(long double x) noexcept; +long lrintl(long double x); } // namespace __llvm_libc diff --git a/libc/src/math/lround.h b/libc/src/math/lround.h index 78631d51562e3..8c555e816c8ba 100644 --- a/libc/src/math/lround.h +++ b/libc/src/math/lround.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -long lround(double x) noexcept; +long lround(double x); } // namespace __llvm_libc diff --git a/libc/src/math/lroundf.h b/libc/src/math/lroundf.h index 19e31f1a156d1..3d318a7a2faba 100644 --- a/libc/src/math/lroundf.h +++ b/libc/src/math/lroundf.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -long lroundf(float x) noexcept; +long lroundf(float x); } // namespace __llvm_libc diff --git a/libc/src/math/lroundl.h b/libc/src/math/lroundl.h index b6116e80925ee..a8b5aff0fcf38 100644 --- a/libc/src/math/lroundl.h +++ b/libc/src/math/lroundl.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -long lroundl(long double x) noexcept; +long lroundl(long double x); } // namespace __llvm_libc diff --git a/libc/src/math/modf.h b/libc/src/math/modf.h index 2816e1c53916f..1dc732f6e89ab 100644 --- a/libc/src/math/modf.h +++ b/libc/src/math/modf.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -double modf(double x, double *iptr) noexcept; +double modf(double x, double *iptr); } // namespace __llvm_libc diff --git a/libc/src/math/modff.h b/libc/src/math/modff.h index 36d5849836d54..21457e0d2e81a 100644 --- a/libc/src/math/modff.h +++ b/libc/src/math/modff.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -float modff(float x, float *iptr) noexcept; +float modff(float x, float *iptr); } // namespace __llvm_libc diff --git a/libc/src/math/modfl.h b/libc/src/math/modfl.h index 44206211bdf2e..ff89239c4bfde 100644 --- a/libc/src/math/modfl.h +++ b/libc/src/math/modfl.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -long double modfl(long double x, long double *iptr) noexcept; +long double modfl(long double x, long double *iptr); } // namespace __llvm_libc diff --git a/libc/src/math/nearbyint.h b/libc/src/math/nearbyint.h index bde631c421549..957a06b979214 100644 --- a/libc/src/math/nearbyint.h +++ b/libc/src/math/nearbyint.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -double nearbyint(double x) noexcept; +double nearbyint(double x); } // namespace __llvm_libc diff --git a/libc/src/math/nearbyintf.h b/libc/src/math/nearbyintf.h index 9d1f42a905f1b..3793f6bc1b881 100644 --- a/libc/src/math/nearbyintf.h +++ b/libc/src/math/nearbyintf.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -float nearbyintf(float x) noexcept; +float nearbyintf(float x); } // namespace __llvm_libc diff --git a/libc/src/math/nearbyintl.h b/libc/src/math/nearbyintl.h index 8b896002e178b..7029e86a52114 100644 --- a/libc/src/math/nearbyintl.h +++ b/libc/src/math/nearbyintl.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -long double nearbyintl(long double x) noexcept; +long double nearbyintl(long double x); } // namespace __llvm_libc diff --git a/libc/src/math/nextafter.h b/libc/src/math/nextafter.h index 89ff5cc4819b7..1f6d24de5f2e0 100644 --- a/libc/src/math/nextafter.h +++ b/libc/src/math/nextafter.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -double nextafter(double x, double y) noexcept; +double nextafter(double x, double y); } // namespace __llvm_libc diff --git a/libc/src/math/nextafterf.h b/libc/src/math/nextafterf.h index 9ab90f26fa148..8afac0e5f6a03 100644 --- a/libc/src/math/nextafterf.h +++ b/libc/src/math/nextafterf.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -float nextafterf(float x, float y) noexcept; +float nextafterf(float x, float y); } // namespace __llvm_libc diff --git a/libc/src/math/nextafterl.h b/libc/src/math/nextafterl.h index 14f652e9904b3..912877867dc21 100644 --- a/libc/src/math/nextafterl.h +++ b/libc/src/math/nextafterl.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -long double nextafterl(long double x, long double y) noexcept; +long double nextafterl(long double x, long double y); } // namespace __llvm_libc diff --git a/libc/src/math/remainder.h b/libc/src/math/remainder.h index 924fc15ec6abb..8a720fc23b6be 100644 --- a/libc/src/math/remainder.h +++ b/libc/src/math/remainder.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -double remainder(double x, double y) noexcept; +double remainder(double x, double y); } // namespace __llvm_libc diff --git a/libc/src/math/remainderf.h b/libc/src/math/remainderf.h index f177e5c7e08ea..19a16d08a94d3 100644 --- a/libc/src/math/remainderf.h +++ b/libc/src/math/remainderf.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -float remainderf(float x, float y) noexcept; +float remainderf(float x, float y); } // namespace __llvm_libc diff --git a/libc/src/math/remainderl.h b/libc/src/math/remainderl.h index 2aeb09c2b56f8..f2837635ab77c 100644 --- a/libc/src/math/remainderl.h +++ b/libc/src/math/remainderl.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -long double remainderl(long double x, long double y) noexcept; +long double remainderl(long double x, long double y); } // namespace __llvm_libc diff --git a/libc/src/math/remquo.h b/libc/src/math/remquo.h index c4a0b686aca28..cb753fee6ea0d 100644 --- a/libc/src/math/remquo.h +++ b/libc/src/math/remquo.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -double remquo(double x, double y, int *exp) noexcept; +double remquo(double x, double y, int *exp); } // namespace __llvm_libc diff --git a/libc/src/math/remquof.h b/libc/src/math/remquof.h index 53ae441acb475..feb2e4f5e0dd5 100644 --- a/libc/src/math/remquof.h +++ b/libc/src/math/remquof.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -float remquof(float x, float y, int *exp) noexcept; +float remquof(float x, float y, int *exp); } // namespace __llvm_libc diff --git a/libc/src/math/remquol.h b/libc/src/math/remquol.h index c50e3ec36faac..d1b0e20fcc865 100644 --- a/libc/src/math/remquol.h +++ b/libc/src/math/remquol.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -long double remquol(long double x, long double y, int *exp) noexcept; +long double remquol(long double x, long double y, int *exp); } // namespace __llvm_libc diff --git a/libc/src/math/rint.h b/libc/src/math/rint.h index f8b1a7612b527..e4910ad95a81c 100644 --- a/libc/src/math/rint.h +++ b/libc/src/math/rint.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -double rint(double x) noexcept; +double rint(double x); } // namespace __llvm_libc diff --git a/libc/src/math/rintf.h b/libc/src/math/rintf.h index 3de8f2703d4e7..0091ba3a8cd00 100644 --- a/libc/src/math/rintf.h +++ b/libc/src/math/rintf.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -float rintf(float x) noexcept; +float rintf(float x); } // namespace __llvm_libc diff --git a/libc/src/math/rintl.h b/libc/src/math/rintl.h index 93d45b394ab5f..2bf095de76f88 100644 --- a/libc/src/math/rintl.h +++ b/libc/src/math/rintl.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -long double rintl(long double x) noexcept; +long double rintl(long double x); } // namespace __llvm_libc diff --git a/libc/src/math/round.h b/libc/src/math/round.h index b0378a577e2f2..bb09ea4a77c53 100644 --- a/libc/src/math/round.h +++ b/libc/src/math/round.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -double round(double x) noexcept; +double round(double x); } // namespace __llvm_libc diff --git a/libc/src/math/roundf.h b/libc/src/math/roundf.h index 8d39f4267ed61..6bab35adf781a 100644 --- a/libc/src/math/roundf.h +++ b/libc/src/math/roundf.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -float roundf(float x) noexcept; +float roundf(float x); } // namespace __llvm_libc diff --git a/libc/src/math/roundl.h b/libc/src/math/roundl.h index 0b3aced3b2fa5..43fb63e231de4 100644 --- a/libc/src/math/roundl.h +++ b/libc/src/math/roundl.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -long double roundl(long double x) noexcept; +long double roundl(long double x); } // namespace __llvm_libc diff --git a/libc/src/math/sin.h b/libc/src/math/sin.h index 43dbe80fdb91c..f3919c46df603 100644 --- a/libc/src/math/sin.h +++ b/libc/src/math/sin.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -double sin(double x) noexcept; +double sin(double x); } // namespace __llvm_libc diff --git a/libc/src/math/sincosf.h b/libc/src/math/sincosf.h index 430f6f6417ae4..47ef983f4385f 100644 --- a/libc/src/math/sincosf.h +++ b/libc/src/math/sincosf.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -void sincosf(float x, float *sinx, float *cosx) noexcept; +void sincosf(float x, float *sinx, float *cosx); } // namespace __llvm_libc diff --git a/libc/src/math/sinf.h b/libc/src/math/sinf.h index 8e6b4f3dc0c30..e63db04c51b5d 100644 --- a/libc/src/math/sinf.h +++ b/libc/src/math/sinf.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -float sinf(float x) noexcept; +float sinf(float x); } // namespace __llvm_libc diff --git a/libc/src/math/sqrt.h b/libc/src/math/sqrt.h index 26dc527e8a5c0..2390e07b5dce5 100644 --- a/libc/src/math/sqrt.h +++ b/libc/src/math/sqrt.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -double sqrt(double x) noexcept; +double sqrt(double x); } // namespace __llvm_libc diff --git a/libc/src/math/sqrtf.h b/libc/src/math/sqrtf.h index 6ab9dbe208d7d..d1d06f3adfa8e 100644 --- a/libc/src/math/sqrtf.h +++ b/libc/src/math/sqrtf.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -float sqrtf(float x) noexcept; +float sqrtf(float x); } // namespace __llvm_libc diff --git a/libc/src/math/sqrtl.h b/libc/src/math/sqrtl.h index a033849d77c85..5fbfa14507147 100644 --- a/libc/src/math/sqrtl.h +++ b/libc/src/math/sqrtl.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -long double sqrtl(long double x) noexcept; +long double sqrtl(long double x); } // namespace __llvm_libc diff --git a/libc/src/math/tan.h b/libc/src/math/tan.h index 6e733be6746ff..05366db52ff87 100644 --- a/libc/src/math/tan.h +++ b/libc/src/math/tan.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -double tan(double x) noexcept; +double tan(double x); } // namespace __llvm_libc diff --git a/libc/src/math/trunc.h b/libc/src/math/trunc.h index dba5d37d027f8..f7fed01f30d25 100644 --- a/libc/src/math/trunc.h +++ b/libc/src/math/trunc.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -double trunc(double x) noexcept; +double trunc(double x); } // namespace __llvm_libc diff --git a/libc/src/math/truncf.h b/libc/src/math/truncf.h index 83f93b9dbf354..b4f1cd7ea72f6 100644 --- a/libc/src/math/truncf.h +++ b/libc/src/math/truncf.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -float truncf(float x) noexcept; +float truncf(float x); } // namespace __llvm_libc diff --git a/libc/src/math/truncl.h b/libc/src/math/truncl.h index 4b005c1e696ad..2a78ffaa3c5ef 100644 --- a/libc/src/math/truncl.h +++ b/libc/src/math/truncl.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -long double truncl(long double x) noexcept; +long double truncl(long double x); } // namespace __llvm_libc From fa4c372ea8afdcf314cbdacf61f6e81461d76ffe Mon Sep 17 00:00:00 2001 From: Alfonso Gregory <83477269+gAlfonso-bit@users.noreply.github.com> Date: Mon, 26 Jul 2021 13:29:02 -0400 Subject: [PATCH 09/17] Revert "Round 2" This reverts commit b565df0ded41ce4667f10cfc0601cfeb6e212ced. --- libc/src/errno/__errno_location.h | 2 +- libc/src/fenv/feclearexcept.h | 2 +- libc/src/fenv/fegetenv.h | 2 +- libc/src/fenv/fegetexceptflag.h | 2 +- libc/src/fenv/fegetround.h | 2 +- libc/src/fenv/feholdexcept.h | 2 +- libc/src/fenv/feraiseexcept.h | 2 +- libc/src/fenv/fesetenv.h | 2 +- libc/src/fenv/fesetexceptflag.h | 2 +- libc/src/fenv/fesetround.h | 2 +- libc/src/fenv/fetestexcept.h | 2 +- libc/src/fenv/feupdateenv.h | 2 +- libc/utils/FPUtil/x86_64/FEnvImpl.h | 45 ++++++++++++++--------------- libc/utils/FPUtil/x86_64/FMA.h | 8 ++--- 14 files changed, 38 insertions(+), 39 deletions(-) diff --git a/libc/src/errno/__errno_location.h b/libc/src/errno/__errno_location.h index edc98535f63ef..20be3fcf812ae 100644 --- a/libc/src/errno/__errno_location.h +++ b/libc/src/errno/__errno_location.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -int *__errno_location() noexcept; +int *__errno_location(); } // namespace __llvm_libc diff --git a/libc/src/fenv/feclearexcept.h b/libc/src/fenv/feclearexcept.h index 3266db3050ab7..fa771cee32a18 100644 --- a/libc/src/fenv/feclearexcept.h +++ b/libc/src/fenv/feclearexcept.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -int feclearexcept(int) noexcept; +int feclearexcept(int); } // namespace __llvm_libc diff --git a/libc/src/fenv/fegetenv.h b/libc/src/fenv/fegetenv.h index 3849a9bbd88ee..e1001682a42bb 100644 --- a/libc/src/fenv/fegetenv.h +++ b/libc/src/fenv/fegetenv.h @@ -13,7 +13,7 @@ namespace __llvm_libc { -int fegetenv(fenv_t *) noexcept; +int fegetenv(fenv_t *); } // namespace __llvm_libc diff --git a/libc/src/fenv/fegetexceptflag.h b/libc/src/fenv/fegetexceptflag.h index e173b4b722cf4..20913cb7a22f8 100644 --- a/libc/src/fenv/fegetexceptflag.h +++ b/libc/src/fenv/fegetexceptflag.h @@ -13,7 +13,7 @@ namespace __llvm_libc { -int fegetexceptflag(fexcept_t *, int excepts) noexcept; +int fegetexceptflag(fexcept_t *, int excepts); } // namespace __llvm_libc diff --git a/libc/src/fenv/fegetround.h b/libc/src/fenv/fegetround.h index 7934dea2beaf5..1bc79cbf5a6c4 100644 --- a/libc/src/fenv/fegetround.h +++ b/libc/src/fenv/fegetround.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -int fegetround() noexcept; +int fegetround(); } // namespace __llvm_libc diff --git a/libc/src/fenv/feholdexcept.h b/libc/src/fenv/feholdexcept.h index 5ac71e1d1c65b..cfb86b54ff49e 100644 --- a/libc/src/fenv/feholdexcept.h +++ b/libc/src/fenv/feholdexcept.h @@ -13,7 +13,7 @@ namespace __llvm_libc { -int feholdexcept(fenv_t *) noexcept; +int feholdexcept(fenv_t *); } // namespace __llvm_libc diff --git a/libc/src/fenv/feraiseexcept.h b/libc/src/fenv/feraiseexcept.h index 446b255243eba..5c9eacf462d49 100644 --- a/libc/src/fenv/feraiseexcept.h +++ b/libc/src/fenv/feraiseexcept.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -int feraiseexcept(int) noexcept; +int feraiseexcept(int); } // namespace __llvm_libc diff --git a/libc/src/fenv/fesetenv.h b/libc/src/fenv/fesetenv.h index fc6d612f193a2..316ecee41996e 100644 --- a/libc/src/fenv/fesetenv.h +++ b/libc/src/fenv/fesetenv.h @@ -13,7 +13,7 @@ namespace __llvm_libc { -int fesetenv(const fenv_t *) noexcept; +int fesetenv(const fenv_t *); } // namespace __llvm_libc diff --git a/libc/src/fenv/fesetexceptflag.h b/libc/src/fenv/fesetexceptflag.h index 05dfe59a8e54b..0e6497abafaed 100644 --- a/libc/src/fenv/fesetexceptflag.h +++ b/libc/src/fenv/fesetexceptflag.h @@ -13,7 +13,7 @@ namespace __llvm_libc { -int fesetexceptflag(const fexcept_t *, int excepts) noexcept; +int fesetexceptflag(const fexcept_t *, int excepts); } // namespace __llvm_libc diff --git a/libc/src/fenv/fesetround.h b/libc/src/fenv/fesetround.h index 6ad8c24f045d6..148a5eabcf3d5 100644 --- a/libc/src/fenv/fesetround.h +++ b/libc/src/fenv/fesetround.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -int fesetround(int) noexcept; +int fesetround(int); } // namespace __llvm_libc diff --git a/libc/src/fenv/fetestexcept.h b/libc/src/fenv/fetestexcept.h index f67796343ae63..fb3e4045dd6b0 100644 --- a/libc/src/fenv/fetestexcept.h +++ b/libc/src/fenv/fetestexcept.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -int fetestexcept(int) noexcept; +int fetestexcept(int); } // namespace __llvm_libc diff --git a/libc/src/fenv/feupdateenv.h b/libc/src/fenv/feupdateenv.h index 9e2d6cec67e69..1599c01ebddff 100644 --- a/libc/src/fenv/feupdateenv.h +++ b/libc/src/fenv/feupdateenv.h @@ -13,7 +13,7 @@ namespace __llvm_libc { -int feupdateenv(const fenv_t *) noexcept; +int feupdateenv(const fenv_t *); } // namespace __llvm_libc diff --git a/libc/utils/FPUtil/x86_64/FEnvImpl.h b/libc/utils/FPUtil/x86_64/FEnvImpl.h index f628d3211bb4b..fae74bb5da9bc 100644 --- a/libc/utils/FPUtil/x86_64/FEnvImpl.h +++ b/libc/utils/FPUtil/x86_64/FEnvImpl.h @@ -61,7 +61,7 @@ static constexpr uint16_t MXCSRExceptionContolBitPoistion = 7; // Exception flags are individual bits in the corresponding registers. // So, we just OR the bit values to get the full set of exceptions. -static constexpr uint16_t getStatusValueForExcept(int excepts) { +static inline uint16_t getStatusValueForExcept(int excepts) { // We will make use of the fact that exception control bits are single // bit flags in the control registers. return (excepts & FE_INVALID ? ExceptionFlags::Invalid : 0) | @@ -74,7 +74,7 @@ static constexpr uint16_t getStatusValueForExcept(int excepts) { (excepts & FE_INEXACT ? ExceptionFlags::Inexact : 0); } -static constexpr int exceptionStatusToMacro(uint16_t status) { +static inline int exceptionStatusToMacro(uint16_t status) { return (status & ExceptionFlags::Invalid ? FE_INVALID : 0) | #ifdef __FE_DENORM (status & ExceptionFlags::Denormal ? __FE_DENORM : 0) | @@ -107,54 +107,53 @@ static_assert( sizeof(fenv_t) == sizeof(FPState), "Internal floating point state does not match the public fenv_t type."); -static inline uint16_t getX87ControlWord() noexcept { +static inline uint16_t getX87ControlWord() { uint16_t w; __asm__ __volatile__("fnstcw %0" : "=m"(w)::); SANITIZER_MEMORY_INITIALIZED(&w, sizeof(w)); return w; } -static inline void writeX87ControlWord(uint16_t w) noexcept { +static inline void writeX87ControlWord(uint16_t w) { __asm__ __volatile__("fldcw %0" : : "m"(w) :); } -static inline uint16_t getX87StatusWord() noexcept { +static inline uint16_t getX87StatusWord() { uint16_t w; __asm__ __volatile__("fnstsw %0" : "=m"(w)::); SANITIZER_MEMORY_INITIALIZED(&w, sizeof(w)); return w; } -static inline void clearX87Exceptions() noexcept { +static inline void clearX87Exceptions() { __asm__ __volatile__("fnclex" : : :); } -static inline uint32_t getMXCSR() noexcept { +static inline uint32_t getMXCSR() { uint32_t w; __asm__ __volatile__("stmxcsr %0" : "=m"(w)::); SANITIZER_MEMORY_INITIALIZED(&w, sizeof(w)); return w; } -static inline void writeMXCSR(uint32_t w) noexcept { +static inline void writeMXCSR(uint32_t w) { __asm__ __volatile__("ldmxcsr %0" : : "m"(w) :); } -static inline void getX87StateDescriptor(X87StateDescriptor &s) noexcept { +static inline void getX87StateDescriptor(X87StateDescriptor &s) { __asm__ __volatile__("fnstenv %0" : "=m"(s)); SANITIZER_MEMORY_INITIALIZED(&s, sizeof(s)); } -static inline void -writeX87StateDescriptor(const X87StateDescriptor &s) noexcept { +static inline void writeX87StateDescriptor(const X87StateDescriptor &s) { __asm__ __volatile__("fldenv %0" : : "m"(s) :); } -static inline void fwait() noexcept { __asm__ __volatile__("fwait"); } +static inline void fwait() { __asm__ __volatile__("fwait"); } } // namespace internal -static inline int enableExcept(int excepts) noexcept { +static inline int enableExcept(int excepts) { // In the x87 control word and in MXCSR, an exception is blocked // if the corresponding bit is set. That is the reason for all the // bit-flip operations below as we need to turn the bits to zero @@ -181,7 +180,7 @@ static inline int enableExcept(int excepts) noexcept { return internal::exceptionStatusToMacro(oldExcepts); } -static inline int disableExcept(int excepts) noexcept { +static inline int disableExcept(int excepts) { // In the x87 control word and in MXCSR, an exception is blocked // if the corresponding bit is set. @@ -201,7 +200,7 @@ static inline int disableExcept(int excepts) noexcept { return internal::exceptionStatusToMacro(oldExcepts); } -static inline int clearExcept(int excepts) noexcept { +static inline int clearExcept(int excepts) { internal::X87StateDescriptor state; internal::getX87StateDescriptor(state); state.StatusWord &= ~internal::getStatusValueForExcept(excepts); @@ -213,7 +212,7 @@ static inline int clearExcept(int excepts) noexcept { return 0; } -static inline int testExcept(int excepts) noexcept { +static inline int testExcept(int excepts) { uint16_t statusValue = internal::getStatusValueForExcept(excepts); // Check both x87 status word and MXCSR. return internal::exceptionStatusToMacro( @@ -222,7 +221,7 @@ static inline int testExcept(int excepts) noexcept { } // Sets the exception flags but does not trigger the exception handler. -static inline int setExcept(int excepts) noexcept { +static inline int setExcept(int excepts) { uint16_t statusValue = internal::getStatusValueForExcept(excepts); internal::X87StateDescriptor state; internal::getX87StateDescriptor(state); @@ -236,7 +235,7 @@ static inline int setExcept(int excepts) noexcept { return 0; } -static inline int raiseExcept(int excepts) noexcept { +static inline int raiseExcept(int excepts) { uint16_t statusValue = internal::getStatusValueForExcept(excepts); // We set the status flag for exception one at a time and call the @@ -252,7 +251,7 @@ static inline int raiseExcept(int excepts) noexcept { // ensure that the writes by the exception handler are maintained // when raising the next exception. - auto raiseHelper = [](uint16_t singleExceptFlag) { + auto raiseHelper = [](uint16_t singleExceptFlag) { internal::X87StateDescriptor state; internal::getX87StateDescriptor(state); state.StatusWord |= singleExceptFlag; @@ -284,7 +283,7 @@ static inline int raiseExcept(int excepts) noexcept { return 0; } -static inline int getRound() noexcept { +static inline int getRound() { uint16_t bitValue = (internal::getMXCSR() >> internal::MXCSRRoundingControlBitPosition) & 0x3; switch (bitValue) { @@ -301,7 +300,7 @@ static inline int getRound() noexcept { } } -static inline int setRound(int mode) noexcept { +static inline int setRound(int mode) { uint16_t bitValue; switch (mode) { case FE_TONEAREST: @@ -340,14 +339,14 @@ static inline int setRound(int mode) noexcept { } #if !(defined(_WIN32)) -static inline int getEnv(fenv_t *envp) noexcept { +static inline int getEnv(fenv_t *envp) { internal::FPState *state = reinterpret_cast(envp); internal::getX87StateDescriptor(state->X87Status); state->MXCSR = internal::getMXCSR(); return 0; } -static inline int setEnv(const fenv_t *envp) noexcept { +static inline int setEnv(const fenv_t *envp) { const internal::FPState *state = reinterpret_cast(envp); internal::writeX87StateDescriptor(state->X87Status); diff --git a/libc/utils/FPUtil/x86_64/FMA.h b/libc/utils/FPUtil/x86_64/FMA.h index 0f38e837cbca5..e1bc806e4ac8b 100644 --- a/libc/utils/FPUtil/x86_64/FMA.h +++ b/libc/utils/FPUtil/x86_64/FMA.h @@ -15,8 +15,8 @@ namespace __llvm_libc { namespace fputil { template -static inline cpp::EnableIfType::Value, T> -fma(T x, T y, T z) noexcept { +static inline cpp::EnableIfType::Value, T> fma(T x, T y, + T z) { float result = x; __asm__ __volatile__("vfmadd213ss %x2, %x1, %x0" : "+x"(result) @@ -25,8 +25,8 @@ fma(T x, T y, T z) noexcept { } template -static inline cpp::EnableIfType::Value, T> -fma(T x, T y, T z) noexcept { +static inline cpp::EnableIfType::Value, T> fma(T x, T y, + T z) { double result = x; __asm__ __volatile__("vfmadd213sd %x2, %x1, %x0" : "+x"(result) From a112a6ecb6b39d3723492e6806901cd6a1e57972 Mon Sep 17 00:00:00 2001 From: Alfonso Gregory <83477269+gAlfonso-bit@users.noreply.github.com> Date: Mon, 26 Jul 2021 13:29:47 -0400 Subject: [PATCH 10/17] OK --- libc/utils/FPUtil/x86_64/FEnvImpl.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libc/utils/FPUtil/x86_64/FEnvImpl.h b/libc/utils/FPUtil/x86_64/FEnvImpl.h index fae74bb5da9bc..e235d83fb2354 100644 --- a/libc/utils/FPUtil/x86_64/FEnvImpl.h +++ b/libc/utils/FPUtil/x86_64/FEnvImpl.h @@ -61,7 +61,7 @@ static constexpr uint16_t MXCSRExceptionContolBitPoistion = 7; // Exception flags are individual bits in the corresponding registers. // So, we just OR the bit values to get the full set of exceptions. -static inline uint16_t getStatusValueForExcept(int excepts) { +static constexpr uint16_t getStatusValueForExcept(int excepts) { // We will make use of the fact that exception control bits are single // bit flags in the control registers. return (excepts & FE_INVALID ? ExceptionFlags::Invalid : 0) | @@ -74,7 +74,7 @@ static inline uint16_t getStatusValueForExcept(int excepts) { (excepts & FE_INEXACT ? ExceptionFlags::Inexact : 0); } -static inline int exceptionStatusToMacro(uint16_t status) { +static constexpr int exceptionStatusToMacro(uint16_t status) { return (status & ExceptionFlags::Invalid ? FE_INVALID : 0) | #ifdef __FE_DENORM (status & ExceptionFlags::Denormal ? __FE_DENORM : 0) | @@ -251,7 +251,7 @@ static inline int raiseExcept(int excepts) { // ensure that the writes by the exception handler are maintained // when raising the next exception. - auto raiseHelper = [](uint16_t singleExceptFlag) { + auto raiseHelper = [](uint16_t singleExceptFlag) { internal::X87StateDescriptor state; internal::getX87StateDescriptor(state); state.StatusWord |= singleExceptFlag; From 1e4eba0170602cbcd761eb8b1f0f5ade54d0f6c7 Mon Sep 17 00:00:00 2001 From: Alfonso Gregory <83477269+gAlfonso-bit@users.noreply.github.com> Date: Mon, 26 Jul 2021 13:30:30 -0400 Subject: [PATCH 11/17] Revert "stdlib and signal" This reverts commit 857d6ccbc48c5b549b828c7cd15c963517acd188. --- libc/config/linux/x86_64/syscall.h.inc | 159 ++++++++++++------------- libc/src/signal/linux/sigaction.cpp | 2 +- libc/src/signal/linux/sigaddset.cpp | 4 +- libc/src/signal/linux/sigdelset.cpp | 4 +- libc/src/signal/linux/sigemptyset.cpp | 2 +- libc/src/signal/linux/sigfillset.cpp | 2 +- libc/src/signal/linux/signal.h | 4 +- libc/src/signal/raise.h | 2 +- libc/src/signal/sigaction.h | 2 +- libc/src/signal/sigaddset.h | 2 +- libc/src/signal/sigdelset.h | 2 +- libc/src/signal/sigemptyset.h | 2 +- libc/src/signal/sigfillset.h | 2 +- libc/src/signal/signal.h | 2 +- libc/src/signal/sigprocmask.h | 2 +- libc/src/stdio/FILE.h | 2 +- libc/src/stdio/fwrite.cpp | 4 +- libc/src/stdio/fwrite.h | 2 +- libc/src/stdlib/abort.cpp | 2 +- libc/src/stdlib/abs.h | 2 +- libc/src/stdlib/labs.h | 2 +- libc/src/stdlib/linux/_Exit.cpp | 2 +- libc/src/stdlib/llabs.h | 2 +- 23 files changed, 105 insertions(+), 106 deletions(-) diff --git a/libc/config/linux/x86_64/syscall.h.inc b/libc/config/linux/x86_64/syscall.h.inc index de34d8ed21625..ee3b5e5bfc0d7 100644 --- a/libc/config/linux/x86_64/syscall.h.inc +++ b/libc/config/linux/x86_64/syscall.h.inc @@ -14,93 +14,92 @@ namespace __llvm_libc { - __attribute__((always_inline)) inline long syscall(long __number) noexcept { - long retcode; - LIBC_INLINE_ASM("syscall" - : "=a"(retcode) - : "a"(__number) - : SYSCALL_CLOBBER_LIST); - return retcode; - } +__attribute__((always_inline)) inline long syscall(long __number) { + long retcode; + LIBC_INLINE_ASM("syscall" + : "=a"(retcode) + : "a"(__number) + : SYSCALL_CLOBBER_LIST); + return retcode; +} - __attribute__((always_inline)) inline long syscall(long __number, - long __arg1) noexcept { - long retcode; - LIBC_INLINE_ASM("syscall" - : "=a"(retcode) - : "a"(__number), "D"(__arg1) - : SYSCALL_CLOBBER_LIST); - return retcode; - } +__attribute__((always_inline)) inline long syscall(long __number, long __arg1) { + long retcode; + LIBC_INLINE_ASM("syscall" + : "=a"(retcode) + : "a"(__number), "D"(__arg1) + : SYSCALL_CLOBBER_LIST); + return retcode; +} - __attribute__((always_inline)) inline long syscall(long __number, long __arg1, - long __arg2) noexcept { - long retcode; - LIBC_INLINE_ASM("syscall" - : "=a"(retcode) - : "a"(__number), "D"(__arg1), "S"(__arg2) - : SYSCALL_CLOBBER_LIST); - return retcode; - } +__attribute__((always_inline)) inline long syscall(long __number, long __arg1, + long __arg2) { + long retcode; + LIBC_INLINE_ASM("syscall" + : "=a"(retcode) + : "a"(__number), "D"(__arg1), "S"(__arg2) + : SYSCALL_CLOBBER_LIST); + return retcode; +} - __attribute__((always_inline)) inline long syscall( - long __number, long __arg1, long __arg2, long __arg3) noexcept { - long retcode; - LIBC_INLINE_ASM("syscall" - : "=a"(retcode) - : "a"(__number), "D"(__arg1), "S"(__arg2), "d"(__arg3) - : SYSCALL_CLOBBER_LIST); - return retcode; - } +__attribute__((always_inline)) inline long syscall(long __number, long __arg1, + long __arg2, long __arg3) { + long retcode; + LIBC_INLINE_ASM("syscall" + : "=a"(retcode) + : "a"(__number), "D"(__arg1), "S"(__arg2), "d"(__arg3) + : SYSCALL_CLOBBER_LIST); + return retcode; +} - __attribute__((always_inline)) inline long syscall(long __number, long __arg1, - long __arg2, long __arg3, - long __arg4) noexcept { - long retcode; - register long r10 __asm__("r10") = __arg4; - LIBC_INLINE_ASM("syscall" - : "=a"(retcode) - : "a"(__number), "D"(__arg1), "S"(__arg2), "d"(__arg3), - "r"(r10) - : SYSCALL_CLOBBER_LIST); - return retcode; - } +__attribute__((always_inline)) inline long +syscall(long __number, long __arg1, long __arg2, long __arg3, long __arg4) { + long retcode; + register long r10 __asm__("r10") = __arg4; + LIBC_INLINE_ASM("syscall" + : "=a"(retcode) + : "a"(__number), "D"(__arg1), "S"(__arg2), "d"(__arg3), + "r"(r10) + : SYSCALL_CLOBBER_LIST); + return retcode; +} - __attribute__((always_inline)) inline long syscall( - long __number, long __arg1, long __arg2, long __arg3, long __arg4, - long __arg5) noexcept { - long retcode; - register long r10 __asm__("r10") = __arg4; - register long r8 __asm__("r8") = __arg5; - LIBC_INLINE_ASM("syscall" - : "=a"(retcode) - : "a"(__number), "D"(__arg1), "S"(__arg2), "d"(__arg3), - "r"(r10), "r"(r8) - : SYSCALL_CLOBBER_LIST); - return retcode; - } +__attribute__((always_inline)) inline long syscall(long __number, long __arg1, + long __arg2, long __arg3, + long __arg4, long __arg5) { + long retcode; + register long r10 __asm__("r10") = __arg4; + register long r8 __asm__("r8") = __arg5; + LIBC_INLINE_ASM("syscall" + : "=a"(retcode) + : "a"(__number), "D"(__arg1), "S"(__arg2), "d"(__arg3), + "r"(r10), "r"(r8) + : SYSCALL_CLOBBER_LIST); + return retcode; +} - __attribute__((always_inline)) inline long syscall( - long __number, long __arg1, long __arg2, long __arg3, long __arg4, - long __arg5, long __arg6) noexcept { - long retcode; - register long r10 __asm__("r10") = __arg4; - register long r8 __asm__("r8") = __arg5; - register long r9 __asm__("r9") = __arg6; - LIBC_INLINE_ASM("syscall" - : "=a"(retcode) - : "a"(__number), "D"(__arg1), "S"(__arg2), "d"(__arg3), - "r"(r10), "r"(r8), "r"(r9) - : SYSCALL_CLOBBER_LIST); - return retcode; - } +__attribute__((always_inline)) inline long syscall(long __number, long __arg1, + long __arg2, long __arg3, + long __arg4, long __arg5, + long __arg6) { + long retcode; + register long r10 __asm__("r10") = __arg4; + register long r8 __asm__("r8") = __arg5; + register long r9 __asm__("r9") = __arg6; + LIBC_INLINE_ASM("syscall" + : "=a"(retcode) + : "a"(__number), "D"(__arg1), "S"(__arg2), "d"(__arg3), + "r"(r10), "r"(r8), "r"(r9) + : SYSCALL_CLOBBER_LIST); + return retcode; +} + +template +__attribute__((always_inline)) inline long syscall(long __number, Ts... ts) { + static_assert(sizeof...(Ts) <= 6, "Too many arguments for syscall"); + return syscall(__number, (long)ts...); +} - template - __attribute__((always_inline)) inline long syscall(long __number, - Ts... ts) noexcept { - static_assert(sizeof...(Ts) <= 6, "Too many arguments for syscall"); - return syscall(__number, static_cast(ts...)); - } #undef SYSCALL_CLOBBER_LIST diff --git a/libc/src/signal/linux/sigaction.cpp b/libc/src/signal/linux/sigaction.cpp index 8ecda77d6f8d3..602fc71bf390c 100644 --- a/libc/src/signal/linux/sigaction.cpp +++ b/libc/src/signal/linux/sigaction.cpp @@ -21,7 +21,7 @@ namespace __llvm_libc { extern "C" void __restore_rt(); template -static void copySigaction(T &dest, const V &source) noexcept { +static void copySigaction(T &dest, const V &source) { dest.sa_handler = source.sa_handler; dest.sa_mask = source.sa_mask; dest.sa_flags = source.sa_flags; diff --git a/libc/src/signal/linux/sigaddset.cpp b/libc/src/signal/linux/sigaddset.cpp index a7732645dea9a..bc51ef67e0b3a 100644 --- a/libc/src/signal/linux/sigaddset.cpp +++ b/libc/src/signal/linux/sigaddset.cpp @@ -15,8 +15,8 @@ namespace __llvm_libc { -LLVM_LIBC_FUNCTION(int, sigaddset, (sigset_t * set, int signum)) noexcept { - if (!set || static_cast(signum - 1) >= (8 * sizeof(sigset_t))) { +LLVM_LIBC_FUNCTION(int, sigaddset, (sigset_t * set, int signum)) { + if (!set || (unsigned)(signum - 1) >= (8 * sizeof(sigset_t))) { llvmlibc_errno = EINVAL; return -1; } diff --git a/libc/src/signal/linux/sigdelset.cpp b/libc/src/signal/linux/sigdelset.cpp index 60b84a3f9865f..f870f71560074 100644 --- a/libc/src/signal/linux/sigdelset.cpp +++ b/libc/src/signal/linux/sigdelset.cpp @@ -15,8 +15,8 @@ namespace __llvm_libc { -LLVM_LIBC_FUNCTION(int, sigdelset, (sigset_t * set, int signum)) noexcept { - if (!set || static_cast(signum - 1) >= (8 * sizeof(sigset_t))) { +LLVM_LIBC_FUNCTION(int, sigdelset, (sigset_t * set, int signum)) { + if (!set || (unsigned)(signum - 1) >= (8 * sizeof(sigset_t))) { llvmlibc_errno = EINVAL; return -1; } diff --git a/libc/src/signal/linux/sigemptyset.cpp b/libc/src/signal/linux/sigemptyset.cpp index 542e2f8635b3f..bce5fea7c963b 100644 --- a/libc/src/signal/linux/sigemptyset.cpp +++ b/libc/src/signal/linux/sigemptyset.cpp @@ -15,7 +15,7 @@ namespace __llvm_libc { -LLVM_LIBC_FUNCTION(int, sigemptyset, (sigset_t * set)) noexcept { +LLVM_LIBC_FUNCTION(int, sigemptyset, (sigset_t * set)) { if (!set) { llvmlibc_errno = EINVAL; return -1; diff --git a/libc/src/signal/linux/sigfillset.cpp b/libc/src/signal/linux/sigfillset.cpp index 1377263c7b17b..1b908f1992640 100644 --- a/libc/src/signal/linux/sigfillset.cpp +++ b/libc/src/signal/linux/sigfillset.cpp @@ -15,7 +15,7 @@ namespace __llvm_libc { -LLVM_LIBC_FUNCTION(int, sigfillset, (sigset_t * set)) noexcept { +LLVM_LIBC_FUNCTION(int, sigfillset, (sigset_t * set)) { if (!set) { llvmlibc_errno = EINVAL; return -1; diff --git a/libc/src/signal/linux/signal.h b/libc/src/signal/linux/signal.h index d9687952713bd..89b471b4079e4 100644 --- a/libc/src/signal/linux/signal.h +++ b/libc/src/signal/linux/signal.h @@ -35,7 +35,7 @@ struct Sigset { constexpr static Sigset all = Sigset::fullset(); -static inline int block_all_signals(Sigset &set) noexcept { +static inline int block_all_signals(Sigset &set) { sigset_t nativeSigset = all; sigset_t oldSet = set; int ret = __llvm_libc::syscall(SYS_rt_sigprocmask, SIG_BLOCK, &nativeSigset, @@ -44,7 +44,7 @@ static inline int block_all_signals(Sigset &set) noexcept { return ret; } -static inline int restore_signals(const Sigset &set) noexcept { +static inline int restore_signals(const Sigset &set) { sigset_t nativeSigset = set; return __llvm_libc::syscall(SYS_rt_sigprocmask, SIG_SETMASK, &nativeSigset, nullptr, sizeof(sigset_t)); diff --git a/libc/src/signal/raise.h b/libc/src/signal/raise.h index d477fca998090..00fd4c8fbda99 100644 --- a/libc/src/signal/raise.h +++ b/libc/src/signal/raise.h @@ -13,7 +13,7 @@ namespace __llvm_libc { -int raise(int sig) noexcept; +int raise(int sig); } // namespace __llvm_libc diff --git a/libc/src/signal/sigaction.h b/libc/src/signal/sigaction.h index c72902cd79946..105ab1b250cc6 100644 --- a/libc/src/signal/sigaction.h +++ b/libc/src/signal/sigaction.h @@ -15,7 +15,7 @@ namespace __llvm_libc { int sigaction(int signal, const struct __sigaction *__restrict libc_new, - struct __sigaction *__restrict libc_old) noexcept; + struct __sigaction *__restrict libc_old); } // namespace __llvm_libc diff --git a/libc/src/signal/sigaddset.h b/libc/src/signal/sigaddset.h index 7eb76ccc92439..40cec9f00c647 100644 --- a/libc/src/signal/sigaddset.h +++ b/libc/src/signal/sigaddset.h @@ -13,7 +13,7 @@ namespace __llvm_libc { -int sigaddset(sigset_t *set, int signum) noexcept; +int sigaddset(sigset_t *set, int signum); } // namespace __llvm_libc diff --git a/libc/src/signal/sigdelset.h b/libc/src/signal/sigdelset.h index c055d34010f35..a005d9c0aa138 100644 --- a/libc/src/signal/sigdelset.h +++ b/libc/src/signal/sigdelset.h @@ -13,7 +13,7 @@ namespace __llvm_libc { -int sigdelset(sigset_t *set, int signum) noexcept; +int sigdelset(sigset_t *set, int signum); } // namespace __llvm_libc diff --git a/libc/src/signal/sigemptyset.h b/libc/src/signal/sigemptyset.h index 7d418a06ade7e..0651c7302f992 100644 --- a/libc/src/signal/sigemptyset.h +++ b/libc/src/signal/sigemptyset.h @@ -13,7 +13,7 @@ namespace __llvm_libc { -int sigemptyset(sigset_t *set) noexcept; +int sigemptyset(sigset_t *set); } // namespace __llvm_libc diff --git a/libc/src/signal/sigfillset.h b/libc/src/signal/sigfillset.h index af60fb86694eb..ed3612ce4ed5a 100644 --- a/libc/src/signal/sigfillset.h +++ b/libc/src/signal/sigfillset.h @@ -13,7 +13,7 @@ namespace __llvm_libc { -int sigfillset(sigset_t *set) noexcept; +int sigfillset(sigset_t *set); } // namespace __llvm_libc diff --git a/libc/src/signal/signal.h b/libc/src/signal/signal.h index bd10c6d61de4f..4315497e2cf8c 100644 --- a/libc/src/signal/signal.h +++ b/libc/src/signal/signal.h @@ -15,7 +15,7 @@ namespace __llvm_libc { using sighandler_t = __sighandler_t; -sighandler_t signal(int signum, sighandler_t handler) noexcept; +sighandler_t signal(int signum, sighandler_t handler); } // namespace __llvm_libc diff --git a/libc/src/signal/sigprocmask.h b/libc/src/signal/sigprocmask.h index 41a79f6a5706c..353c0c84b38a1 100644 --- a/libc/src/signal/sigprocmask.h +++ b/libc/src/signal/sigprocmask.h @@ -14,7 +14,7 @@ namespace __llvm_libc { int sigprocmask(int how, const sigset_t *__restrict set, - sigset_t *__restrict oldset) noexcept; + sigset_t *__restrict oldset); } // namespace __llvm_libc diff --git a/libc/src/stdio/FILE.h b/libc/src/stdio/FILE.h index 7051838af4945..54bc9b2c87311 100644 --- a/libc/src/stdio/FILE.h +++ b/libc/src/stdio/FILE.h @@ -19,7 +19,7 @@ struct FILE { using write_function_t = size_t(FILE *, const char *, size_t); - write_function_t *write noexcept; + write_function_t *write; }; } // namespace __llvm_libc diff --git a/libc/src/stdio/fwrite.cpp b/libc/src/stdio/fwrite.cpp index d54aad2ec0934..80cf50ca376e4 100644 --- a/libc/src/stdio/fwrite.cpp +++ b/libc/src/stdio/fwrite.cpp @@ -14,13 +14,13 @@ namespace __llvm_libc { size_t fwrite_unlocked(const void *__restrict ptr, size_t size, size_t nmeb, - __llvm_libc::FILE *__restrict stream) noexcept { + __llvm_libc::FILE *__restrict stream) { return stream->write(stream, reinterpret_cast(ptr), size * nmeb); } size_t fwrite(const void *__restrict ptr, size_t size, size_t nmeb, - __llvm_libc::FILE *__restrict stream) noexcept { + __llvm_libc::FILE *__restrict stream) { __llvm_libc::mtx_lock(&stream->lock); size_t written = fwrite_unlocked(ptr, size, nmeb, stream); __llvm_libc::mtx_unlock(&stream->lock); diff --git a/libc/src/stdio/fwrite.h b/libc/src/stdio/fwrite.h index 7dd03da033434..8a71ca105bb08 100644 --- a/libc/src/stdio/fwrite.h +++ b/libc/src/stdio/fwrite.h @@ -15,7 +15,7 @@ namespace __llvm_libc { size_t fwrite(const void *__restrict ptr, size_t size, size_t nmeb, - __llvm_libc::FILE *__restrict stream) noexcept; + __llvm_libc::FILE *__restrict stream); } // namespace __llvm_libc diff --git a/libc/src/stdlib/abort.cpp b/libc/src/stdlib/abort.cpp index 0dfab6ebbeded..1da81611273de 100644 --- a/libc/src/stdlib/abort.cpp +++ b/libc/src/stdlib/abort.cpp @@ -14,7 +14,7 @@ namespace __llvm_libc { -[[noreturn]] LLVM_LIBC_FUNCTION(void, abort, ()) { +LLVM_LIBC_FUNCTION(void, abort, ()) { // TODO: When sigprocmask and sigaction land: // Unblock SIGABRT, raise it, if it was ignored or the handler returned, // change its action to SIG_DFL, raise it again. diff --git a/libc/src/stdlib/abs.h b/libc/src/stdlib/abs.h index d7fc1fd91f522..42ef7f885ed65 100644 --- a/libc/src/stdlib/abs.h +++ b/libc/src/stdlib/abs.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -int abs(int n) noexcept; +int abs(int n); } // namespace __llvm_libc diff --git a/libc/src/stdlib/labs.h b/libc/src/stdlib/labs.h index 5d52ca9701de6..0f0ea99dc22a7 100644 --- a/libc/src/stdlib/labs.h +++ b/libc/src/stdlib/labs.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -long labs(long n) noexcept; +long labs(long n); } // namespace __llvm_libc diff --git a/libc/src/stdlib/linux/_Exit.cpp b/libc/src/stdlib/linux/_Exit.cpp index 89b223b35a6ba..7fdd60ffe9bc6 100644 --- a/libc/src/stdlib/linux/_Exit.cpp +++ b/libc/src/stdlib/linux/_Exit.cpp @@ -14,7 +14,7 @@ namespace __llvm_libc { -[[noreturn]] LLVM_LIBC_FUNCTION(void, _Exit, (int status)) { +LLVM_LIBC_FUNCTION(void, _Exit, (int status)) { for (;;) { __llvm_libc::syscall(SYS_exit_group, status); __llvm_libc::syscall(SYS_exit, status); diff --git a/libc/src/stdlib/llabs.h b/libc/src/stdlib/llabs.h index fcbe64ca45682..f173431a14f15 100644 --- a/libc/src/stdlib/llabs.h +++ b/libc/src/stdlib/llabs.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -long long llabs(long long n) noexcept; +long long llabs(long long n); } // namespace __llvm_libc From a6bc6686b3cad065b59ccd4a604076e18200d804 Mon Sep 17 00:00:00 2001 From: Alfonso Gregory <83477269+gAlfonso-bit@users.noreply.github.com> Date: Mon, 26 Jul 2021 13:31:31 -0400 Subject: [PATCH 12/17] Revert "Done" This reverts commit 690324b85eb3af5f5c114433b6a69a54e2fa7523. --- libc/src/sys/mman/mmap.h | 3 +- libc/src/sys/mman/munmap.h | 2 +- libc/src/threads/call_once.h | 2 +- libc/src/threads/linux/thrd_create.cpp | 2 +- .../linux/x86_64/thread_start_args.h.in | 2 +- libc/src/threads/mtx_init.h | 2 +- libc/src/threads/mtx_lock.h | 2 +- libc/src/threads/mtx_unlock.h | 2 +- libc/src/threads/thrd_create.h | 2 +- libc/src/threads/thrd_join.h | 2 +- libc/src/time/asctime.h | 2 +- libc/src/time/asctime_r.h | 2 +- libc/src/time/gmtime.h | 2 +- libc/src/time/gmtime_r.h | 2 +- libc/src/time/mktime.h | 2 +- libc/src/time/time_utils.h | 8 +-- libc/src/unistd/write.h | 2 +- libc/utils/CPP/Array.h | 2 +- libc/utils/CPP/ArrayRef.h | 26 ++++----- libc/utils/FPUtil/BasicOperations.h | 6 +- .../FPUtil/DivisionAndRemainderOperations.h | 2 +- libc/utils/FPUtil/FPBits.h | 40 ++++++------- libc/utils/FPUtil/Hypot.h | 8 +-- libc/utils/FPUtil/LongDoubleBitsX86.h | 40 ++++++------- libc/utils/FPUtil/ManipulationFunctions.h | 14 ++--- libc/utils/FPUtil/NearestIntegerOperations.h | 16 +++--- libc/utils/FPUtil/NextAfterLongDoubleX86.h | 2 +- libc/utils/FPUtil/NormalFloat.h | 12 ++-- libc/utils/FPUtil/PolyEval.h | 12 ++-- libc/utils/FPUtil/Sqrt.h | 15 ++--- libc/utils/FPUtil/SqrtLongDoubleX86.h | 5 +- llvm/include/llvm/Support/Compiler.h | 4 +- llvm/lib/TableGen/Error.cpp | 57 ++++++++----------- 33 files changed, 136 insertions(+), 166 deletions(-) diff --git a/libc/src/sys/mman/mmap.h b/libc/src/sys/mman/mmap.h index 1cae4a7983d9d..c7aa404f65857 100644 --- a/libc/src/sys/mman/mmap.h +++ b/libc/src/sys/mman/mmap.h @@ -13,8 +13,7 @@ namespace __llvm_libc { -void *mmap(void *addr, size_t size, int prot, int flags, int fd, - off_t offset) noexcept; +void *mmap(void *addr, size_t size, int prot, int flags, int fd, off_t offset); } // namespace __llvm_libc diff --git a/libc/src/sys/mman/munmap.h b/libc/src/sys/mman/munmap.h index 72cd7508be9d0..ba272dc45e15f 100644 --- a/libc/src/sys/mman/munmap.h +++ b/libc/src/sys/mman/munmap.h @@ -13,7 +13,7 @@ namespace __llvm_libc { -int munmap(void *addr, size_t size) noexcept; +int munmap(void *addr, size_t size); } // namespace __llvm_libc diff --git a/libc/src/threads/call_once.h b/libc/src/threads/call_once.h index a4a8363594097..f6602df68197c 100644 --- a/libc/src/threads/call_once.h +++ b/libc/src/threads/call_once.h @@ -13,7 +13,7 @@ namespace __llvm_libc { -void call_once(once_flag *flag, __call_once_func_t func) noexcept; +void call_once(once_flag *flag, __call_once_func_t func); } // namespace __llvm_libc diff --git a/libc/src/threads/linux/thrd_create.cpp b/libc/src/threads/linux/thrd_create.cpp index 449b4a4f25f98..8b68f2a48688d 100644 --- a/libc/src/threads/linux/thrd_create.cpp +++ b/libc/src/threads/linux/thrd_create.cpp @@ -30,7 +30,7 @@ struct StartArgs { void *arg; }; -static __attribute__((noinline)) void start_thread() noexcept { +static __attribute__((noinline)) void start_thread() { StartArgs *start_args = reinterpret_cast(get_start_args_addr()); __llvm_libc::syscall(SYS_exit, start_args->thread->__retval = start_args->func(start_args->arg)); diff --git a/libc/src/threads/linux/x86_64/thread_start_args.h.in b/libc/src/threads/linux/x86_64/thread_start_args.h.in index 43e04ce4d34d5..36365b98bb214 100644 --- a/libc/src/threads/linux/x86_64/thread_start_args.h.in +++ b/libc/src/threads/linux/x86_64/thread_start_args.h.in @@ -10,7 +10,7 @@ namespace __llvm_libc { -__attribute__((always_inline)) inline uintptr_t get_start_args_addr() noexcept { +__attribute__((always_inline)) inline uintptr_t get_start_args_addr() { // NOTE: For __builtin_frame_address to work reliably across compilers, // architectures and various optimization levels, the TU including this file // should be compiled with -fno-omit-frame-pointer. diff --git a/libc/src/threads/mtx_init.h b/libc/src/threads/mtx_init.h index a7302746a8ef5..7eed5ece6d5e7 100644 --- a/libc/src/threads/mtx_init.h +++ b/libc/src/threads/mtx_init.h @@ -13,7 +13,7 @@ namespace __llvm_libc { -int mtx_init(mtx_t *mutex, int type) noexcept; +int mtx_init(mtx_t *mutex, int type); } // namespace __llvm_libc diff --git a/libc/src/threads/mtx_lock.h b/libc/src/threads/mtx_lock.h index 6afd9d6da5ad4..5086f773f0fe6 100644 --- a/libc/src/threads/mtx_lock.h +++ b/libc/src/threads/mtx_lock.h @@ -13,7 +13,7 @@ namespace __llvm_libc { -int mtx_lock(mtx_t *mutex) noexcept; +int mtx_lock(mtx_t *mutex); } // namespace __llvm_libc diff --git a/libc/src/threads/mtx_unlock.h b/libc/src/threads/mtx_unlock.h index a28679993b495..55f0b4a7a6655 100644 --- a/libc/src/threads/mtx_unlock.h +++ b/libc/src/threads/mtx_unlock.h @@ -13,7 +13,7 @@ namespace __llvm_libc { -int mtx_unlock(mtx_t *mutex) noexcept; +int mtx_unlock(mtx_t *mutex); } // namespace __llvm_libc diff --git a/libc/src/threads/thrd_create.h b/libc/src/threads/thrd_create.h index 859d2cbec7eb0..d2bb7dfad41c5 100644 --- a/libc/src/threads/thrd_create.h +++ b/libc/src/threads/thrd_create.h @@ -13,7 +13,7 @@ namespace __llvm_libc { -int thrd_create(thrd_t *thread, thrd_start_t func, void *arg) noexcept; +int thrd_create(thrd_t *thread, thrd_start_t func, void *arg); } // namespace __llvm_libc diff --git a/libc/src/threads/thrd_join.h b/libc/src/threads/thrd_join.h index fa9f6ebc0a806..fc36503dc521c 100644 --- a/libc/src/threads/thrd_join.h +++ b/libc/src/threads/thrd_join.h @@ -13,7 +13,7 @@ namespace __llvm_libc { -int thrd_join(thrd_t *thread, int *retval) noexcept; +int thrd_join(thrd_t *thread, int *retval); } // namespace __llvm_libc diff --git a/libc/src/time/asctime.h b/libc/src/time/asctime.h index c0c6bfa258794..9d75b40148afd 100644 --- a/libc/src/time/asctime.h +++ b/libc/src/time/asctime.h @@ -13,7 +13,7 @@ namespace __llvm_libc { -char *asctime(const struct tm *timeptr) noexcept; +char *asctime(const struct tm *timeptr); } // namespace __llvm_libc diff --git a/libc/src/time/asctime_r.h b/libc/src/time/asctime_r.h index 56c75826bf4bc..8521e782a509d 100644 --- a/libc/src/time/asctime_r.h +++ b/libc/src/time/asctime_r.h @@ -13,7 +13,7 @@ namespace __llvm_libc { -char *asctime_r(const struct tm *timeptr, char *buffer) noexcept; +char *asctime_r(const struct tm *timeptr, char *buffer); } // namespace __llvm_libc diff --git a/libc/src/time/gmtime.h b/libc/src/time/gmtime.h index 7203c743fc02b..8891a8c917ac5 100644 --- a/libc/src/time/gmtime.h +++ b/libc/src/time/gmtime.h @@ -13,7 +13,7 @@ namespace __llvm_libc { -struct tm *gmtime(const time_t *timer) noexcept; +struct tm *gmtime(const time_t *timer); } // namespace __llvm_libc diff --git a/libc/src/time/gmtime_r.h b/libc/src/time/gmtime_r.h index 9476b6d82353d..8e9fc94b5ceed 100644 --- a/libc/src/time/gmtime_r.h +++ b/libc/src/time/gmtime_r.h @@ -13,7 +13,7 @@ namespace __llvm_libc { -struct tm *gmtime_r(const time_t *timer, struct tm *result) noexcept; +struct tm *gmtime_r(const time_t *timer, struct tm *result); } // namespace __llvm_libc diff --git a/libc/src/time/mktime.h b/libc/src/time/mktime.h index b153cd24937a6..ecd604c12fc35 100644 --- a/libc/src/time/mktime.h +++ b/libc/src/time/mktime.h @@ -14,7 +14,7 @@ namespace __llvm_libc { -time_t mktime(struct tm *t1) noexcept; +time_t mktime(struct tm *t1); } // namespace __llvm_libc diff --git a/libc/src/time/time_utils.h b/libc/src/time/time_utils.h index 327a6538a170c..c1c7735f49060 100644 --- a/libc/src/time/time_utils.h +++ b/libc/src/time/time_utils.h @@ -68,15 +68,15 @@ struct TimeConstants { extern int64_t UpdateFromSeconds(int64_t total_seconds, struct tm *tm); // POSIX.1-2017 requires this. -static inline time_t OutOfRange() noexcept { +static inline time_t OutOfRange() { llvmlibc_errno = EOVERFLOW; return static_cast(-1); } -static inline void InvalidValue() noexcept { llvmlibc_errno = EINVAL; } +static inline void InvalidValue() { llvmlibc_errno = EINVAL; } static inline char *asctime(const struct tm *timeptr, char *buffer, - size_t bufferLength) noexcept { + size_t bufferLength) { if (timeptr == nullptr || buffer == nullptr) { InvalidValue(); return nullptr; @@ -114,7 +114,7 @@ static inline char *asctime(const struct tm *timeptr, char *buffer, } static inline struct tm *gmtime_internal(const time_t *timer, - struct tm *result) noexcept { + struct tm *result) { int64_t seconds = *timer; // Update the tm structure's year, month, day, etc. from seconds. if (UpdateFromSeconds(seconds, result) < 0) { diff --git a/libc/src/unistd/write.h b/libc/src/unistd/write.h index 0ad6981645604..d69c10a66f0f1 100644 --- a/libc/src/unistd/write.h +++ b/libc/src/unistd/write.h @@ -14,7 +14,7 @@ namespace __llvm_libc { -ssize_t write(int fd, const void *buf, size_t count) noexcept; +ssize_t write(int fd, const void *buf, size_t count); } // namespace __llvm_libc diff --git a/libc/utils/CPP/Array.h b/libc/utils/CPP/Array.h index 9085ebd66f054..c774a9f793d8c 100644 --- a/libc/utils/CPP/Array.h +++ b/libc/utils/CPP/Array.h @@ -43,7 +43,7 @@ template struct Array { constexpr const_iterator begin() const { return Data; } constexpr iterator end() { return Data + N; } - const_iterator end() const noexcept { return Data + N; } + const_iterator end() const { return Data + N; } }; } // namespace cpp diff --git a/libc/utils/CPP/ArrayRef.h b/libc/utils/CPP/ArrayRef.h index 9df6b7d7e2c4e..cad7db9d3b663 100644 --- a/libc/utils/CPP/ArrayRef.h +++ b/libc/utils/CPP/ArrayRef.h @@ -50,46 +50,44 @@ template class ArrayRefBase { template constexpr ArrayRefBase(QualifiedT (&Arr)[N]) : Data(Arr), Length(N) {} - QualifiedT *data() const noexcept { return Data; } - size_t size() const noexcept { return Length; } + QualifiedT *data() const { return Data; } + size_t size() const { return Length; } - auto begin() const noexcept { return data(); } - auto end() const noexcept { return data() + size(); } + auto begin() const { return data(); } + auto end() const { return data() + size(); } - bool empty() const noexcept { return size() == 0; } + bool empty() const { return size() == 0; } auto operator[](size_t Index) const { return data()[Index]; } // slice(n, m) - Chop off the first N elements of the array, and keep M // elements in the array. - auto slice(size_t N, size_t M) const noexcept { - return ArrayRefBase(data() + N, M); - } + auto slice(size_t N, size_t M) const { return ArrayRefBase(data() + N, M); } // slice(n) - Chop off the first N elements of the array. - auto slice(size_t N) const noexcept { return slice(N, size() - N); } + auto slice(size_t N) const { return slice(N, size() - N); } // Drop the first \p N elements of the array. - auto drop_front(size_t N = 1) const noexcept { return slice(N, size() - N); } + auto drop_front(size_t N = 1) const { return slice(N, size() - N); } // Drop the last \p N elements of the array. - auto drop_back(size_t N = 1) const noexcept { return slice(0, size() - N); } + auto drop_back(size_t N = 1) const { return slice(0, size() - N); } // Return a copy of *this with only the first \p N elements. - auto take_front(size_t N = 1) const noexcept { + auto take_front(size_t N = 1) const { if (N >= size()) return *this; return drop_back(size() - N); } // Return a copy of *this with only the last \p N elements. - auto take_back(size_t N = 1) const noexcept { + auto take_back(size_t N = 1) const { if (N >= size()) return *this; return drop_front(size() - N); } // equals - Check for element-wise equality. - bool equals(ArrayRefBase RHS) const noexcept { + bool equals(ArrayRefBase RHS) const { if (Length != RHS.Length) return false; auto First1 = begin(); diff --git a/libc/utils/FPUtil/BasicOperations.h b/libc/utils/FPUtil/BasicOperations.h index 877119dea5e69..43ccd12fdb70e 100644 --- a/libc/utils/FPUtil/BasicOperations.h +++ b/libc/utils/FPUtil/BasicOperations.h @@ -18,7 +18,7 @@ namespace fputil { template ::Value, int> = 0> -static inline T abs(T x) noexcept { +static inline T abs(T x) { FPBits bits(x); bits.setSign(0); return T(bits); @@ -26,7 +26,7 @@ static inline T abs(T x) noexcept { template ::Value, int> = 0> -static inline T fmin(T x, T y) noexcept { +static inline T fmin(T x, T y) { FPBits bitx(x), bity(y); if (bitx.isNaN()) { @@ -45,7 +45,7 @@ static inline T fmin(T x, T y) noexcept { template ::Value, int> = 0> -static inline T fmax(T x, T y) noexcept { +static inline T fmax(T x, T y) { FPBits bitx(x), bity(y); if (bitx.isNaN()) { diff --git a/libc/utils/FPUtil/DivisionAndRemainderOperations.h b/libc/utils/FPUtil/DivisionAndRemainderOperations.h index 9493b408b547a..d23a8daabbe63 100644 --- a/libc/utils/FPUtil/DivisionAndRemainderOperations.h +++ b/libc/utils/FPUtil/DivisionAndRemainderOperations.h @@ -24,7 +24,7 @@ static constexpr int quotientLSBBits = 3; // to evaluate the quotient and remainder. template ::Value, int> = 0> -static inline T remquo(T x, T y, int &q) noexcept { +static inline T remquo(T x, T y, int &q) { FPBits xbits(x), ybits(y); if (xbits.isNaN()) return x; diff --git a/libc/utils/FPUtil/FPBits.h b/libc/utils/FPUtil/FPBits.h index fca93cfc04081..9ee870dc9983d 100644 --- a/libc/utils/FPUtil/FPBits.h +++ b/libc/utils/FPUtil/FPBits.h @@ -48,34 +48,32 @@ template union FPBits { UIntType bits; - void setMantissa(UIntType mantVal) noexcept { + void setMantissa(UIntType mantVal) { mantVal &= (FloatProp::mantissaMask); bits &= ~(FloatProp::mantissaMask); bits |= mantVal; } - UIntType getMantissa() const noexcept { - return bits & FloatProp::mantissaMask; - } + UIntType getMantissa() const { return bits & FloatProp::mantissaMask; } - void setUnbiasedExponent(UIntType expVal) noexcept { + void setUnbiasedExponent(UIntType expVal) { expVal = (expVal << (FloatProp::mantissaWidth)) & FloatProp::exponentMask; bits &= ~(FloatProp::exponentMask); bits |= expVal; } - uint16_t getUnbiasedExponent() const noexcept { + uint16_t getUnbiasedExponent() const { return uint16_t((bits & FloatProp::exponentMask) >> (FloatProp::mantissaWidth)); } - void setSign(bool signVal) noexcept { + void setSign(bool signVal) { bits &= ~(FloatProp::signMask); UIntType sign = UIntType(signVal) << (FloatProp::bitWidth - 1); bits |= sign; } - bool getSign() const noexcept { + bool getSign() const { return ((bits & FloatProp::signMask) >> (FloatProp::bitWidth - 1)); } T val; @@ -108,47 +106,43 @@ template union FPBits { explicit operator T() { return val; } - UIntType uintval() const noexcept { return bits; } + UIntType uintval() const { return bits; } - int getExponent() const noexcept { - return int(getUnbiasedExponent()) - exponentBias; - } + int getExponent() const { return int(getUnbiasedExponent()) - exponentBias; } - bool isZero() const noexcept { + bool isZero() const { return getMantissa() == 0 && getUnbiasedExponent() == 0; } - bool isInf() const noexcept { + bool isInf() const { return getMantissa() == 0 && getUnbiasedExponent() == maxExponent; } - bool isNaN() const noexcept { + bool isNaN() const { return getUnbiasedExponent() == maxExponent && getMantissa() != 0; } - bool isInfOrNaN() const noexcept { - return getUnbiasedExponent() == maxExponent; - } + bool isInfOrNaN() const { return getUnbiasedExponent() == maxExponent; } - static FPBits zero() noexcept { return FPBits(); } + static FPBits zero() { return FPBits(); } - static FPBits negZero() noexcept { + static FPBits negZero() { return FPBits(UIntType(1) << (sizeof(UIntType) * 8 - 1)); } - static FPBits inf() noexcept { + static FPBits inf() { FPBits bits; bits.setUnbiasedExponent(maxExponent); return bits; } - static FPBits negInf() noexcept { + static FPBits negInf() { FPBits bits = inf(); bits.setSign(1); return bits; } - static T buildNaN(UIntType v) noexcept { + static T buildNaN(UIntType v) { FPBits bits = inf(); bits.setMantissa(v); return T(bits); diff --git a/libc/utils/FPUtil/Hypot.h b/libc/utils/FPUtil/Hypot.h index a3983dafc6ce8..8d108a74761de 100644 --- a/libc/utils/FPUtil/Hypot.h +++ b/libc/utils/FPUtil/Hypot.h @@ -18,10 +18,10 @@ namespace fputil { namespace internal { -template static inline T findLeadingOne(T mant, int &shift_length) noexcept; +template static inline T findLeadingOne(T mant, int &shift_length); template <> -inline uint32_t findLeadingOne(uint32_t mant, int &shift_length) noexcept { +inline uint32_t findLeadingOne(uint32_t mant, int &shift_length) { shift_length = 0; constexpr int nsteps = 5; constexpr uint32_t bounds[nsteps] = {1 << 16, 1 << 8, 1 << 4, 1 << 2, 1 << 1}; @@ -36,7 +36,7 @@ inline uint32_t findLeadingOne(uint32_t mant, int &shift_length) noexc } template <> -inline uint64_t findLeadingOne(uint64_t mant, int &shift_length) noexcept { +inline uint64_t findLeadingOne(uint64_t mant, int &shift_length) { shift_length = 0; constexpr int nsteps = 6; constexpr uint64_t bounds[nsteps] = {1ULL << 32, 1ULL << 16, 1ULL << 8, @@ -117,7 +117,7 @@ template <> struct DoubleLength { using Type = __uint128_t; }; // template ::Value, int> = 0> -static inline T hypot(T x, T y) noexcept { +static inline T hypot(T x, T y) { using FPBits_t = FPBits; using UIntType = typename FPBits::UIntType; using DUIntType = typename DoubleLength::Type; diff --git a/libc/utils/FPUtil/LongDoubleBitsX86.h b/libc/utils/FPUtil/LongDoubleBitsX86.h index 04c155b48a41f..ce7fdb1b0fa8a 100644 --- a/libc/utils/FPUtil/LongDoubleBitsX86.h +++ b/libc/utils/FPUtil/LongDoubleBitsX86.h @@ -43,45 +43,43 @@ template <> union FPBits { UIntType bits; - void setMantissa(UIntType mantVal) noexcept { + void setMantissa(UIntType mantVal) { mantVal &= (FloatProp::mantissaMask); bits &= ~(FloatProp::mantissaMask); bits |= mantVal; } - UIntType getMantissa() const noexcept { - return bits & FloatProp::mantissaMask; - } + UIntType getMantissa() const { return bits & FloatProp::mantissaMask; } - void setUnbiasedExponent(UIntType expVal) noexcept { + void setUnbiasedExponent(UIntType expVal) { expVal = (expVal << (FloatProp::bitWidth - 1 - FloatProp::exponentWidth)) & FloatProp::exponentMask; bits &= ~(FloatProp::exponentMask); bits |= expVal; } - uint16_t getUnbiasedExponent() const noexcept { + uint16_t getUnbiasedExponent() const { return uint16_t((bits & FloatProp::exponentMask) >> (FloatProp::bitWidth - 1 - FloatProp::exponentWidth)); } - void setImplicitBit(bool implicitVal) noexcept { + void setImplicitBit(bool implicitVal) { bits &= ~(UIntType(1) << FloatProp::mantissaWidth); bits |= (UIntType(implicitVal) << FloatProp::mantissaWidth); } - bool getImplicitBit() const noexcept { + bool getImplicitBit() const { return ((bits & (UIntType(1) << FloatProp::mantissaWidth)) >> FloatProp::mantissaWidth); } - void setSign(bool signVal) noexcept { + void setSign(bool signVal) { bits &= ~(FloatProp::signMask); UIntType sign1 = UIntType(signVal) << (FloatProp::bitWidth - 1); bits |= sign1; } - bool getSign() const noexcept { + bool getSign() const { return ((bits & FloatProp::signMask) >> (FloatProp::bitWidth - 1)); } @@ -108,23 +106,23 @@ template <> union FPBits { return bits & mask; } - int getExponent() const noexcept { + int getExponent() const { if (getUnbiasedExponent() == 0) return int(1) - exponentBias; return int(getUnbiasedExponent()) - exponentBias; } - bool isZero() const noexcept { + bool isZero() const { return getUnbiasedExponent() == 0 && getMantissa() == 0 && getImplicitBit() == 0; } - bool isInf() const noexcept { + bool isInf() const { return getUnbiasedExponent() == maxExponent && getMantissa() == 0 && getImplicitBit() == 1; } - bool isNaN() const noexcept { + bool isNaN() const { if (getUnbiasedExponent() == maxExponent) { return (getImplicitBit() == 0) || getMantissa() != 0; } else if (getUnbiasedExponent() != 0) { @@ -133,31 +131,29 @@ template <> union FPBits { return false; } - bool isInfOrNaN() const noexcept { + bool isInfOrNaN() const { return (getUnbiasedExponent() == maxExponent) || (getUnbiasedExponent() != 0 && getImplicitBit() == 0); } // Methods below this are used by tests. - static FPBits zero() noexcept { - return FPBits(0.0l); - } + static FPBits zero() { return FPBits(0.0l); } - static FPBits negZero() noexcept { + static FPBits negZero() { FPBits bits(0.0l); bits.setSign(1); return bits; } - static FPBits inf() noexcept { + static FPBits inf() { FPBits bits(0.0l); bits.setUnbiasedExponent(maxExponent); bits.setImplicitBit(1); return bits; } - static FPBits negInf() noexcept { + static FPBits negInf() { FPBits bits(0.0l); bits.setUnbiasedExponent(maxExponent); bits.setImplicitBit(1); @@ -165,7 +161,7 @@ template <> union FPBits { return bits; } - static long double buildNaN(UIntType v) noexcept { + static long double buildNaN(UIntType v) { FPBits bits(0.0l); bits.setUnbiasedExponent(maxExponent); bits.setImplicitBit(1); diff --git a/libc/utils/FPUtil/ManipulationFunctions.h b/libc/utils/FPUtil/ManipulationFunctions.h index ee06166c46b1a..545e5f0f24288 100644 --- a/libc/utils/FPUtil/ManipulationFunctions.h +++ b/libc/utils/FPUtil/ManipulationFunctions.h @@ -24,7 +24,7 @@ namespace fputil { template ::Value, int> = 0> -static inline T frexp(T x, int &exp) noexcept { +static inline T frexp(T x, int &exp) { FPBits bits(x); if (bits.isInfOrNaN()) return x; @@ -41,7 +41,7 @@ static inline T frexp(T x, int &exp) noexcept { template ::Value, int> = 0> -static inline T modf(T x, T &iptr) noexcept { +static inline T modf(T x, T &iptr) { FPBits bits(x); if (bits.isZero() || bits.isNaN()) { iptr = x; @@ -63,7 +63,7 @@ static inline T modf(T x, T &iptr) noexcept { template ::Value, int> = 0> -static inline T copysign(T x, T y) noexcept { +static inline T copysign(T x, T y) { FPBits xbits(x); xbits.setSign(FPBits(y).getSign()); return T(xbits); @@ -71,7 +71,7 @@ static inline T copysign(T x, T y) noexcept { template ::Value, int> = 0> -static inline int ilogb(T x) noexcept { +static inline int ilogb(T x) { // TODO: Raise appropriate floating point exceptions and set errno to the // an appropriate error value wherever relevant. FPBits bits(x); @@ -100,7 +100,7 @@ static inline int ilogb(T x) noexcept { template ::Value, int> = 0> -static inline T logb(T x) noexcept { +static inline T logb(T x) { FPBits bits(x); if (bits.isZero()) { // TODO(Floating point exception): Raise div-by-zero exception. @@ -119,7 +119,7 @@ static inline T logb(T x) noexcept { template ::Value, int> = 0> -static inline T ldexp(T x, int exp) noexcept { +static inline T ldexp(T x, int exp) { FPBits bits(x); if (bits.isZero() || bits.isInfOrNaN() || exp == 0) return x; @@ -146,7 +146,7 @@ static inline T ldexp(T x, int exp) noexcept { template ::Value, int> = 0> -static inline T nextafter(T from, T to) noexcept { +static inline T nextafter(T from, T to) { FPBits fromBits(from); if (fromBits.isNaN()) return from; diff --git a/libc/utils/FPUtil/NearestIntegerOperations.h b/libc/utils/FPUtil/NearestIntegerOperations.h index cc0b5142197ba..8dc4e23ce75c1 100644 --- a/libc/utils/FPUtil/NearestIntegerOperations.h +++ b/libc/utils/FPUtil/NearestIntegerOperations.h @@ -24,7 +24,7 @@ namespace fputil { template ::Value, int> = 0> -static inline T trunc(T x) noexcept { +static inline T trunc(T x) { FPBits bits(x); // If x is infinity or NaN, return it. @@ -56,7 +56,7 @@ static inline T trunc(T x) noexcept { template ::Value, int> = 0> -static inline T ceil(T x) noexcept { +static inline T ceil(T x) { FPBits bits(x); // If x is infinity NaN or zero, return it. @@ -95,7 +95,7 @@ static inline T ceil(T x) noexcept { template ::Value, int> = 0> -static inline T floor(T x) noexcept { +static inline T floor(T x) { FPBits bits(x); if (bits.getSign()) { return -ceil(-x); @@ -106,7 +106,7 @@ static inline T floor(T x) noexcept { template ::Value, int> = 0> -static inline T round(T x) noexcept { +static inline T round(T x) { using UIntType = typename FPBits::UIntType; FPBits bits(x); @@ -158,7 +158,7 @@ static inline T round(T x) noexcept { template ::Value, int> = 0> -static inline T roundUsingCurrentRoundingMode(T x) noexcept { +static inline T roundUsingCurrentRoundingMode(T x) { using UIntType = typename FPBits::UIntType; FPBits bits(x); @@ -240,7 +240,7 @@ template ::Value && cpp::IsIntegral::Value, int> = 0> -static inline I roundedFloatToSignedInteger(F x) noexcept { +static inline I roundedFloatToSignedInteger(F x) { constexpr I IntegerMin = (I(1) << (sizeof(I) * 8 - 1)); constexpr I IntegerMax = -(IntegerMin + 1); FPBits bits(x); @@ -284,7 +284,7 @@ template ::Value && cpp::IsIntegral::Value, int> = 0> -static inline I roundToSignedInteger(F x) noexcept { +static inline I roundToSignedInteger(F x) { return internal::roundedFloatToSignedInteger(round(x)); } @@ -292,7 +292,7 @@ template ::Value && cpp::IsIntegral::Value, int> = 0> -static inline I roundToSignedIntegerUsingCurrentRoundingMode(F x) noexcept { +static inline I roundToSignedIntegerUsingCurrentRoundingMode(F x) { return internal::roundedFloatToSignedInteger( roundUsingCurrentRoundingMode(x)); } diff --git a/libc/utils/FPUtil/NextAfterLongDoubleX86.h b/libc/utils/FPUtil/NextAfterLongDoubleX86.h index ea91c02140ffa..80ca9ad084cb2 100644 --- a/libc/utils/FPUtil/NextAfterLongDoubleX86.h +++ b/libc/utils/FPUtil/NextAfterLongDoubleX86.h @@ -16,7 +16,7 @@ namespace __llvm_libc { namespace fputil { -static inline long double nextafter(long double from, long double to) noexcept { +static inline long double nextafter(long double from, long double to) { using FPBits = FPBits; FPBits fromBits(from); if (fromBits.isNaN()) diff --git a/libc/utils/FPUtil/NormalFloat.h b/libc/utils/FPUtil/NormalFloat.h index 024d3e6f8f0d2..2d50e88db9167 100644 --- a/libc/utils/FPUtil/NormalFloat.h +++ b/libc/utils/FPUtil/NormalFloat.h @@ -45,7 +45,7 @@ template struct NormalFloat { bool sign; NormalFloat(int32_t e, UIntType m, bool s) - : exponent(e), mantissa(m), sign(s) noexcept { + : exponent(e), mantissa(m), sign(s) { if (mantissa >= one) return; @@ -61,7 +61,7 @@ template struct NormalFloat { // Compares this normalized number with another normalized number. // Returns -1 is this number is less than |other|, 0 if this number is equal // to |other|, and 1 if this number is greater than |other|. - int cmp(const NormalFloat &other) const noexcept { + int cmp(const NormalFloat &other) const { if (sign != other.sign) return sign ? -1 : 1; @@ -82,7 +82,7 @@ template struct NormalFloat { // Returns a new normalized floating point number which is equal in value // to this number multiplied by 2^e. That is: // new = this * 2^e - NormalFloat mul2(int e) const noexcept { + NormalFloat mul2(int e) const { NormalFloat result = *this; result.exponent += e; return result; @@ -138,7 +138,7 @@ template struct NormalFloat { } private: - void initFromBits(FPBits bits) noexcept { + void initFromBits(FPBits bits) { sign = bits.getSign(); if (bits.isInfOrNaN() || bits.isZero()) { @@ -160,7 +160,7 @@ template struct NormalFloat { } } - unsigned evaluateNormalizationShift(UIntType m) noexcept { + unsigned evaluateNormalizationShift(UIntType m) { unsigned shift = 0; for (; (one & m) == 0 && (shift < MantissaWidth::value); m <<= 1, ++shift) @@ -171,7 +171,7 @@ template struct NormalFloat { #ifdef SPECIAL_X86_LONG_DOUBLE template <> -inline void NormalFloat::initFromBits(FPBits bits) noexcept { +inline void NormalFloat::initFromBits(FPBits bits) { sign = bits.getSign(); if (bits.isInfOrNaN() || bits.isZero()) { diff --git a/libc/utils/FPUtil/PolyEval.h b/libc/utils/FPUtil/PolyEval.h index 313f57bcd032c..ce8377fe895a1 100644 --- a/libc/utils/FPUtil/PolyEval.h +++ b/libc/utils/FPUtil/PolyEval.h @@ -24,12 +24,10 @@ namespace __llvm_libc { namespace fputil { -template static inline T polyeval(T x, T a0) noexcept { - return a0; -} +template static inline T polyeval(T x, T a0) { return a0; } template -static inline T polyeval(T x, T a0, Ts... a) noexcept { +static inline T polyeval(T x, T a0, Ts... a) { return fma(x, polyeval(x, a...), a0); } @@ -41,12 +39,10 @@ static inline T polyeval(T x, T a0, Ts... a) noexcept { namespace __llvm_libc { namespace fputil { -template static inline T polyeval(T x, T a0) noexcept { - return a0; -} +template static inline T polyeval(T x, T a0) { return a0; } template -static inline T polyeval(T x, T a0, Ts... a) noexcept { +static inline T polyeval(T x, T a0, Ts... a) { return x * polyeval(x, a...) + a0; } diff --git a/libc/utils/FPUtil/Sqrt.h b/libc/utils/FPUtil/Sqrt.h index a15a0eb4cf9cb..b977bc2ef8773 100644 --- a/libc/utils/FPUtil/Sqrt.h +++ b/libc/utils/FPUtil/Sqrt.h @@ -21,10 +21,9 @@ namespace internal { template static inline void normalize(int &exponent, - typename FPBits::UIntType &mantissa) noexcept; + typename FPBits::UIntType &mantissa); -template <> -inline void normalize(int &exponent, uint32_t &mantissa) noexcept { +template <> inline void normalize(int &exponent, uint32_t &mantissa) { // Use binary search to shift the leading 1 bit. // With MantissaWidth = 23, it will take // ceil(log2(23)) = 5 steps checking the mantissa bits as followed: @@ -46,8 +45,7 @@ inline void normalize(int &exponent, uint32_t &mantissa) noexcept { } } -template <> -inline void normalize(int &exponent, uint64_t &mantissa) noexcept { +template <> inline void normalize(int &exponent, uint64_t &mantissa) { // Use binary search to shift the leading 1 bit similar to float. // With MantissaWidth = 52, it will take // ceil(log2(52)) = 6 steps checking the mantissa bits. @@ -66,13 +64,12 @@ inline void normalize(int &exponent, uint64_t &mantissa) noexcept { #ifdef LONG_DOUBLE_IS_DOUBLE template <> -inline void normalize(int &exponent, uint64_t &mantissa) noexcept { +inline void normalize(int &exponent, uint64_t &mantissa) { normalize(exponent, mantissa); } #elif !defined(SPECIAL_X86_LONG_DOUBLE) template <> -inline void normalize(int &exponent, - __uint128_t &mantissa) noexcept { +inline void normalize(int &exponent, __uint128_t &mantissa) { // Use binary search to shift the leading 1 bit similar to float. // With MantissaWidth = 112, it will take // ceil(log2(112)) = 7 steps checking the mantissa bits. @@ -98,7 +95,7 @@ inline void normalize(int &exponent, // Shift-and-add algorithm. template ::Value, int> = 0> -static inline T sqrt(T x) noexcept { +static inline T sqrt(T x) { using UIntType = typename FPBits::UIntType; constexpr UIntType One = UIntType(1) << MantissaWidth::value; diff --git a/libc/utils/FPUtil/SqrtLongDoubleX86.h b/libc/utils/FPUtil/SqrtLongDoubleX86.h index 2b21647550f3c..58326183678b8 100644 --- a/libc/utils/FPUtil/SqrtLongDoubleX86.h +++ b/libc/utils/FPUtil/SqrtLongDoubleX86.h @@ -20,8 +20,7 @@ namespace fputil { namespace internal { template <> -inline void normalize(int &exponent, - __uint128_t &mantissa) noexcept { +inline void normalize(int &exponent, __uint128_t &mantissa) { // Use binary search to shift the leading 1 bit similar to float. // With MantissaWidth = 63, it will take // ceil(log2(63)) = 6 steps checking the mantissa bits. @@ -43,7 +42,7 @@ inline void normalize(int &exponent, // Correctly rounded SQRT with round to nearest, ties to even. // Shift-and-add algorithm. -template <> inline long double sqrt(long double x) noexcept { +template <> inline long double sqrt(long double x) { using UIntType = typename FPBits::UIntType; constexpr UIntType One = UIntType(1) << int(MantissaWidth::value); diff --git a/llvm/include/llvm/Support/Compiler.h b/llvm/include/llvm/Support/Compiler.h index ec90f75719470..57052b596edbe 100644 --- a/llvm/include/llvm/Support/Compiler.h +++ b/llvm/include/llvm/Support/Compiler.h @@ -246,10 +246,8 @@ #define LLVM_ATTRIBUTE_NORETURN __attribute__((noreturn)) #elif defined(_MSC_VER) #define LLVM_ATTRIBUTE_NORETURN __declspec(noreturn) -#elif __cplusplus -#define LLVM_ATTRIBUTE_NORETURN [[noreturn]] #else -#define LLVM_ATTRIBUTE_NORETURN _Noreturn +#define LLVM_ATTRIBUTE_NORETURN #endif #if __has_attribute(returns_nonnull) || LLVM_GNUC_PREREQ(4, 9, 0) diff --git a/llvm/lib/TableGen/Error.cpp b/llvm/lib/TableGen/Error.cpp index cf7c4dd129499..6104573b4b25b 100644 --- a/llvm/lib/TableGen/Error.cpp +++ b/llvm/lib/TableGen/Error.cpp @@ -11,11 +11,11 @@ // //===----------------------------------------------------------------------===// -#include "llvm/TableGen/Error.h" #include "llvm/ADT/Twine.h" +#include "llvm/Support/raw_ostream.h" #include "llvm/Support/Signals.h" #include "llvm/Support/WithColor.h" -#include "llvm/Support/raw_ostream.h" +#include "llvm/TableGen/Error.h" #include "llvm/TableGen/Record.h" #include @@ -25,7 +25,7 @@ SourceMgr SrcMgr; unsigned ErrorsPrinted = 0; static void PrintMessage(ArrayRef Loc, SourceMgr::DiagKind Kind, - const Twine &Msg) noexcept { + const Twine &Msg) { // Count the total number of errors printed. // This is used to exit with an error code if there were any errors. if (Kind == SourceMgr::DK_Error) @@ -42,23 +42,24 @@ static void PrintMessage(ArrayRef Loc, SourceMgr::DiagKind Kind, // Functions to print notes. -void PrintNote(const Twine &Msg) noexcept { WithColor::note() << Msg << "\n"; } +void PrintNote(const Twine &Msg) { + WithColor::note() << Msg << "\n"; +} -void PrintNote(ArrayRef NoteLoc, const Twine &Msg) noexcept { +void PrintNote(ArrayRef NoteLoc, const Twine &Msg) { PrintMessage(NoteLoc, SourceMgr::DK_Note, Msg); } // Functions to print fatal notes. -LLVM_ATTRIBUTE_NORETURN void PrintFatalNote(const Twine &Msg) noexcept { +void PrintFatalNote(const Twine &Msg) { PrintNote(Msg); // The following call runs the file cleanup handlers. sys::RunInterruptHandlers(); std::exit(1); } -LLVM_ATTRIBUTE_NORETURN void PrintFatalNote(ArrayRef NoteLoc, - const Twine &Msg) noexcept { +void PrintFatalNote(ArrayRef NoteLoc, const Twine &Msg) { PrintNote(NoteLoc, Msg); // The following call runs the file cleanup handlers. sys::RunInterruptHandlers(); @@ -67,7 +68,7 @@ LLVM_ATTRIBUTE_NORETURN void PrintFatalNote(ArrayRef NoteLoc, // This method takes a Record and uses the source location // stored in it. -LLVM_ATTRIBUTE_NORETURN void PrintFatalNote(const Record *Rec, const Twine &Msg) noexcept { +void PrintFatalNote(const Record *Rec, const Twine &Msg) { PrintNote(Rec->getLoc(), Msg); // The following call runs the file cleanup handlers. sys::RunInterruptHandlers(); @@ -76,8 +77,7 @@ LLVM_ATTRIBUTE_NORETURN void PrintFatalNote(const Record *Rec, const Twine &Msg) // This method takes a RecordVal and uses the source location // stored in it. -LLVM_ATTRIBUTE_NORETURN void PrintFatalNote(const RecordVal *RecVal, - const Twine &Msg) noexcept { +void PrintFatalNote(const RecordVal *RecVal, const Twine &Msg) { PrintNote(RecVal->getLoc(), Msg); // The following call runs the file cleanup handlers. sys::RunInterruptHandlers(); @@ -86,55 +86,50 @@ LLVM_ATTRIBUTE_NORETURN void PrintFatalNote(const RecordVal *RecVal, // Functions to print warnings. -void PrintWarning(const Twine &Msg) noexcept { - WithColor::warning() << Msg << "\n"; -} +void PrintWarning(const Twine &Msg) { WithColor::warning() << Msg << "\n"; } -void PrintWarning(ArrayRef WarningLoc, const Twine &Msg) noexcept { +void PrintWarning(ArrayRef WarningLoc, const Twine &Msg) { PrintMessage(WarningLoc, SourceMgr::DK_Warning, Msg); } -void PrintWarning(const char *Loc, const Twine &Msg) noexcept { +void PrintWarning(const char *Loc, const Twine &Msg) { SrcMgr.PrintMessage(SMLoc::getFromPointer(Loc), SourceMgr::DK_Warning, Msg); } // Functions to print errors. -void PrintError(const Twine &Msg) noexcept { - WithColor::error() << Msg << "\n"; -} +void PrintError(const Twine &Msg) { WithColor::error() << Msg << "\n"; } -void PrintError(ArrayRef ErrorLoc, const Twine &Msg) noexcept { +void PrintError(ArrayRef ErrorLoc, const Twine &Msg) { PrintMessage(ErrorLoc, SourceMgr::DK_Error, Msg); } -void PrintError(const char *Loc, const Twine &Msg) noexcept { +void PrintError(const char *Loc, const Twine &Msg) { SrcMgr.PrintMessage(SMLoc::getFromPointer(Loc), SourceMgr::DK_Error, Msg); } // This method takes a Record and uses the source location // stored in it. -void PrintError(const Record *Rec, const Twine &Msg) noexcept { +void PrintError(const Record *Rec, const Twine &Msg) { PrintMessage(Rec->getLoc(), SourceMgr::DK_Error, Msg); } // This method takes a RecordVal and uses the source location // stored in it. -void PrintError(const RecordVal *RecVal, const Twine &Msg) noexcept { +void PrintError(const RecordVal *RecVal, const Twine &Msg) { PrintMessage(RecVal->getLoc(), SourceMgr::DK_Error, Msg); } // Functions to print fatal errors. -[[noreturn]] void PrintFatalError(const Twine &Msg) noexcept { +void PrintFatalError(const Twine &Msg) { PrintError(Msg); // The following call runs the file cleanup handlers. sys::RunInterruptHandlers(); std::exit(1); } -[[noreturn]] void PrintFatalError(ArrayRef ErrorLoc, - const Twine &Msg) noexcept { +void PrintFatalError(ArrayRef ErrorLoc, const Twine &Msg) { PrintError(ErrorLoc, Msg); // The following call runs the file cleanup handlers. sys::RunInterruptHandlers(); @@ -143,8 +138,7 @@ void PrintError(const RecordVal *RecVal, const Twine &Msg) noexcept { // This method takes a Record and uses the source location // stored in it. -[[noreturn]] void PrintFatalError(const Record *Rec, - const Twine &Msg) noexcept { +void PrintFatalError(const Record *Rec, const Twine &Msg) { PrintError(Rec->getLoc(), Msg); // The following call runs the file cleanup handlers. sys::RunInterruptHandlers(); @@ -153,8 +147,7 @@ void PrintError(const RecordVal *RecVal, const Twine &Msg) noexcept { // This method takes a RecordVal and uses the source location // stored in it. -[[noreturn]] void PrintFatalError(const RecordVal *RecVal, - const Twine &Msg) noexcept { +void PrintFatalError(const RecordVal *RecVal, const Twine &Msg) { PrintError(RecVal->getLoc(), Msg); // The following call runs the file cleanup handlers. sys::RunInterruptHandlers(); @@ -163,9 +156,9 @@ void PrintError(const RecordVal *RecVal, const Twine &Msg) noexcept { // Check an assertion: Obtain the condition value and be sure it is true. // If not, print a nonfatal error along with the message. -void CheckAssert(SMLoc Loc, Init *Condition, Init *Message) noexcept { +void CheckAssert(SMLoc Loc, Init *Condition, Init *Message) { auto *CondValue = dyn_cast_or_null( - Condition->convertInitializerTo(IntRecTy::get())); + Condition->convertInitializerTo(IntRecTy::get())); if (!CondValue) PrintError(Loc, "assert condition must of type bit, bits, or int."); else if (!CondValue->getValue()) { From abaaed473edffc1fbc2dddfa8785a146bfc29eb4 Mon Sep 17 00:00:00 2001 From: Alfonso Gregory <83477269+gAlfonso-bit@users.noreply.github.com> Date: Mon, 26 Jul 2021 13:31:39 -0400 Subject: [PATCH 13/17] OK --- llvm/include/llvm/Support/Compiler.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/llvm/include/llvm/Support/Compiler.h b/llvm/include/llvm/Support/Compiler.h index 57052b596edbe..ec90f75719470 100644 --- a/llvm/include/llvm/Support/Compiler.h +++ b/llvm/include/llvm/Support/Compiler.h @@ -246,8 +246,10 @@ #define LLVM_ATTRIBUTE_NORETURN __attribute__((noreturn)) #elif defined(_MSC_VER) #define LLVM_ATTRIBUTE_NORETURN __declspec(noreturn) +#elif __cplusplus +#define LLVM_ATTRIBUTE_NORETURN [[noreturn]] #else -#define LLVM_ATTRIBUTE_NORETURN +#define LLVM_ATTRIBUTE_NORETURN _Noreturn #endif #if __has_attribute(returns_nonnull) || LLVM_GNUC_PREREQ(4, 9, 0) From a93e9b919c0fc4ac42fe3457da2d3fde30c82e01 Mon Sep 17 00:00:00 2001 From: Alfonso Gregory <83477269+gAlfonso-bit@users.noreply.github.com> Date: Mon, 26 Jul 2021 13:34:15 -0400 Subject: [PATCH 14/17] Fix --- libc/src/__support/common.h | 4 ++-- libc/src/ctype/isalpha.h | 2 +- libc/src/ctype/isascii.h | 2 +- libc/src/ctype/isblank.h | 2 +- libc/src/ctype/iscntrl.h | 2 +- libc/src/ctype/isdigit.h | 2 +- libc/src/ctype/isgraph.h | 2 +- libc/src/ctype/islower.h | 2 +- libc/src/ctype/isprint.h | 2 +- libc/src/ctype/ispunct.h | 2 +- libc/src/ctype/isspace.h | 2 +- libc/src/ctype/isupper.h | 2 +- libc/src/ctype/isxdigit.h | 2 +- libc/src/ctype/toascii.h | 2 +- libc/src/ctype/tolower.h | 2 +- libc/src/ctype/toupper.h | 2 +- 16 files changed, 17 insertions(+), 17 deletions(-) diff --git a/libc/src/__support/common.h b/libc/src/__support/common.h index b5cd66ae52ca9..53a63fc2e9173 100644 --- a/libc/src/__support/common.h +++ b/libc/src/__support/common.h @@ -24,9 +24,9 @@ LLVM_LIBC_FUNCTION_ATTR decltype(__llvm_libc::name) \ __##name##_impl__ __asm__(#name); \ decltype(__llvm_libc::name) name [[gnu::alias(#name)]]; \ - type __##name##_impl__ arglist noexcept + type __##name##_impl__ arglist #else -#define LLVM_LIBC_FUNCTION(type, name, arglist) type name arglist noexcept +#define LLVM_LIBC_FUNCTION(type, name, arglist) type name arglist #endif namespace __llvm_libc { diff --git a/libc/src/ctype/isalpha.h b/libc/src/ctype/isalpha.h index c1f1f9e9ed054..d5697a39e9aa5 100644 --- a/libc/src/ctype/isalpha.h +++ b/libc/src/ctype/isalpha.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -int isalpha(int c) noexcept; +int isalpha(int c); } // namespace __llvm_libc diff --git a/libc/src/ctype/isascii.h b/libc/src/ctype/isascii.h index ce328f2a2467e..7e31b3c6ca4dd 100644 --- a/libc/src/ctype/isascii.h +++ b/libc/src/ctype/isascii.h @@ -13,7 +13,7 @@ namespace __llvm_libc { -int isascii(int c) noexcept; +int isascii(int c); } // namespace __llvm_libc diff --git a/libc/src/ctype/isblank.h b/libc/src/ctype/isblank.h index ac706d60588f9..0554322d08251 100644 --- a/libc/src/ctype/isblank.h +++ b/libc/src/ctype/isblank.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -int isblank(int c) noexcept; +int isblank(int c); } // namespace __llvm_libc diff --git a/libc/src/ctype/iscntrl.h b/libc/src/ctype/iscntrl.h index 676123e269d47..26f094053a28a 100644 --- a/libc/src/ctype/iscntrl.h +++ b/libc/src/ctype/iscntrl.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -int iscntrl(int c) noexcept; +int iscntrl(int c); } // namespace __llvm_libc diff --git a/libc/src/ctype/isdigit.h b/libc/src/ctype/isdigit.h index a0d1aa4d8181b..32a76235e0592 100644 --- a/libc/src/ctype/isdigit.h +++ b/libc/src/ctype/isdigit.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -int isdigit(int c) noexcept; +int isdigit(int c); } // namespace __llvm_libc diff --git a/libc/src/ctype/isgraph.h b/libc/src/ctype/isgraph.h index 9eb47aa3d9372..421d0ffc4488b 100644 --- a/libc/src/ctype/isgraph.h +++ b/libc/src/ctype/isgraph.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -int isgraph(int c) noexcept; +int isgraph(int c); } // namespace __llvm_libc diff --git a/libc/src/ctype/islower.h b/libc/src/ctype/islower.h index 7905506ad05cc..7643542fb7a99 100644 --- a/libc/src/ctype/islower.h +++ b/libc/src/ctype/islower.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -int islower(int c) noexcept; +int islower(int c); } // namespace __llvm_libc diff --git a/libc/src/ctype/isprint.h b/libc/src/ctype/isprint.h index 97daf4b908b1d..17ed56ef25340 100644 --- a/libc/src/ctype/isprint.h +++ b/libc/src/ctype/isprint.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -int isprint(int c) noexcept; +int isprint(int c); } // namespace __llvm_libc diff --git a/libc/src/ctype/ispunct.h b/libc/src/ctype/ispunct.h index 265524d65711b..23cc08a0bac9c 100644 --- a/libc/src/ctype/ispunct.h +++ b/libc/src/ctype/ispunct.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -int ispunct(int c) noexcept; +int ispunct(int c); } // namespace __llvm_libc diff --git a/libc/src/ctype/isspace.h b/libc/src/ctype/isspace.h index ef49dea7462df..d919e9e7d972b 100644 --- a/libc/src/ctype/isspace.h +++ b/libc/src/ctype/isspace.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -int isspace(int c) noexcept; +int isspace(int c); } // namespace __llvm_libc diff --git a/libc/src/ctype/isupper.h b/libc/src/ctype/isupper.h index 83a9df3044c57..7a1f2270943a9 100644 --- a/libc/src/ctype/isupper.h +++ b/libc/src/ctype/isupper.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -int isupper(int c) noexcept; +int isupper(int c); } // namespace __llvm_libc diff --git a/libc/src/ctype/isxdigit.h b/libc/src/ctype/isxdigit.h index 16a12c1afdd42..a332ecc1018ff 100644 --- a/libc/src/ctype/isxdigit.h +++ b/libc/src/ctype/isxdigit.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -int isxdigit(int c) noexcept; +int isxdigit(int c); } // namespace __llvm_libc diff --git a/libc/src/ctype/toascii.h b/libc/src/ctype/toascii.h index 59bac6770b844..c3f48a38d84c9 100644 --- a/libc/src/ctype/toascii.h +++ b/libc/src/ctype/toascii.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -int toascii(int c) noexcept; +int toascii(int c); } // namespace __llvm_libc diff --git a/libc/src/ctype/tolower.h b/libc/src/ctype/tolower.h index d88be0e6f9551..97e675c558252 100644 --- a/libc/src/ctype/tolower.h +++ b/libc/src/ctype/tolower.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -int tolower(int c) noexcept; +int tolower(int c); } // namespace __llvm_libc diff --git a/libc/src/ctype/toupper.h b/libc/src/ctype/toupper.h index eac891d4d5949..a21b0cf79d955 100644 --- a/libc/src/ctype/toupper.h +++ b/libc/src/ctype/toupper.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -int toupper(int c) noexcept; +int toupper(int c); } // namespace __llvm_libc From d1c9efd4c442c03364015e6503895192e4cd5b4c Mon Sep 17 00:00:00 2001 From: Alfonso Gregory <83477269+gAlfonso-bit@users.noreply.github.com> Date: Mon, 26 Jul 2021 13:34:18 -0400 Subject: [PATCH 15/17] Revert "Update memchr.h" This reverts commit dbc6ac1e9b10131092a426413e2034782d8cd9b0. --- libc/src/string/memchr.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libc/src/string/memchr.h b/libc/src/string/memchr.h index 98246cb4ea032..369475305236d 100644 --- a/libc/src/string/memchr.h +++ b/libc/src/string/memchr.h @@ -13,7 +13,7 @@ namespace __llvm_libc { -void *memchr(const void *src, int c, size_t n) noexcept; +void *memchr(const void *src, int c, size_t n); } // namespace __llvm_libc From 165785068daad11652cc7f8394e352b4c1adc658 Mon Sep 17 00:00:00 2001 From: Alfonso Gregory <83477269+gAlfonso-bit@users.noreply.github.com> Date: Mon, 26 Jul 2021 13:47:12 -0400 Subject: [PATCH 16/17] Fix --- libc/src/stdlib/abort.h | 2 +- libc/src/string/memmove.cpp | 2 +- libc/utils/HdrGen/Command.h | 2 +- llvm/lib/TableGen/Error.cpp | 10 ++++------ 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/libc/src/stdlib/abort.h b/libc/src/stdlib/abort.h index 17f9544816632..4878fb9bbb45d 100644 --- a/libc/src/stdlib/abort.h +++ b/libc/src/stdlib/abort.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -[[noreturn]] void abort(); +LLVM_ATTRIBUTE_NORETURN void abort(); } // namespace __llvm_libc diff --git a/libc/src/string/memmove.cpp b/libc/src/string/memmove.cpp index 3e5b493e0f7f2..ebbe4643e7da6 100644 --- a/libc/src/string/memmove.cpp +++ b/libc/src/string/memmove.cpp @@ -16,7 +16,7 @@ namespace __llvm_libc { static inline void move_byte_forward(char *dest_m, const char *src_m, - size_t count) noexcept { + size_t count) { for (size_t offset = 0; count; --count, ++offset) dest_m[offset] = src_m[offset]; } diff --git a/libc/utils/HdrGen/Command.h b/libc/utils/HdrGen/Command.h index edc40298d97d9..4303a2204d156 100644 --- a/libc/utils/HdrGen/Command.h +++ b/libc/utils/HdrGen/Command.h @@ -36,7 +36,7 @@ class Command { public: ErrorReporter(llvm::SMLoc L, llvm::SourceMgr &SM) : Loc(L), SrcMgr(SM) {} - void printFatalError(llvm::Twine Msg) const { + LLVM_ATTRIBUTE_NORETURN void printFatalError(llvm::Twine Msg) const { SrcMgr.PrintMessage(Loc, llvm::SourceMgr::DK_Error, Msg); std::exit(1); } diff --git a/llvm/lib/TableGen/Error.cpp b/llvm/lib/TableGen/Error.cpp index 6104573b4b25b..ccec8992db54c 100644 --- a/llvm/lib/TableGen/Error.cpp +++ b/llvm/lib/TableGen/Error.cpp @@ -11,11 +11,11 @@ // //===----------------------------------------------------------------------===// +#include "llvm/TableGen/Error.h" #include "llvm/ADT/Twine.h" -#include "llvm/Support/raw_ostream.h" #include "llvm/Support/Signals.h" #include "llvm/Support/WithColor.h" -#include "llvm/TableGen/Error.h" +#include "llvm/Support/raw_ostream.h" #include "llvm/TableGen/Record.h" #include @@ -42,9 +42,7 @@ static void PrintMessage(ArrayRef Loc, SourceMgr::DiagKind Kind, // Functions to print notes. -void PrintNote(const Twine &Msg) { - WithColor::note() << Msg << "\n"; -} +void PrintNote(const Twine &Msg) { WithColor::note() << Msg << "\n"; } void PrintNote(ArrayRef NoteLoc, const Twine &Msg) { PrintMessage(NoteLoc, SourceMgr::DK_Note, Msg); @@ -158,7 +156,7 @@ void PrintFatalError(const RecordVal *RecVal, const Twine &Msg) { // If not, print a nonfatal error along with the message. void CheckAssert(SMLoc Loc, Init *Condition, Init *Message) { auto *CondValue = dyn_cast_or_null( - Condition->convertInitializerTo(IntRecTy::get())); + Condition->convertInitializerTo(IntRecTy::get())); if (!CondValue) PrintError(Loc, "assert condition must of type bit, bits, or int."); else if (!CondValue->getValue()) { From 4b3cb0e385e23be8878f30d506fe73ee381c7a78 Mon Sep 17 00:00:00 2001 From: Alfonso Gregory <83477269+gAlfonso-bit@users.noreply.github.com> Date: Mon, 26 Jul 2021 13:55:11 -0400 Subject: [PATCH 17/17] Fixup --- libc/src/__support/integer_operations.h | 3 ++- libc/src/assert/__assert_fail.cpp | 8 ++++---- libc/src/stdlib/abort.h | 2 +- libc/utils/HdrGen/Command.h | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/libc/src/__support/integer_operations.h b/libc/src/__support/integer_operations.h index f52c11a4a97e7..4c13bb86e2d87 100644 --- a/libc/src/__support/integer_operations.h +++ b/libc/src/__support/integer_operations.h @@ -14,7 +14,8 @@ namespace __llvm_libc { template -static constexpr inline cpp::EnableIfType::Value, T> integerAbs(T n) { +static constexpr cpp::EnableIfType::Value, T> +integerAbs(T n) { return (n < 0) ? -n : n; } diff --git a/libc/src/assert/__assert_fail.cpp b/libc/src/assert/__assert_fail.cpp index 5ccb96dc4af47..8bb76cd430d2e 100644 --- a/libc/src/assert/__assert_fail.cpp +++ b/libc/src/assert/__assert_fail.cpp @@ -18,16 +18,16 @@ namespace __llvm_libc { // This is just a temporary solution to make assert available to internal // llvm libc code. In the future writeToStderr will not exist and __assert_fail // will call fprintf(stderr, ...). -static void writeToStderr(const char *s) noexcept { +static void writeToStderr(const char *s) { size_t length = 0; for (const char *curr = s; *curr; ++curr) ++length; __llvm_libc::syscall(SYS_write, 2, s, length); } -[[noreturn]] LLVM_LIBC_FUNCTION(void, __assert_fail, - (const char *assertion, const char *file, - unsigned line, const char *function)) { +LLVM_LIBC_FUNCTION(void, __assert_fail, + (const char *assertion, const char *file, unsigned line, + const char *function)) { writeToStderr(file); writeToStderr(": Assertion failed: '"); writeToStderr(assertion); diff --git a/libc/src/stdlib/abort.h b/libc/src/stdlib/abort.h index 4878fb9bbb45d..17f9544816632 100644 --- a/libc/src/stdlib/abort.h +++ b/libc/src/stdlib/abort.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -LLVM_ATTRIBUTE_NORETURN void abort(); +[[noreturn]] void abort(); } // namespace __llvm_libc diff --git a/libc/utils/HdrGen/Command.h b/libc/utils/HdrGen/Command.h index 4303a2204d156..895f472c3ad32 100644 --- a/libc/utils/HdrGen/Command.h +++ b/libc/utils/HdrGen/Command.h @@ -36,7 +36,7 @@ class Command { public: ErrorReporter(llvm::SMLoc L, llvm::SourceMgr &SM) : Loc(L), SrcMgr(SM) {} - LLVM_ATTRIBUTE_NORETURN void printFatalError(llvm::Twine Msg) const { + [[noreturn]] void printFatalError(llvm::Twine Msg) const { SrcMgr.PrintMessage(Loc, llvm::SourceMgr::DK_Error, Msg); std::exit(1); }