[libc-commits] [libc] ce368e1 - [libc][NFC] Workaround clang assertion in inline asm
Alex Brachet via libc-commits
libc-commits at lists.llvm.org
Tue Jan 25 08:40:24 PST 2022
Author: Alex Brachet
Date: 2022-01-25T16:39:55Z
New Revision: ce368e1aa51f3d9f0a5f6ff0be3c02a9cf1e2d2e
URL: https://github.com/llvm/llvm-project/commit/ce368e1aa51f3d9f0a5f6ff0be3c02a9cf1e2d2e
DIFF: https://github.com/llvm/llvm-project/commit/ce368e1aa51f3d9f0a5f6ff0be3c02a9cf1e2d2e.diff
LOG: [libc][NFC] Workaround clang assertion in inline asm
The clobber list "cc" is added to inline assembly to workaround a clang assertion that triggers when building with a clang built with assertions enabled. See bug [53391](https://github.com/llvm/llvm-project/issues/53391).
See https://godbolt.org/z/z3bc6a9PM showing functionally same output assembly.
Reviewed By: sivachandra, lntue
Differential Revision: https://reviews.llvm.org/D118099
Added:
Modified:
libc/src/math/x86_64/cos.cpp
libc/src/math/x86_64/sin.cpp
libc/src/math/x86_64/tan.cpp
Removed:
################################################################################
diff --git a/libc/src/math/x86_64/cos.cpp b/libc/src/math/x86_64/cos.cpp
index 9e7e7227c6b1d..3b785a2f78cdf 100644
--- a/libc/src/math/x86_64/cos.cpp
+++ b/libc/src/math/x86_64/cos.cpp
@@ -13,7 +13,7 @@ namespace __llvm_libc {
LLVM_LIBC_FUNCTION(double, cos, (double x)) {
double result;
- __asm__ __volatile__("fcos" : "=t"(result) : "f"(x));
+ __asm__ __volatile__("fcos" : "=t"(result) : "f"(x) : "cc");
return result;
}
diff --git a/libc/src/math/x86_64/sin.cpp b/libc/src/math/x86_64/sin.cpp
index 22774f278956e..e94aa1a3f0925 100644
--- a/libc/src/math/x86_64/sin.cpp
+++ b/libc/src/math/x86_64/sin.cpp
@@ -13,7 +13,7 @@ namespace __llvm_libc {
LLVM_LIBC_FUNCTION(double, sin, (double x)) {
double result;
- __asm__ __volatile__("fsin" : "=t"(result) : "f"(x));
+ __asm__ __volatile__("fsin" : "=t"(result) : "f"(x) : "cc");
return result;
}
diff --git a/libc/src/math/x86_64/tan.cpp b/libc/src/math/x86_64/tan.cpp
index 9146473741f95..0503af7a16dde 100644
--- a/libc/src/math/x86_64/tan.cpp
+++ b/libc/src/math/x86_64/tan.cpp
@@ -16,7 +16,7 @@ LLVM_LIBC_FUNCTION(double, tan, (double x)) {
double one;
// The fptan instruction pushes the number 1 on to the FP stack after
// computing tan. So, we read out the one before popping the actual result.
- __asm__ __volatile__("fptan" : "=t"(one) : "f"(x));
+ __asm__ __volatile__("fptan" : "=t"(one) : "f"(x) : "cc");
__asm__ __volatile__("fstpl %0" : "=m"(result));
return result;
}
More information about the libc-commits
mailing list