[LICM] allow MemoryAccess creation failure (#116813)
[llvm-project.git] / libc / fuzzing / math / math_differential_fuzz.cpp
blob0e66377cfba90d5b6a154d4af7efbc69952ccf1a
1 //===-- ldexp_differential_fuzz.cpp ---------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 ///
9 /// Differential fuzz test for llvm-libc ldexp implementation.
10 ///
11 //===----------------------------------------------------------------------===//
13 #include "fuzzing/math/RemQuoDiff.h"
14 #include "fuzzing/math/SingleInputSingleOutputDiff.h"
15 #include "fuzzing/math/TwoInputSingleOutputDiff.h"
17 #include "src/math/ceil.h"
18 #include "src/math/ceilf.h"
19 #include "src/math/ceill.h"
21 #include "src/math/fdim.h"
22 #include "src/math/fdimf.h"
23 #include "src/math/fdiml.h"
25 #include "src/math/floor.h"
26 #include "src/math/floorf.h"
27 #include "src/math/floorl.h"
29 #include "src/math/frexp.h"
30 #include "src/math/frexpf.h"
31 #include "src/math/frexpl.h"
33 #include "src/math/hypotf.h"
35 #include "src/math/ldexp.h"
36 #include "src/math/ldexpf.h"
37 #include "src/math/ldexpl.h"
39 #include "src/math/logb.h"
40 #include "src/math/logbf.h"
41 #include "src/math/logbl.h"
43 #include "src/math/modf.h"
44 #include "src/math/modff.h"
45 #include "src/math/modfl.h"
47 #include "src/math/remainder.h"
48 #include "src/math/remainderf.h"
49 #include "src/math/remainderl.h"
51 #include "src/math/remquo.h"
52 #include "src/math/remquof.h"
53 #include "src/math/remquol.h"
55 #include "src/math/round.h"
56 #include "src/math/roundf.h"
57 #include "src/math/roundl.h"
59 #include "src/math/sqrt.h"
60 #include "src/math/sqrtf.h"
61 #include "src/math/sqrtl.h"
63 #include "src/math/trunc.h"
64 #include "src/math/truncf.h"
65 #include "src/math/truncl.h"
67 #include <math.h>
68 #include <stddef.h>
69 #include <stdint.h>
71 extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
73 SingleInputSingleOutputDiff<float>(&LIBC_NAMESPACE::ceilf, &::ceilf, data,
74 size);
75 SingleInputSingleOutputDiff<double>(&LIBC_NAMESPACE::ceil, &::ceil, data,
76 size);
77 SingleInputSingleOutputDiff<long double>(&LIBC_NAMESPACE::ceill, &::ceill,
78 data, size);
80 SingleInputSingleOutputDiff<float>(&LIBC_NAMESPACE::floorf, &::floorf, data,
81 size);
82 SingleInputSingleOutputDiff<double>(&LIBC_NAMESPACE::floor, &::floor, data,
83 size);
84 SingleInputSingleOutputDiff<long double>(&LIBC_NAMESPACE::floorl, &::floorl,
85 data, size);
87 SingleInputSingleOutputDiff<float>(&LIBC_NAMESPACE::roundf, &::roundf, data,
88 size);
89 SingleInputSingleOutputDiff<double>(&LIBC_NAMESPACE::round, &::round, data,
90 size);
91 SingleInputSingleOutputDiff<long double>(&LIBC_NAMESPACE::roundl, &::roundl,
92 data, size);
94 SingleInputSingleOutputDiff<float>(&LIBC_NAMESPACE::truncf, &::truncf, data,
95 size);
96 SingleInputSingleOutputDiff<double>(&LIBC_NAMESPACE::trunc, &::trunc, data,
97 size);
98 SingleInputSingleOutputDiff<long double>(&LIBC_NAMESPACE::truncl, &::truncl,
99 data, size);
101 SingleInputSingleOutputDiff<float>(&LIBC_NAMESPACE::logbf, &::logbf, data,
102 size);
103 SingleInputSingleOutputDiff<double>(&LIBC_NAMESPACE::logb, &::logb, data,
104 size);
105 SingleInputSingleOutputDiff<long double>(&LIBC_NAMESPACE::logbl, &::logbl,
106 data, size);
108 TwoInputSingleOutputDiff<float, float>(&LIBC_NAMESPACE::hypotf, &::hypotf,
109 data, size);
111 TwoInputSingleOutputDiff<float, float>(&LIBC_NAMESPACE::remainderf,
112 &::remainderf, data, size);
113 TwoInputSingleOutputDiff<double, double>(&LIBC_NAMESPACE::remainder,
114 &::remainder, data, size);
115 TwoInputSingleOutputDiff<long double, long double>(
116 &LIBC_NAMESPACE::remainderl, &::remainderl, data, size);
118 TwoInputSingleOutputDiff<float, float>(&LIBC_NAMESPACE::fdimf, &::fdimf, data,
119 size);
120 TwoInputSingleOutputDiff<double, double>(&LIBC_NAMESPACE::fdim, &::fdim, data,
121 size);
122 TwoInputSingleOutputDiff<long double, long double>(&LIBC_NAMESPACE::fdiml,
123 &::fdiml, data, size);
125 SingleInputSingleOutputDiff<float>(&LIBC_NAMESPACE::sqrtf, &::sqrtf, data,
126 size);
127 SingleInputSingleOutputDiff<double>(&LIBC_NAMESPACE::sqrt, &::sqrt, data,
128 size);
129 SingleInputSingleOutputDiff<long double>(&LIBC_NAMESPACE::sqrtl, &::sqrtl,
130 data, size);
132 SingleInputSingleOutputWithSideEffectDiff<float, int>(&LIBC_NAMESPACE::frexpf,
133 &::frexpf, data, size);
134 SingleInputSingleOutputWithSideEffectDiff<double, int>(&LIBC_NAMESPACE::frexp,
135 &::frexp, data, size);
136 SingleInputSingleOutputWithSideEffectDiff<long double, int>(
137 &LIBC_NAMESPACE::frexpl, &::frexpl, data, size);
139 SingleInputSingleOutputWithSideEffectDiff<float, float>(
140 &LIBC_NAMESPACE::modff, &::modff, data, size);
141 SingleInputSingleOutputWithSideEffectDiff<double, double>(
142 &LIBC_NAMESPACE::modf, &::modf, data, size);
143 SingleInputSingleOutputWithSideEffectDiff<long double, long double>(
144 &LIBC_NAMESPACE::modfl, &::modfl, data, size);
146 TwoInputSingleOutputDiff<float, int>(&LIBC_NAMESPACE::ldexpf, &::ldexpf, data,
147 size);
148 TwoInputSingleOutputDiff<double, int>(&LIBC_NAMESPACE::ldexp, &::ldexp, data,
149 size);
150 TwoInputSingleOutputDiff<long double, int>(&LIBC_NAMESPACE::ldexpl, &::ldexpl,
151 data, size);
153 RemQuoDiff<float>(&LIBC_NAMESPACE::remquof, &::remquof, data, size);
154 RemQuoDiff<double>(&LIBC_NAMESPACE::remquo, &::remquo, data, size);
155 RemQuoDiff<long double>(&LIBC_NAMESPACE::remquol, &::remquol, data, size);
157 return 0;