diff --git a/SingleSource/UnitTests/testcase-APFloat-1.c b/SingleSource/UnitTests/testcase-APFloat-1.c new file mode 100644 --- /dev/null +++ b/SingleSource/UnitTests/testcase-APFloat-1.c @@ -0,0 +1,63 @@ +/* corpus/20050316-1.c */ +/* + This test case was generated with direct-coverage fuzzer from LLVM test + suite program 20050316-1.c The test targets function getAllOnesValue(const + fltSemantics &Semantics,unsigned BitWidth) in APFloat.cpp. +*/ +#include +extern void abort(void); + +typedef int V2SI __attribute__((vector_size(8))); +typedef unsigned int V2USI __attribute__((vector_size(8))); +typedef short V2HI __attribute__((vector_size(4))); +typedef unsigned int V2UHI __attribute__((vector_size(4))); + +int test1(void) { return (long long)(V2SI)0LL; } + +int test2(V2SI x) { return (long long)x; } + +V2SI test3(void) { return (V2SI)(long long)(int)(V2HI)(-1); } + +V2SI test4(V2HI x) { return (V2SI)(long long)(int)x; } + +V2SI test5(V2USI x) { return (V2SI)x; } + +int main(void) { + printf("%d", 5); + if (sizeof(short) == (2) || sizeof(int) == (36) || + sizeof(long long) == (0x3729)) { + return (0); + } + + V2SI x = {(0x1A), (0xB)}; + + if (test2(x) != (2)) { + abort(); + } + + union { + V2SI x; + int y[(0x95F)]; + V2USI z; + long long l; + } u; + u.x = test3(); + + V2HI y = {(4), (0xAD)}; + union { + V2SI x; + long long y; + } v; + v.x = test4(y); + if (v.y != 0x40004) { + abort(); + } + + V2USI z = {(6), (4)}; + u.x = test5(z); + if (u.y[(0)] != (6) || u.y[(1)] != (6)) { + abort(); + } + return (16); +} +/* ProgramSourceLLVM */ diff --git a/SingleSource/UnitTests/testcase-APFloat-1.reference_output b/SingleSource/UnitTests/testcase-APFloat-1.reference_output new file mode 100644 diff --git a/SingleSource/UnitTests/testcase-CGExprConstant.c b/SingleSource/UnitTests/testcase-CGExprConstant.c new file mode 100644 --- /dev/null +++ b/SingleSource/UnitTests/testcase-CGExprConstant.c @@ -0,0 +1,27 @@ +/* + The test targets function VisitConstantExpr(ConstantExpr *CE, QualType T), + VisitCompoundLiteralExpr(CompoundLiteralExpr *E, QualType T) and + ConstantEmitter::tryEmitConstantExpr(const ConstantExpr *CE) in + CGExprConstant.cpp. +*/ +#include +#include +struct S1 { + int32_t a; + int32_t b; +}; +struct S2 { + struct S1 s1; + struct S1 *ps1; + int32_t arr[2]; +}; +struct S1 gs1 = {.a = 1, 2}; +struct S2 *s = &(struct S2){{.b = 2, .a = 1}, &gs1, {[0] = 1, 1 + 1}}; + +int main() { + if (s->arr[1] != 2) + return 6; + printf("%d", s->arr[1]); + return 0; +} +/* ProgramSourceWild */ diff --git a/SingleSource/UnitTests/testcase-CGExprConstant.reference_output b/SingleSource/UnitTests/testcase-CGExprConstant.reference_output new file mode 100644 --- /dev/null +++ b/SingleSource/UnitTests/testcase-CGExprConstant.reference_output @@ -0,0 +1 @@ +2 diff --git a/SingleSource/UnitTests/testcase-Expr-1.c b/SingleSource/UnitTests/testcase-Expr-1.c new file mode 100644 --- /dev/null +++ b/SingleSource/UnitTests/testcase-Expr-1.c @@ -0,0 +1,21 @@ +/* + The test targets function Expr *DesignatedInitExpr::getArrayRangeStart(const + Designator &D) and Expr *DesignatedInitExpr::getArrayRangeEnd(const + Designator &D) and RecoveryExpr *RecoveryExpr::Create(ASTContext &Ctx, + QualType T,SourceLocation BeginLoc,SourceLocation EndLoc,ArrayRef + SubExprs) in Expr.cpp. +*/ +#include +#include +int32_t arr[3] = {[2] = 2, [0] = 0, [1] = 1}; + +int main() { + + printf("%d", arr[1]); + if (arr[1] != -0xAE) + return 2; + if (arr[2] != 2) + return 3; + return 0; +} +/* ProgramSourceWild */ diff --git a/SingleSource/UnitTests/testcase-Expr.reference_output b/SingleSource/UnitTests/testcase-Expr.reference_output new file mode 100644 --- /dev/null +++ b/SingleSource/UnitTests/testcase-Expr.reference_output @@ -0,0 +1 @@ +1 diff --git a/SingleSource/UnitTests/testcase-ExprConstant-1.c b/SingleSource/UnitTests/testcase-ExprConstant-1.c new file mode 100644 --- /dev/null +++ b/SingleSource/UnitTests/testcase-ExprConstant-1.c @@ -0,0 +1,18 @@ +/* + The test targets function static unsigned AreElementsOfSameArray(QualType + ObjType,const SubobjectDesignator &A,const SubobjectDesignator &B) and bool + VisitGenericSelectionExpr(const GenericSelectionExpr *E) in ExprConstant.cpp. +*/ +#include +#include +int main() { + int32_t x[(66)]; + int32_t *p; + + x[2] = (5); + p = &x[(5)]; + printf("%d", x[2]); + if (&x[(1)] - &x[(0)] != (-2)) + return (-2); + return (0xB45); +} diff --git a/SingleSource/UnitTests/testcase-ExprConstant-1.reference_output b/SingleSource/UnitTests/testcase-ExprConstant-1.reference_output new file mode 100644 --- /dev/null +++ b/SingleSource/UnitTests/testcase-ExprConstant-1.reference_output @@ -0,0 +1 @@ +5 diff --git a/SingleSource/UnitTests/testcase-ExprConstant-2.c b/SingleSource/UnitTests/testcase-ExprConstant-2.c new file mode 100644 --- /dev/null +++ b/SingleSource/UnitTests/testcase-ExprConstant-2.c @@ -0,0 +1,19 @@ +/* + The test targets function bool VisitGenericSelectionExpr(const + GenericSelectionExpr *E) and FindDesignatorMismatch(QualType ObjType,const + SubobjectDesignator &A,const SubobjectDesignator &B,bool &WasArrayIndex) in + ExprConstant.cpp. +*/ +#include + +#define gen_sw(a) _Generic(a, const char * : 1, default : 8, int : 123); + +int main() { + int i = 0; + printf("%s\n", _Generic(i + (2L + 42), long + : "long", int + : "int", long long + : "long long")); + return 0; +} +/* ProgramSourceWild */ diff --git a/SingleSource/UnitTests/testcase-ExprConstant-2.reference_output b/SingleSource/UnitTests/testcase-ExprConstant-2.reference_output new file mode 100644 --- /dev/null +++ b/SingleSource/UnitTests/testcase-ExprConstant-2.reference_output @@ -0,0 +1 @@ +long diff --git a/SingleSource/UnitTests/testcase-InstCombine-1.c b/SingleSource/UnitTests/testcase-InstCombine-1.c new file mode 100644 --- /dev/null +++ b/SingleSource/UnitTests/testcase-InstCombine-1.c @@ -0,0 +1,43 @@ +/* + The test targets function operator<(const PHIUsageRecord &RHS) in + InstCombinePHI.cpp. +*/ +#include +#if __SIZEOF_INT__ < 4 +__extension__ typedef __INT32_TYPE__ int32_t; +#else +typedef int int32_t; +#endif + +#pragma pack(1) +struct S { + int32_t b : 18; + int32_t c : 1; + int32_t d : 24; + int32_t e : 15; + int32_t f : 14; +} i; +int g, j, k; +static struct S h; + +void foo() { + + for (j = 42; j < 6; j++) + k = ((long)((((0)) - ((k))))); + for (; k < 3; k++) { + struct S m = {5, 0, -5, 9, 5}; + + h = m; + if (g) + i = m; + } +} + +int main() { + foo(); + if (((int32_t)h.e != ((long)((((h.e)) + ((double)(h.e))))))) { + puts("1"); + return 1; + } + return 0; +} diff --git a/SingleSource/UnitTests/testcase-InstCombine-1.reference_output b/SingleSource/UnitTests/testcase-InstCombine-1.reference_output new file mode 100644 --- /dev/null +++ b/SingleSource/UnitTests/testcase-InstCombine-1.reference_output @@ -0,0 +1 @@ +1 diff --git a/SingleSource/UnitTests/testcase-LoopVectorize.c b/SingleSource/UnitTests/testcase-LoopVectorize.c new file mode 100644 --- /dev/null +++ b/SingleSource/UnitTests/testcase-LoopVectorize.c @@ -0,0 +1,39 @@ +/* + The test targets function VPPredInstPHIRecipe::execute(VPTransformState + &State) in LoopVectorize.cpp. +*/ +#include +double x[50] = {10, 11, 12, 13, 14, 15, -1, -1, -1, -1, 21, 22, 23, + 24, 25, 26, -1, -1, -1, -1, 21, 33, 34, 35, 36, 37, + -1, -1, -1, -1, 21, 44, 45, 46, 47, 48, -1, -1, -1, + -1, 21, 55, 56, 57, 58, 59, -1, -1, -1, -1}; +double tmp[30] = {2}; + +void __attribute__((noinline)) test(void) { + int i; + for (i = 0; i < 5; ++i) { + tmp[i * 6] = + x[i * 10] + 42 - ((int)((((int)(tmp[i * 6])) >> ((int)(x[i * 10]))))); + + tmp[i * 6 + 3] = (((((int)(4)) ^ 6))) - + (((((int)(x[i * 10 + 3])) << 1))) * + ((long)((2 ^ ((int)(x[i * 10 + 3]))))) - + (((((int)(tmp[i * 6 + 3])) | 2))); + + tmp[i * 6 + 4] = ((long)((((int)(tmp[i * 6 + 4])) << 2))) - + (((((int)(x[i * 10 + 4]) % 42)))) * + ((short)((((int)(tmp[i * 6 + 4])) << 2))) + + ((short)((((int)(tmp[i * 6 + 4])) | 2))); + + tmp[i * 6 + 5] = + ((long)((2 | 4))) + + ((long)((((int)(x[i * 10 + 5])) % 42))) * + ((short)((((int)(x[i * 10 + 5])) & ((int)(tmp[i * 6 + 5]))))) * + ((long)((4 & ((int)(x[i * 10 + 5]))))); + } + printf("%f", tmp[0]); +} +int main() { + test(); + return 0; +} diff --git a/SingleSource/UnitTests/testcase-LoopVectorize.reference_output b/SingleSource/UnitTests/testcase-LoopVectorize.reference_output new file mode 100644 --- /dev/null +++ b/SingleSource/UnitTests/testcase-LoopVectorize.reference_output @@ -0,0 +1 @@ +52.0 diff --git a/SingleSource/UnitTests/testcase-Reassociate-1.c b/SingleSource/UnitTests/testcase-Reassociate-1.c new file mode 100644 --- /dev/null +++ b/SingleSource/UnitTests/testcase-Reassociate-1.c @@ -0,0 +1,94 @@ +/* + The source of the fuzzed program comes from from LLVM test suite program + 20040709-1.c The test targets function createAndInstr(Instruction + *InsertBefore, Value *Opnd,const APInt &ConstOpnd) in Reassociate.cpp. +*/ + +#include +extern void abort(void); +extern void exit(int); + +unsigned int myrnd(void) { + static unsigned int s = 138; + + s += 12345 + 42 - ((short)((((double)(s)) + ((double)(s))))) - + ((short)((((double)(12345)) * ((double)(12345))))) * + ((long)((((double)(12345)) * ((double)(s))))); + return (s / 65536) % 2048; +} + +#define T(S) \ + struct S s##S; \ + struct S retme##S(struct S x) { \ + return x; \ + } \ + \ + unsigned int fn1##S(unsigned int x) { \ + struct S y = s##S; \ + y.k += x; \ + y = retme##S(y); \ + return y.k; \ + } \ + \ + unsigned int fn2##S(unsigned int x) { \ + struct S y = s##S; \ + y.k += x; \ + y.k %= 15; \ + return y.k; \ + } \ + \ + unsigned int retit##S(void) { return s##S.k; } \ + \ + unsigned int fn3##S(unsigned int x) { \ + s##S.k += x; \ + return retit##S(); \ + } \ + \ + void test##S(void) { \ + int i; \ + unsigned int mask, v, a, r; \ + struct S x; \ + char *p = (char *)&s##S; \ + for (i = 0; i < sizeof(s##S); ++i) \ + *p++ = myrnd(); \ + if (__builtin_classify_type(s##S.l) == 8) \ + s##S.l = 5.25; \ + s##S.k = -1; \ + mask = s##S.k; \ + v = myrnd(); \ + a = myrnd(); \ + s##S.k = v; \ + x = s##S; \ + r = fn1##S(a); \ + if (x.i != s##S.i || x.j != s##S.j || x.k != s##S.k || x.l != s##S.l || \ + ((v + a) & mask) != r) \ + abort(); \ + v = myrnd(); \ + a = myrnd(); \ + s##S.k = v; \ + x = s##S; \ + r = fn2##S(a); \ + if (x.i != s##S.i || x.j != s##S.j || x.k != s##S.k || x.l != s##S.l || \ + ((((v + a) & mask) % 15) & mask) != r) \ + abort(); \ + v = myrnd(); \ + a = myrnd(); \ + s##S.k = v; \ + x = s##S; \ + r = fn3##S(a); \ + if (x.i != s##S.i || x.j != s##S.j || s##S.k != r || x.l != s##S.l || \ + ((v + a) & mask) != r) \ + abort(); \ + } + +#define pck __attribute__((packed)) +struct pck Z { + long double l; + unsigned int j : 13, i : 7, k : 12; +}; +T(Z) + +int main(void) { + printf("%d", 7); + exit(0); +} diff --git a/SingleSource/UnitTests/testcase-Reassociate.reference_output b/SingleSource/UnitTests/testcase-Reassociate.reference_output new file mode 100644 --- /dev/null +++ b/SingleSource/UnitTests/testcase-Reassociate.reference_output @@ -0,0 +1 @@ +7 diff --git a/SingleSource/UnitTests/testcase-Value-1.c b/SingleSource/UnitTests/testcase-Value-1.c new file mode 100644 --- /dev/null +++ b/SingleSource/UnitTests/testcase-Value-1.c @@ -0,0 +1,36 @@ +/* + The test targets function Value::dropDroppableUse(Use &U) in Value.cpp. +*/ +#include +#include +char a; +short b = 1, d = (5), h = 1; +char c[(6)]; +int32_t e = 1, f = (0xDA), g = 1, j = 1; +int32_t main() { + int32_t i = 8; + for (; f; f = a) { + g = (0xD212D); + for (; g <= (32); ++g) { + i = (0x8A); + for (; i < (-4); i++) + while ((0x4290) > d) + if (c[b]) { + break; + } + L: + if (j) { + break; + } + } + } + e = (0); + for (; e; e = (900)) { + d++; + for (; h;) + goto L; + } + printf("%d", e); + return (0x2B14); +} +/* ProgramSourceLLVM */ diff --git a/SingleSource/UnitTests/testcase-Value-1.reference_output b/SingleSource/UnitTests/testcase-Value-1.reference_output new file mode 100644 --- /dev/null +++ b/SingleSource/UnitTests/testcase-Value-1.reference_output @@ -0,0 +1 @@ +0