Skip to content

[libc] Add maybe_unused for functions only used on slow path #98024

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 8, 2024

Conversation

jhuber6
Copy link
Contributor

@jhuber6 jhuber6 commented Jul 8, 2024

Summary:
When the fast math options are enabled these functions are uncalled,
which makes it error.

Summary:
When the fast math options are enabled these functions are uncalled,
which makes it error.
@jhuber6 jhuber6 requested a review from lntue July 8, 2024 14:03
@llvmbot llvmbot added the libc label Jul 8, 2024
@llvmbot
Copy link
Member

llvmbot commented Jul 8, 2024

@llvm/pr-subscribers-libc

Author: Joseph Huber (jhuber6)

Changes

Summary:
When the fast math options are enabled these functions are uncalled,
which makes it error.


Full diff: https://github.com/llvm/llvm-project/pull/98024.diff

1 Files Affected:

  • (modified) libc/src/math/generic/tan.cpp (+2-2)
diff --git a/libc/src/math/generic/tan.cpp b/libc/src/math/generic/tan.cpp
index e6230e9c1cd69..7f1385c4717dd 100644
--- a/libc/src/math/generic/tan.cpp
+++ b/libc/src/math/generic/tan.cpp
@@ -95,7 +95,7 @@ LIBC_INLINE DoubleDouble tan_eval(const DoubleDouble &u) {
 }
 
 // Accurate evaluation of tan for small u.
-Float128 tan_eval(const Float128 &u) {
+[[maybe_unused]] Float128 tan_eval(const Float128 &u) {
   Float128 u_sq = fputil::quick_mul(u, u);
 
   // tan(x) ~ x + x^3/3 + x^5 * 2/15 + x^7 * 17/315 + x^9 * 62/2835 +
@@ -127,7 +127,7 @@ Float128 tan_eval(const Float128 &u) {
 // Calculation a / b = a * (1/b) for Float128.
 // Using the initial approximation of q ~ (1/b), then apply 2 Newton-Raphson
 // iterations, before multiplying by a.
-Float128 newton_raphson_div(const Float128 &a, Float128 b, double q) {
+[[maybe_unused]] Float128 newton_raphson_div(const Float128 &a, Float128 b, double q) {
   Float128 q0(q);
   constexpr Float128 TWO(2.0);
   b.sign = (b.sign == Sign::POS) ? Sign::NEG : Sign::POS;

@jhuber6 jhuber6 merged commit d3a5589 into llvm:main Jul 8, 2024
5 of 7 checks passed
Copy link

github-actions bot commented Jul 8, 2024

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

You can test this locally with the following command:
git-clang-format --diff 5c40e561bbc102f47553732fcebc0876b45d68b2 b2fc97b454853b19e7d38ef3d4f1ba35e17740bd -- libc/src/math/generic/tan.cpp
View the diff from clang-format here.
diff --git a/libc/src/math/generic/tan.cpp b/libc/src/math/generic/tan.cpp
index 7f1385c471..78d71c16c1 100644
--- a/libc/src/math/generic/tan.cpp
+++ b/libc/src/math/generic/tan.cpp
@@ -127,7 +127,8 @@ LIBC_INLINE DoubleDouble tan_eval(const DoubleDouble &u) {
 // Calculation a / b = a * (1/b) for Float128.
 // Using the initial approximation of q ~ (1/b), then apply 2 Newton-Raphson
 // iterations, before multiplying by a.
-[[maybe_unused]] Float128 newton_raphson_div(const Float128 &a, Float128 b, double q) {
+[[maybe_unused]] Float128 newton_raphson_div(const Float128 &a, Float128 b,
+                                             double q) {
   Float128 q0(q);
   constexpr Float128 TWO(2.0);
   b.sign = (b.sign == Sign::POS) ? Sign::NEG : Sign::POS;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants