git: 27e68baf24f1 - stable/13 - Build lib/msun tests with compiler builtins disabled
Dimitry Andric
dim at FreeBSD.org
Tue Mar 9 20:22:37 UTC 2021
The branch stable/13 has been updated by dim:
URL: https://cgit.FreeBSD.org/src/commit/?id=27e68baf24f1eb10f1cfb48731d7447a78b278ff
commit 27e68baf24f1eb10f1cfb48731d7447a78b278ff
Author: Dimitry Andric <dim at FreeBSD.org>
AuthorDate: 2021-02-23 20:03:32 +0000
Commit: Dimitry Andric <dim at FreeBSD.org>
CommitDate: 2021-03-09 20:17:10 +0000
Build lib/msun tests with compiler builtins disabled
This forces the compiler to emit calls to libm functions, instead of
possibly substituting pre-calculated results at compile time, which
should help to actually test those functions.
Reviewed by: emaste, arichardson, ngie
Differential Revision: https://reviews.freebsd.org/D28577
(cherry picked from commit cf97d2a1dab8f2cddc4466fe64d37818339c73be)
riscv: Add a soft-float implementation of fabs()
We could just use a C implementation using __builtin_fabs(), but using
this assembly version guarantees that there is no additional prolog/epilog
code. Additionally, clang generates worse code for masking off the top bit
than GCC: https://bugs.llvm.org/show_bug.cgi?id=49377.
This fixes the RISCV64 softfloat world build after cf97d2a1dab8. That commit
added -fno-builtin to the msun tests which resulted in the first references to
fabs (previously the compiler inlined all calls).
Reviewed By: dim
Reported by: mjg
Differential Revision: https://reviews.freebsd.org/D28994
(cherry picked from commit 524b018d200408bed5eb0d2b892db5b9fb46808b)
riscv: Fix whitespace issues in fabs added in 524b018d2004
(cherry picked from commit 066dab17e7a4a78d43dbcef8119960ddc8090a73)
---
lib/libc/riscv/gen/fabs.S | 11 +++++++++--
lib/msun/tests/Makefile | 4 ++++
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/lib/libc/riscv/gen/fabs.S b/lib/libc/riscv/gen/fabs.S
index 44249252e9c1..036d50eddf90 100644
--- a/lib/libc/riscv/gen/fabs.S
+++ b/lib/libc/riscv/gen/fabs.S
@@ -1,5 +1,6 @@
/*-
* Copyright (c) 2015-2017 Ruslan Bukin <br at bsdpad.com>
+ * Copyright (c) 2021 Alex Richardson <arichardson at FreeBSD.org>
* All rights reserved.
*
* Portions of this software were developed by SRI International and the
@@ -10,6 +11,9 @@
* Computer Laboratory as part of the CTSRD Project, with support from the
* UK Higher Education Innovation Fund (HEIF).
*
+ * This work was supported by Innovate UK project 105694, "Digital Security
+ * by Design (DSbD) Technology Platform Prototype".
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -35,9 +39,12 @@
#include <machine/asm.h>
__FBSDID("$FreeBSD$");
-#ifdef __riscv_float_abi_double
ENTRY(fabs)
+#ifdef __riscv_float_abi_double
fabs.d fa0, fa0
+#else
+ slli a0, a0, 1
+ srli a0, a0, 1
+#endif
ret
END(fabs)
-#endif
diff --git a/lib/msun/tests/Makefile b/lib/msun/tests/Makefile
index 67a38855309e..902d1ca22f73 100644
--- a/lib/msun/tests/Makefile
+++ b/lib/msun/tests/Makefile
@@ -19,6 +19,10 @@ CFLAGS+= -I${TESTSRC:H}/libc/gen
CFLAGS+= -D__HAVE_LONG_DOUBLE
.endif
+# Avoid builtins, to force the compiler to emit calls to the libm
+# functions, and not calculate any results in advance.
+CFLAGS+= -fno-builtin
+
NETBSD_ATF_TESTS_C= acos_test
NETBSD_ATF_TESTS_C+= asin_test
NETBSD_ATF_TESTS_C+= atan_test
More information about the dev-commits-src-all
mailing list