Index: SingleSource/UnitTests/testcase-APFloat-1.c =================================================================== --- /dev/null +++ SingleSource/UnitTests/testcase-APFloat-1.c @@ -0,0 +1,68 @@ +/* + 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); + } + + if (0) { + abort(); + } + + V2SI x = {(0x1A), (0xB)}; + + if (test2(x) != 2) { + abort(); + } + + union { + V2SI x; + int y[0x95F]; + V2USI z; + long long l; + } u; + u.x = test3(); + if (0) { + abort(); + } + + 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); +} Index: SingleSource/UnitTests/testcase-APFloat-1.reference_output =================================================================== --- /dev/null +++ SingleSource/UnitTests/testcase-APFloat-1.reference_output @@ -0,0 +1 @@ +5exit 0 Index: SingleSource/UnitTests/testcase-CGExprConstant.c =================================================================== --- /dev/null +++ SingleSource/UnitTests/testcase-CGExprConstant.c @@ -0,0 +1,38 @@ +/* + This fuzzed program's source comes from + https://github.com/c-testsuite/c-testsuite 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 (0) + return 1; + if (s->s1.b != 2) + return 2; + if (0) + return 3; + if (0) + return 4; + if (0) + return 5; + if (s->arr[1] != 2) + return 6; + printf("%d", s->arr[1]); + return 0; +} Index: SingleSource/UnitTests/testcase-CGExprConstant.reference_output =================================================================== --- /dev/null +++ SingleSource/UnitTests/testcase-CGExprConstant.reference_output @@ -0,0 +1 @@ +2exit 0 Index: SingleSource/UnitTests/testcase-Expr-1.c =================================================================== --- /dev/null +++ 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 (0) + return 1; + if (arr[1] != -0xAE) + return 2; + if (arr[2] != 2) + return 3; + return 0; +} Index: SingleSource/UnitTests/testcase-Expr-1.reference_output =================================================================== --- /dev/null +++ SingleSource/UnitTests/testcase-Expr-1.reference_output @@ -0,0 +1 @@ +1exit 2 Index: SingleSource/UnitTests/testcase-ExprConstant-1.c =================================================================== --- /dev/null +++ SingleSource/UnitTests/testcase-ExprConstant-1.c @@ -0,0 +1,19 @@ +/* + 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 (1); + } + return (0); +} Index: SingleSource/UnitTests/testcase-ExprConstant-1.reference_output =================================================================== --- /dev/null +++ SingleSource/UnitTests/testcase-ExprConstant-1.reference_output @@ -0,0 +1 @@ +5exit 1 Index: SingleSource/UnitTests/testcase-ExprConstant-2.c =================================================================== --- /dev/null +++ SingleSource/UnitTests/testcase-ExprConstant-2.c @@ -0,0 +1,19 @@ +/* + This fuzzed program's source comes from + https://github.com/c-testsuite/c-testsuite 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; +} Index: SingleSource/UnitTests/testcase-ExprConstant-2.reference_output =================================================================== --- /dev/null +++ SingleSource/UnitTests/testcase-ExprConstant-2.reference_output @@ -0,0 +1,2 @@ +long +exit 0 Index: SingleSource/UnitTests/testcase-InstCombine-1.c =================================================================== --- /dev/null +++ SingleSource/UnitTests/testcase-InstCombine-1.c @@ -0,0 +1,24 @@ +/* + The test targets function operator<(const PHIUsageRecord &RHS) in + InstCombinePHI.cpp. +*/ +#include +#include +#pragma pack(1) +struct S { + int32_t a : 18; + int32_t b : 1; + int32_t c : 24; + int32_t d : 15; + int32_t e : 14; +} h; +int f; +int main(void) { + for (; f; f++) { + struct S m = {5, 0, -5, 9, 5}; + h = m; + } + if (h.d != (long)0 - h.d * h.d) + printf("1"); // This should be reachable, since h.d is 15 + return 0; +} Index: SingleSource/UnitTests/testcase-InstCombine-1.reference_output =================================================================== --- /dev/null +++ SingleSource/UnitTests/testcase-InstCombine-1.reference_output @@ -0,0 +1 @@ +1exit 0 Index: SingleSource/UnitTests/testcase-Reassociate-1.c =================================================================== --- /dev/null +++ SingleSource/UnitTests/testcase-Reassociate-1.c @@ -0,0 +1,93 @@ +/* + 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); +} Index: SingleSource/UnitTests/testcase-Reassociate-1.reference_output =================================================================== --- /dev/null +++ SingleSource/UnitTests/testcase-Reassociate-1.reference_output @@ -0,0 +1 @@ +7exit 0 Index: SingleSource/UnitTests/testcase-Value-1.c =================================================================== --- /dev/null +++ SingleSource/UnitTests/testcase-Value-1.c @@ -0,0 +1,35 @@ +/* + 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 = 20, g = 1, j = 1; +int32_t main() { + int32_t i = 8; + for (; f; f = a) { + g = (5); + for (; g <= 32; ++g) { + i = 6; + for (; i < -4; i++) + while (7 > d) + if (c[b]) { + break; + } + L: + if (j) { + break; + } + } + } + e = 0; + for (; e; e = 900) { + d++; + for (; h;) + goto L; + } + printf("%d", e); + return (0); +} Index: SingleSource/UnitTests/testcase-Value-1.reference_output =================================================================== --- /dev/null +++ SingleSource/UnitTests/testcase-Value-1.reference_output @@ -0,0 +1 @@ +0exit 0