[llvm] [TLI] Add support for nan libfunc (PR #101356)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 31 13:07:17 PDT 2024


================
@@ -279,6 +279,9 @@ bool llvm::inferNonMandatoryLibFuncAttrs(Function &F,
     Changed |= setNonLazyBind(F);
 
   switch (TheLibFunc) {
+  case LibFunc_nan:
+  case LibFunc_nanf:
+  case LibFunc_nanl:
----------------
nikic wrote:

```
#include <math.h>
#include <errno.h>
#include <stdio.h>

int main() {
	errno = 0;
	double d = nan("99999999999999999999999999999999999999999");
	int err = errno;
	printf("%d %f\n", err, d);
	return 0;
}

$ clang -lm test.c && ./a.out 
34 nan
```
With glibc. Is this a glibc bug?

https://github.com/llvm/llvm-project/pull/101356


More information about the llvm-commits mailing list