[libc-commits] [libc] [libc] Add maybe_unused for functions only used on slow path (PR #98024)

Joseph Huber via libc-commits libc-commits at lists.llvm.org
Mon Jul 8 07:03:09 PDT 2024


https://github.com/jhuber6 created https://github.com/llvm/llvm-project/pull/98024

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


>From b2fc97b454853b19e7d38ef3d4f1ba35e17740bd Mon Sep 17 00:00:00 2001
From: Joseph Huber <huberjn at outlook.com>
Date: Mon, 8 Jul 2024 09:02:00 -0500
Subject: [PATCH] [libc] Add maybe_unused for functions only used on slow path

Summary:
When the fast math options are enabled these functions are uncalled,
which makes it error.
---
 libc/src/math/generic/tan.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libc/src/math/generic/tan.cpp b/libc/src/math/generic/tan.cpp
index e6230e9c1cd69c..7f1385c4717dd9 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;



More information about the libc-commits mailing list