diff --git a/SingleSource/UnitTests/testcase-CGExprConstant-IR.ll b/SingleSource/UnitTests/testcase-CGExprConstant-IR.ll new file mode 100644 --- /dev/null +++ b/SingleSource/UnitTests/testcase-CGExprConstant-IR.ll @@ -0,0 +1,57 @@ +; ModuleID = 'testcase-CGExprConstant.c' +source_filename = "testcase-CGExprConstant.c" +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-pc-linux-gnu" + +%struct.S1 = type { i32, i32 } +%struct.S2 = type { %struct.S1, %struct.S1*, [2 x i32] } + +@gs1 = dso_local global %struct.S1 { i32 1, i32 2 }, align 4 +@.compoundliteral = internal global %struct.S2 { %struct.S1 { i32 1, i32 2 }, %struct.S1* @gs1, [2 x i32] [i32 1, i32 2] }, align 8 +@s = dso_local local_unnamed_addr global %struct.S2* @.compoundliteral, align 8 +@.str = private unnamed_addr constant [3 x i8] c"%d\00", align 1 + +; Function Attrs: nofree nounwind uwtable +define dso_local i32 @main() local_unnamed_addr #0 { + %1 = load %struct.S2*, %struct.S2** @s, align 8, !tbaa !3 + %2 = getelementptr inbounds %struct.S2, %struct.S2* %1, i64 0, i32 0, i32 1 + %3 = load i32, i32* %2, align 4, !tbaa !7 + %4 = icmp eq i32 %3, 2 + br i1 %4, label %5, label %11 + +5: ; preds = %0 + %6 = getelementptr inbounds %struct.S2, %struct.S2* %1, i64 0, i32 2, i64 1 + %7 = load i32, i32* %6, align 4, !tbaa !11 + %8 = icmp eq i32 %7, 2 + br i1 %8, label %9, label %11 + +9: ; preds = %5 + %10 = tail call i32 (i8*, ...) @printf(i8* nonnull dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2) + br label %11 + +11: ; preds = %5, %0, %9 + %12 = phi i32 [ 0, %9 ], [ 2, %0 ], [ 6, %5 ] + ret i32 %12 +} + +; Function Attrs: nofree nounwind +declare dso_local noundef i32 @printf(i8* nocapture noundef readonly, ...) local_unnamed_addr #1 + +attributes #0 = { nofree nounwind uwtable "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #1 = { nofree nounwind "frame-pointer"="none" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } + +!llvm.module.flags = !{!0, !1} +!llvm.ident = !{!2} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 7, !"uwtable", i32 1} +!2 = !{!"Ubuntu clang version 13.0.0-++20210711063810+98c2e4115d8d-1~exp1~20210711164601.2534"} +!3 = !{!4, !4, i64 0} +!4 = !{!"any pointer", !5, i64 0} +!5 = !{!"omnipotent char", !6, i64 0} +!6 = !{!"Simple C/C++ TBAA"} +!7 = !{!8, !10, i64 4} +!8 = !{!"S2", !9, i64 0, !4, i64 8, !5, i64 16} +!9 = !{!"S1", !10, i64 0, !10, i64 4} +!10 = !{!"int", !5, i64 0} +!11 = !{!10, !10, i64 0} diff --git a/SingleSource/UnitTests/testcase-CGExprConstant-IR.reference_output b/SingleSource/UnitTests/testcase-CGExprConstant-IR.reference_output new file mode 100644 --- /dev/null +++ b/SingleSource/UnitTests/testcase-CGExprConstant-IR.reference_output @@ -0,0 +1 @@ +2exit 0 diff --git a/SingleSource/UnitTests/testcase-CodeGen-1-IR.ll b/SingleSource/UnitTests/testcase-CodeGen-1-IR.ll new file mode 100644 --- /dev/null +++ b/SingleSource/UnitTests/testcase-CodeGen-1-IR.ll @@ -0,0 +1,53 @@ +; ModuleID = 'testcase-CodeGen-1.c' +source_filename = "testcase-CodeGen-1.c" +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-pc-linux-gnu" + +@a = dso_local local_unnamed_addr global i128 0, align 16 + +; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn uwtable +define dso_local void @b() local_unnamed_addr #0 { + %1 = load i128, ptr @a, align 16, !tbaa !5 + %2 = uitofp i128 %1 to double + %3 = fptoui double %2 to i128 + store i128 %3, ptr @a, align 16, !tbaa !5 + ret void +} + +; Function Attrs: nounwind uwtable +define dso_local i32 @main() local_unnamed_addr #1 { + %1 = load i128, ptr @a, align 16, !tbaa !5 + %2 = uitofp i128 %1 to double + %3 = fptoui double %2 to i128 + store i128 %3, ptr @a, align 16, !tbaa !5 + %4 = icmp eq i128 %3, 0 + br i1 %4, label %6, label %5 + +5: ; preds = %0 + tail call void @abort() #3 + unreachable + +6: ; preds = %0 + ret i32 0 +} + +; Function Attrs: noreturn +declare void @abort() local_unnamed_addr #2 + +attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn uwtable "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #1 = { nounwind uwtable "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #2 = { noreturn "frame-pointer"="none" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #3 = { noreturn nounwind } + +!llvm.module.flags = !{!0, !1, !2, !3} +!llvm.ident = !{!4} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 7, !"PIC Level", i32 2} +!2 = !{i32 7, !"PIE Level", i32 2} +!3 = !{i32 7, !"uwtable", i32 2} +!4 = !{!"Ubuntu clang version 15.0.0-++20220502063808+e547a333a433-1~exp1~20220502183820.463"} +!5 = !{!6, !6, i64 0} +!6 = !{!"__int128", !7, i64 0} +!7 = !{!"omnipotent char", !8, i64 0} +!8 = !{!"Simple C/C++ TBAA"} diff --git a/SingleSource/UnitTests/testcase-CodeGen-1-IR.reference_output b/SingleSource/UnitTests/testcase-CodeGen-1-IR.reference_output new file mode 100644 --- /dev/null +++ b/SingleSource/UnitTests/testcase-CodeGen-1-IR.reference_output @@ -0,0 +1 @@ +exit 0 diff --git a/SingleSource/UnitTests/testcase-CodeGen-1.c b/SingleSource/UnitTests/testcase-CodeGen-1.c new file mode 100644 --- /dev/null +++ b/SingleSource/UnitTests/testcase-CodeGen-1.c @@ -0,0 +1,15 @@ +// COVERAGE: llvm-project/llvm/lib/Analysis/InlineCost.cpp (1 new functions) +// COVERAGE: llvm-project/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp (2 new functions) +// COVERAGE: llvm-project/llvm/lib/CodeGen/TargetLoweringBase.cpp (2 new functions) +extern void abort(); +#ifndef __SIZEOF_INT128__ +#define __int128 long long // Appears in test case of pr61375.c +#endif +unsigned __int128 a; +void b() { a = (double)a + 0; } +int main() { + b(); + if (a) + abort(); + return 0; +} diff --git a/SingleSource/UnitTests/testcase-CodeGen-1.reference_output b/SingleSource/UnitTests/testcase-CodeGen-1.reference_output new file mode 100644 --- /dev/null +++ b/SingleSource/UnitTests/testcase-CodeGen-1.reference_output @@ -0,0 +1 @@ +exit 0 diff --git a/SingleSource/UnitTests/testcase-CodeGen-2-IR.ll b/SingleSource/UnitTests/testcase-CodeGen-2-IR.ll new file mode 100644 --- /dev/null +++ b/SingleSource/UnitTests/testcase-CodeGen-2-IR.ll @@ -0,0 +1,46 @@ +; ModuleID = 'testcase-CodeGen-2.c' +source_filename = "testcase-CodeGen-2.c" +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-pc-linux-gnu" + +@a = dso_local local_unnamed_addr global float 0.000000e+00, align 4 + +; Function Attrs: nounwind uwtable +define dso_local i32 @main() local_unnamed_addr #0 { + %1 = load float, ptr @a, align 4, !tbaa !5 + %2 = fptosi float %1 to i128 + %3 = sitofp i128 %2 to double + %4 = fadd double %3, 1.000000e+01 + %5 = fcmp une double %4, 0.000000e+00 + %6 = zext i1 %5 to i128 + %7 = add nsw i128 %6, %2 + %8 = icmp eq i128 %7, 1 + br i1 %8, label %10, label %9 + +9: ; preds = %0 + tail call void @abort() #2 + unreachable + +10: ; preds = %0 + ret i32 0 +} + +; Function Attrs: noreturn +declare void @abort() local_unnamed_addr #1 + +attributes #0 = { nounwind uwtable "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #1 = { noreturn "frame-pointer"="none" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #2 = { noreturn nounwind } + +!llvm.module.flags = !{!0, !1, !2, !3} +!llvm.ident = !{!4} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 7, !"PIC Level", i32 2} +!2 = !{i32 7, !"PIE Level", i32 2} +!3 = !{i32 7, !"uwtable", i32 2} +!4 = !{!"Ubuntu clang version 15.0.0-++20220502063808+e547a333a433-1~exp1~20220502183820.463"} +!5 = !{!6, !6, i64 0} +!6 = !{!"float", !7, i64 0} +!7 = !{!"omnipotent char", !8, i64 0} +!8 = !{!"Simple C/C++ TBAA"} diff --git a/SingleSource/UnitTests/testcase-CodeGen-2-IR.reference_output b/SingleSource/UnitTests/testcase-CodeGen-2-IR.reference_output new file mode 100644 --- /dev/null +++ b/SingleSource/UnitTests/testcase-CodeGen-2-IR.reference_output @@ -0,0 +1 @@ +exit 0 diff --git a/SingleSource/UnitTests/testcase-CodeGen-2.c b/SingleSource/UnitTests/testcase-CodeGen-2.c new file mode 100644 --- /dev/null +++ b/SingleSource/UnitTests/testcase-CodeGen-2.c @@ -0,0 +1,15 @@ +// COVERAGE: llvm-project/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp (1 new functions) +// COVERAGE: llvm-project/llvm/lib/CodeGen/TargetLoweringBase.cpp (1 new functions) +extern void abort(); +#ifndef __SIZEOF_INT128__ +#define __int128 long long // Appears in test case of pr61375.c +#endif +float a; +int main() { + __int128 b = a; + if (b + (double)10) + ++b; + while (b != 1) + abort(); + return 0; +} diff --git a/SingleSource/UnitTests/testcase-CodeGen-2.reference_output b/SingleSource/UnitTests/testcase-CodeGen-2.reference_output new file mode 100644 --- /dev/null +++ b/SingleSource/UnitTests/testcase-CodeGen-2.reference_output @@ -0,0 +1 @@ +exit 0 diff --git a/SingleSource/UnitTests/testcase-CodeGen-3-IR.ll b/SingleSource/UnitTests/testcase-CodeGen-3-IR.ll new file mode 100644 --- /dev/null +++ b/SingleSource/UnitTests/testcase-CodeGen-3-IR.ll @@ -0,0 +1,52 @@ +; ModuleID = 'testcase-CodeGen-3.c' +source_filename = "testcase-CodeGen-3.c" +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-pc-linux-gnu" + +@f = dso_local local_unnamed_addr global float 0.000000e+00, align 4 +@.str = private unnamed_addr constant [5 x i8] c"%lld\00", align 1 + +; Function Attrs: nofree nounwind uwtable +define dso_local i32 @main() local_unnamed_addr #0 { + %1 = load float, ptr @f, align 4, !tbaa !5 + %2 = fptosi float %1 to i128 + %3 = sitofp i128 %2 to double + %4 = fadd double %3, 1.000000e+01 + %5 = fptosi double %4 to i64 + %6 = sub nsw i64 10, %5 + %7 = sext i64 %6 to i128 + %8 = icmp sgt i128 %2, %7 + br i1 %8, label %15, label %9 + +9: ; preds = %0, %9 + %10 = phi i128 [ %11, %9 ], [ %2, %0 ] + %11 = add nsw i128 %10, 1 + %12 = trunc i128 %11 to i64 + %13 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull @.str, i64 noundef %12) + %14 = icmp eq i128 %11, 11 + br i1 %14, label %15, label %9, !llvm.loop !9 + +15: ; preds = %9, %0 + ret i32 0 +} + +; Function Attrs: nofree nounwind +declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #1 + +attributes #0 = { nofree nounwind uwtable "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #1 = { nofree nounwind "frame-pointer"="none" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } + +!llvm.module.flags = !{!0, !1, !2, !3} +!llvm.ident = !{!4} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 7, !"PIC Level", i32 2} +!2 = !{i32 7, !"PIE Level", i32 2} +!3 = !{i32 7, !"uwtable", i32 2} +!4 = !{!"Ubuntu clang version 15.0.0-++20220502063808+e547a333a433-1~exp1~20220502183820.463"} +!5 = !{!6, !6, i64 0} +!6 = !{!"float", !7, i64 0} +!7 = !{!"omnipotent char", !8, i64 0} +!8 = !{!"Simple C/C++ TBAA"} +!9 = distinct !{!9, !10} +!10 = !{!"llvm.loop.mustprogress"} diff --git a/SingleSource/UnitTests/testcase-CodeGen-3-IR.reference_output b/SingleSource/UnitTests/testcase-CodeGen-3-IR.reference_output new file mode 100644 --- /dev/null +++ b/SingleSource/UnitTests/testcase-CodeGen-3-IR.reference_output @@ -0,0 +1 @@ +1234567891011exit 0 diff --git a/SingleSource/UnitTests/testcase-CodeGen-3.c b/SingleSource/UnitTests/testcase-CodeGen-3.c new file mode 100644 --- /dev/null +++ b/SingleSource/UnitTests/testcase-CodeGen-3.c @@ -0,0 +1,23 @@ +// COVERAGE: llvm-project/clang/lib/AST/ExprConstant.cpp (1 new functions) +// COVERAGE: llvm-project/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp (1 new functions) +// COVERAGE: llvm-project/llvm/lib/CodeGen/TargetLoweringBase.cpp (1 new functions) +#include "stdio.h" +#ifdef __SIZEOF_INT128__ +typedef __int128 L; // Appears in pr49218.c test case +#else +typedef long long L; +#endif +float f; +int main() { + L i = f; + if (i <= 10 + + 41 * +((long)(((int)10) >> ((int)10))) * + ((long)(((int)(i)) % ((int)10))) - + ((long)(((double)(i)) + ((double)10))) - + ((long)(((int)10) ^ ((int)10)))) + do { + ++i; + printf("%lld", (long long) i); + } while (i != 11); + return 0; +} diff --git a/SingleSource/UnitTests/testcase-CodeGen-3.reference_output b/SingleSource/UnitTests/testcase-CodeGen-3.reference_output new file mode 100644 --- /dev/null +++ b/SingleSource/UnitTests/testcase-CodeGen-3.reference_output @@ -0,0 +1 @@ +1234567891011exit 0 diff --git a/SingleSource/UnitTests/testcase-Expr-1-IR.ll b/SingleSource/UnitTests/testcase-Expr-1-IR.ll new file mode 100644 --- /dev/null +++ b/SingleSource/UnitTests/testcase-Expr-1-IR.ll @@ -0,0 +1,37 @@ +; ModuleID = 'testcase-Expr-1.c' +source_filename = "testcase-Expr-1.c" +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-pc-linux-gnu" + +@arr = dso_local local_unnamed_addr global [3 x i32] [i32 0, i32 1, i32 2], align 4 +@.str = private unnamed_addr constant [3 x i8] c"%d\00", align 1 + +; Function Attrs: nofree nounwind uwtable +define dso_local i32 @main() local_unnamed_addr #0 { + %1 = load i32, i32* getelementptr inbounds ([3 x i32], [3 x i32]* @arr, i64 0, i64 1), align 4, !tbaa !3 + %2 = tail call i32 (i8*, ...) @printf(i8* nonnull dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %1) + %3 = load i32, i32* getelementptr inbounds ([3 x i32], [3 x i32]* @arr, i64 0, i64 1), align 4, !tbaa !3 + %4 = icmp eq i32 %3, -5 + %5 = load i32, i32* getelementptr inbounds ([3 x i32], [3 x i32]* @arr, i64 0, i64 2), align 4 + %6 = icmp eq i32 %5, 2 + %7 = select i1 %6, i32 0, i32 3 + %8 = select i1 %4, i32 %7, i32 2 + ret i32 %8 +} + +; Function Attrs: nofree nounwind +declare dso_local noundef i32 @printf(i8* nocapture noundef readonly, ...) local_unnamed_addr #1 + +attributes #0 = { nofree nounwind uwtable "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #1 = { nofree nounwind "frame-pointer"="none" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } + +!llvm.module.flags = !{!0, !1} +!llvm.ident = !{!2} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 7, !"uwtable", i32 1} +!2 = !{!"Ubuntu clang version 13.0.0-++20210711063810+98c2e4115d8d-1~exp1~20210711164601.2534"} +!3 = !{!4, !4, i64 0} +!4 = !{!"int", !5, i64 0} +!5 = !{!"omnipotent char", !6, i64 0} +!6 = !{!"Simple C/C++ TBAA"} diff --git a/SingleSource/UnitTests/testcase-Expr-1-IR.reference_output b/SingleSource/UnitTests/testcase-Expr-1-IR.reference_output new file mode 100644 --- /dev/null +++ b/SingleSource/UnitTests/testcase-Expr-1-IR.reference_output @@ -0,0 +1 @@ +1exit 2 diff --git a/SingleSource/UnitTests/testcase-ExprConstant-1-IR.ll b/SingleSource/UnitTests/testcase-ExprConstant-1-IR.ll new file mode 100644 --- /dev/null +++ b/SingleSource/UnitTests/testcase-ExprConstant-1-IR.ll @@ -0,0 +1,25 @@ +; ModuleID = 'testcase-ExprConstant-1.c' +source_filename = "testcase-ExprConstant-1.c" +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-pc-linux-gnu" + +@.str = private unnamed_addr constant [3 x i8] c"%d\00", align 1 + +; Function Attrs: nofree nounwind uwtable +define dso_local i32 @main() local_unnamed_addr #0 { + %1 = tail call i32 (i8*, ...) @printf(i8* nonnull dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 5) + ret i32 1 +} + +; Function Attrs: nofree nounwind +declare dso_local noundef i32 @printf(i8* nocapture noundef readonly, ...) local_unnamed_addr #1 + +attributes #0 = { nofree nounwind uwtable "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #1 = { nofree nounwind "frame-pointer"="none" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } + +!llvm.module.flags = !{!0, !1} +!llvm.ident = !{!2} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 7, !"uwtable", i32 1} +!2 = !{!"Ubuntu clang version 13.0.0-++20210711063810+98c2e4115d8d-1~exp1~20210711164601.2534"} diff --git a/SingleSource/UnitTests/testcase-ExprConstant-1-IR.reference_output b/SingleSource/UnitTests/testcase-ExprConstant-1-IR.reference_output new file mode 100644 --- /dev/null +++ b/SingleSource/UnitTests/testcase-ExprConstant-1-IR.reference_output @@ -0,0 +1 @@ +5exit 1 diff --git a/SingleSource/UnitTests/testcase-ExprConstant-2-IR.ll b/SingleSource/UnitTests/testcase-ExprConstant-2-IR.ll new file mode 100644 --- /dev/null +++ b/SingleSource/UnitTests/testcase-ExprConstant-2-IR.ll @@ -0,0 +1,25 @@ +; ModuleID = 'testcase-ExprConstant-2.c' +source_filename = "testcase-ExprConstant-2.c" +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-pc-linux-gnu" + +@.str.1 = private unnamed_addr constant [5 x i8] c"long\00", align 1 + +; Function Attrs: nofree nounwind uwtable +define dso_local i32 @main() local_unnamed_addr #0 { + %1 = tail call i32 @puts(i8* nonnull dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0)) + ret i32 0 +} + +; Function Attrs: nofree nounwind +declare noundef i32 @puts(i8* nocapture noundef readonly) local_unnamed_addr #1 + +attributes #0 = { nofree nounwind uwtable "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #1 = { nofree nounwind } + +!llvm.module.flags = !{!0, !1} +!llvm.ident = !{!2} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 7, !"uwtable", i32 1} +!2 = !{!"Ubuntu clang version 13.0.0-++20210711063810+98c2e4115d8d-1~exp1~20210711164601.2534"} diff --git a/SingleSource/UnitTests/testcase-ExprConstant-2-IR.reference_output b/SingleSource/UnitTests/testcase-ExprConstant-2-IR.reference_output new file mode 100644 --- /dev/null +++ b/SingleSource/UnitTests/testcase-ExprConstant-2-IR.reference_output @@ -0,0 +1,2 @@ +long +exit 0 diff --git a/SingleSource/UnitTests/testcase-Float2Int-IR.ll b/SingleSource/UnitTests/testcase-Float2Int-IR.ll new file mode 100644 --- /dev/null +++ b/SingleSource/UnitTests/testcase-Float2Int-IR.ll @@ -0,0 +1,54 @@ +; ModuleID = 'testcase-Float2Int.c' +source_filename = "testcase-Float2Int.c" +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-pc-linux-gnu" + +@b = dso_local local_unnamed_addr global i8 32, align 1 +@.str = private unnamed_addr constant [3 x i8] c"%d\00", align 1 + +; Function Attrs: nofree nounwind uwtable +define dso_local i32 @main() local_unnamed_addr #0 { + %1 = load i8, ptr @b, align 1, !tbaa !5 + %2 = mul i8 %1, %1 + store i8 %2, ptr @b, align 1, !tbaa !5 + %3 = icmp sgt i8 %2, -30 + br i1 %3, label %4, label %11 + +4: ; preds = %0, %4 + %5 = phi i8 [ %9, %4 ], [ %2, %0 ] + %6 = sext i8 %5 to i32 + %7 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull @.str, i32 noundef %6) + %8 = load i8, ptr @b, align 1, !tbaa !5 + %9 = add i8 %8, -1 + store i8 %9, ptr @b, align 1, !tbaa !5 + %10 = icmp sgt i8 %9, -30 + br i1 %10, label %4, label %11, !llvm.loop !8 + +11: ; preds = %4, %0 + %12 = tail call i32 @putchar(i32 10) + ret i32 0 +} + +; Function Attrs: nofree nounwind +declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #1 + +; Function Attrs: nofree nounwind +declare noundef i32 @putchar(i32 noundef) local_unnamed_addr #2 + +attributes #0 = { nofree nounwind uwtable "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #1 = { nofree nounwind "frame-pointer"="none" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #2 = { nofree nounwind } + +!llvm.module.flags = !{!0, !1, !2, !3} +!llvm.ident = !{!4} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 7, !"PIC Level", i32 2} +!2 = !{i32 7, !"PIE Level", i32 2} +!3 = !{i32 7, !"uwtable", i32 2} +!4 = !{!"Ubuntu clang version 15.0.0-++20220502063808+e547a333a433-1~exp1~20220502183820.463"} +!5 = !{!6, !6, i64 0} +!6 = !{!"omnipotent char", !7, i64 0} +!7 = !{!"Simple C/C++ TBAA"} +!8 = distinct !{!8, !9} +!9 = !{!"llvm.loop.mustprogress"} diff --git a/SingleSource/UnitTests/testcase-Float2Int-IR.reference_output b/SingleSource/UnitTests/testcase-Float2Int-IR.reference_output new file mode 100644 --- /dev/null +++ b/SingleSource/UnitTests/testcase-Float2Int-IR.reference_output @@ -0,0 +1,2 @@ +0-1-2-3-4-5-6-7-8-9-10-11-12-13-14-15-16-17-18-19-20-21-22-23-24-25-26-27-28-29 +exit 0 diff --git a/SingleSource/UnitTests/testcase-Float2Int.c b/SingleSource/UnitTests/testcase-Float2Int.c new file mode 100644 --- /dev/null +++ b/SingleSource/UnitTests/testcase-Float2Int.c @@ -0,0 +1,9 @@ +// COVERAGE: llvm-project/llvm/lib/Transforms/Scalar/Float2Int.cpp (1 new functions) +#include "stdio.h" +char b = ' '; +int main() { + for (b = ((long)(((double)(b)) * ((double)(b)))); b >= -29; b--) + printf("%d", (int)b); + printf("\n"); + return 0; +} diff --git a/SingleSource/UnitTests/testcase-Float2Int.reference_output b/SingleSource/UnitTests/testcase-Float2Int.reference_output new file mode 100644 --- /dev/null +++ b/SingleSource/UnitTests/testcase-Float2Int.reference_output @@ -0,0 +1,2 @@ +0-1-2-3-4-5-6-7-8-9-10-11-12-13-14-15-16-17-18-19-20-21-22-23-24-25-26-27-28-29 +exit 0 diff --git a/SingleSource/UnitTests/testcase-InstCombine-1-IR.ll b/SingleSource/UnitTests/testcase-InstCombine-1-IR.ll new file mode 100644 --- /dev/null +++ b/SingleSource/UnitTests/testcase-InstCombine-1-IR.ll @@ -0,0 +1,96 @@ +; ModuleID = 'testcase-InstCombine-1.c' +source_filename = "testcase-InstCombine-1.c" +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-pc-linux-gnu" + +%struct.S = type { [9 x i8] } + +@f = dso_local local_unnamed_addr global i32 0, align 4 +@__const.main.m = private unnamed_addr constant { i8, i8, i8, i8, i8, i8, i8, i8, i8 } { i8 5, i8 0, i8 -40, i8 -1, i8 -1, i8 79, i8 0, i8 20, i8 0 }, align 1 +@h = dso_local local_unnamed_addr global %struct.S zeroinitializer, align 8 + +; Function Attrs: nofree nounwind uwtable +define dso_local i32 @main() local_unnamed_addr #0 { + %1 = load i32, i32* @f, align 4, !tbaa !3 + %2 = icmp eq i32 %1, 0 + br i1 %2, label %21, label %3 + +3: ; preds = %0 + %4 = sub i32 0, %1 + %5 = and i32 %4, 3 + %6 = icmp eq i32 %5, 0 + br i1 %6, label %13, label %7 + +7: ; preds = %3, %7 + %8 = phi i32 [ %10, %7 ], [ %1, %3 ] + %9 = phi i32 [ %11, %7 ], [ %5, %3 ] + tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* noundef nonnull align 8 dereferenceable(9) getelementptr inbounds (%struct.S, %struct.S* @h, i64 0, i32 0, i64 0), i8* noundef nonnull align 1 dereferenceable(9) getelementptr inbounds ({ i8, i8, i8, i8, i8, i8, i8, i8, i8 }, { i8, i8, i8, i8, i8, i8, i8, i8, i8 }* @__const.main.m, i64 0, i32 0), i64 9, i1 false), !tbaa.struct !7 + %10 = add nsw i32 %8, 1 + %11 = add i32 %9, -1 + %12 = icmp eq i32 %11, 0 + br i1 %12, label %13, label %7, !llvm.loop !8 + +13: ; preds = %7, %3 + %14 = phi i32 [ %1, %3 ], [ %10, %7 ] + %15 = icmp ugt i32 %1, -4 + br i1 %15, label %20, label %16 + +16: ; preds = %13, %16 + %17 = phi i32 [ %18, %16 ], [ %14, %13 ] + tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* noundef nonnull align 8 dereferenceable(9) getelementptr inbounds (%struct.S, %struct.S* @h, i64 0, i32 0, i64 0), i8* noundef nonnull align 1 dereferenceable(9) getelementptr inbounds ({ i8, i8, i8, i8, i8, i8, i8, i8, i8 }, { i8, i8, i8, i8, i8, i8, i8, i8, i8 }* @__const.main.m, i64 0, i32 0), i64 9, i1 false), !tbaa.struct !7 + tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* noundef nonnull align 8 dereferenceable(9) getelementptr inbounds (%struct.S, %struct.S* @h, i64 0, i32 0, i64 0), i8* noundef nonnull align 1 dereferenceable(9) getelementptr inbounds ({ i8, i8, i8, i8, i8, i8, i8, i8, i8 }, { i8, i8, i8, i8, i8, i8, i8, i8, i8 }* @__const.main.m, i64 0, i32 0), i64 9, i1 false), !tbaa.struct !7 + tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* noundef nonnull align 8 dereferenceable(9) getelementptr inbounds (%struct.S, %struct.S* @h, i64 0, i32 0, i64 0), i8* noundef nonnull align 1 dereferenceable(9) getelementptr inbounds ({ i8, i8, i8, i8, i8, i8, i8, i8, i8 }, { i8, i8, i8, i8, i8, i8, i8, i8, i8 }* @__const.main.m, i64 0, i32 0), i64 9, i1 false), !tbaa.struct !7 + tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* noundef nonnull align 8 dereferenceable(9) getelementptr inbounds (%struct.S, %struct.S* @h, i64 0, i32 0, i64 0), i8* noundef nonnull align 1 dereferenceable(9) getelementptr inbounds ({ i8, i8, i8, i8, i8, i8, i8, i8, i8 }, { i8, i8, i8, i8, i8, i8, i8, i8, i8 }* @__const.main.m, i64 0, i32 0), i64 9, i1 false), !tbaa.struct !7 + %18 = add nsw i32 %17, 4 + %19 = icmp eq i32 %18, 0 + br i1 %19, label %20, label %16, !llvm.loop !10 + +20: ; preds = %16, %13 + store i32 0, i32* @f, align 4, !tbaa !3 + br label %31 + +21: ; preds = %0 + %22 = load i72, i72* bitcast (%struct.S* @h to i72*), align 8 + %23 = shl i72 %22, 14 + %24 = ashr i72 %23, 57 + %25 = trunc i72 %24 to i32 + %26 = trunc i72 %24 to i64 + %27 = mul nsw i32 %25, %25 + %28 = zext i32 %27 to i64 + %29 = sub nsw i64 0, %28 + %30 = icmp eq i64 %26, %29 + br i1 %30, label %33, label %31 + +31: ; preds = %20, %21 + %32 = tail call i32 @putchar(i32 49) + br label %33 + +33: ; preds = %31, %21 + ret i32 0 +} + +; Function Attrs: argmemonly mustprogress nofree nounwind willreturn +declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #1 + +; Function Attrs: nofree nounwind +declare noundef i32 @putchar(i32 noundef) local_unnamed_addr #2 + +attributes #0 = { nofree nounwind uwtable "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #1 = { argmemonly mustprogress nofree nounwind willreturn } +attributes #2 = { nofree nounwind } + +!llvm.module.flags = !{!0, !1} +!llvm.ident = !{!2} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 7, !"uwtable", i32 1} +!2 = !{!"Ubuntu clang version 13.0.0-++20210711063810+98c2e4115d8d-1~exp1~20210711164601.2534"} +!3 = !{!4, !4, i64 0} +!4 = !{!"int", !5, i64 0} +!5 = !{!"omnipotent char", !6, i64 0} +!6 = !{!"Simple C/C++ TBAA"} +!7 = !{i64 0, i64 4, !3, i64 2, i64 4, !3, i64 2, i64 4, !3, i64 5, i64 4, !3, i64 7, i64 4, !3} +!8 = distinct !{!8, !9} +!9 = !{!"llvm.loop.unroll.disable"} +!10 = distinct !{!10, !11} +!11 = !{!"llvm.loop.mustprogress"} diff --git a/SingleSource/UnitTests/testcase-InstCombine-1-IR.reference_output b/SingleSource/UnitTests/testcase-InstCombine-1-IR.reference_output new file mode 100644 --- /dev/null +++ b/SingleSource/UnitTests/testcase-InstCombine-1-IR.reference_output @@ -0,0 +1 @@ +exit 0 diff --git a/SingleSource/UnitTests/testcase-SemaStmt-1-IR.ll b/SingleSource/UnitTests/testcase-SemaStmt-1-IR.ll new file mode 100644 --- /dev/null +++ b/SingleSource/UnitTests/testcase-SemaStmt-1-IR.ll @@ -0,0 +1,46 @@ +; ModuleID = 'testcase-SemaStmt-1.c' +source_filename = "testcase-SemaStmt-1.c" +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-pc-linux-gnu" + +@d = dso_local local_unnamed_addr global i32 10, align 4 +@b = dso_local local_unnamed_addr global i32 0, align 4 +@c = dso_local local_unnamed_addr global i32 0, align 4 + +; Function Attrs: nounwind uwtable +define dso_local i32 @main() local_unnamed_addr #0 { + store i32 0, ptr @b, align 4, !tbaa !5 + %1 = load i32, ptr @d, align 4, !tbaa !5 + %2 = add nsw i32 %1, 1 + store i32 %2, ptr @d, align 4, !tbaa !5 + store i32 %2, ptr @c, align 4, !tbaa !5 + %3 = icmp eq i32 %2, 11 + br i1 %3, label %5, label %4 + +4: ; preds = %0 + tail call void @abort() #2 + unreachable + +5: ; preds = %0 + ret i32 0 +} + +; Function Attrs: noreturn nounwind +declare void @abort() local_unnamed_addr #1 + +attributes #0 = { nounwind uwtable "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #1 = { noreturn nounwind "frame-pointer"="none" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #2 = { noreturn nounwind } + +!llvm.module.flags = !{!0, !1, !2, !3} +!llvm.ident = !{!4} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 7, !"PIC Level", i32 2} +!2 = !{i32 7, !"PIE Level", i32 2} +!3 = !{i32 7, !"uwtable", i32 2} +!4 = !{!"Ubuntu clang version 15.0.0-++20220502063808+e547a333a433-1~exp1~20220502183820.463"} +!5 = !{!6, !6, i64 0} +!6 = !{!"int", !7, i64 0} +!7 = !{!"omnipotent char", !8, i64 0} +!8 = !{!"Simple C/C++ TBAA"} diff --git a/SingleSource/UnitTests/testcase-SemaStmt-1-IR.reference_output b/SingleSource/UnitTests/testcase-SemaStmt-1-IR.reference_output new file mode 100644 --- /dev/null +++ b/SingleSource/UnitTests/testcase-SemaStmt-1-IR.reference_output @@ -0,0 +1 @@ +exit 0 diff --git a/SingleSource/UnitTests/testcase-SemaStmt-1.c b/SingleSource/UnitTests/testcase-SemaStmt-1.c new file mode 100644 --- /dev/null +++ b/SingleSource/UnitTests/testcase-SemaStmt-1.c @@ -0,0 +1,11 @@ +// COVERAGE: llvm-project/clang/lib/Sema/SemaStmt.cpp (1 new functions) +// Compilation of this code should give unused value warning on return value of function declared with const attribute +int b, c, d = 10; +int main(void) { + __builtin_expect(1 ? b = 0 : 0, d++); // __builtin_expect used in other PRs test cases: like pr43385.c and pr85156.c + + c = d; + if (d != 11) + __builtin_abort(); + return 0; +} diff --git a/SingleSource/UnitTests/testcase-SemaStmt-1.reference_output b/SingleSource/UnitTests/testcase-SemaStmt-1.reference_output new file mode 100644 --- /dev/null +++ b/SingleSource/UnitTests/testcase-SemaStmt-1.reference_output @@ -0,0 +1 @@ +exit 0 diff --git a/SingleSource/UnitTests/testcase-Value-1-IR.ll b/SingleSource/UnitTests/testcase-Value-1-IR.ll new file mode 100644 --- /dev/null +++ b/SingleSource/UnitTests/testcase-Value-1-IR.ll @@ -0,0 +1,66 @@ +; ModuleID = 'testcase-Value-1.c' +source_filename = "testcase-Value-1.c" +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-pc-linux-gnu" + +@b = dso_local local_unnamed_addr global i16 1, align 2 +@d = dso_local local_unnamed_addr global i16 5, align 2 +@h = dso_local local_unnamed_addr global i16 1, align 2 +@e = dso_local local_unnamed_addr global i32 1, align 4 +@f = dso_local local_unnamed_addr global i32 20, align 4 +@g = dso_local local_unnamed_addr global i32 1, align 4 +@j = dso_local local_unnamed_addr global i32 1, align 4 +@c = dso_local local_unnamed_addr global [6 x i8] zeroinitializer, align 1 +@a = dso_local local_unnamed_addr global i8 0, align 1 +@.str = private unnamed_addr constant [3 x i8] c"%d\00", align 1 + +; Function Attrs: nofree nounwind uwtable +define dso_local i32 @main() local_unnamed_addr #0 { + %1 = load i32, i32* @f, align 4, !tbaa !3 + %2 = load i8, i8* @a, align 1 + %3 = icmp eq i32 %1, 0 + br i1 %3, label %13, label %4 + +4: ; preds = %0 + %5 = sext i8 %2 to i32 + %6 = load i32, i32* @j, align 4 + %7 = icmp eq i32 %6, 0 + store i32 %5, i32* @f, align 4, !tbaa !3 + br i1 %7, label %11, label %8 + +8: ; preds = %4 + %9 = icmp eq i8 %2, 0 + br i1 %9, label %11, label %10, !llvm.loop !7 + +10: ; preds = %8, %10 + br label %10 + +11: ; preds = %4, %8 + %12 = phi i32 [ 5, %8 ], [ 33, %4 ] + store i32 %12, i32* @g, align 4, !tbaa !3 + br label %13 + +13: ; preds = %11, %0 + store i32 0, i32* @e, align 4, !tbaa !3 + %14 = tail call i32 (i8*, ...) @printf(i8* nonnull dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 0) + ret i32 0 +} + +; Function Attrs: nofree nounwind +declare dso_local noundef i32 @printf(i8* nocapture noundef readonly, ...) local_unnamed_addr #1 + +attributes #0 = { nofree nounwind uwtable "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #1 = { nofree nounwind "frame-pointer"="none" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } + +!llvm.module.flags = !{!0, !1} +!llvm.ident = !{!2} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 7, !"uwtable", i32 1} +!2 = !{!"Ubuntu clang version 13.0.0-++20210711063810+98c2e4115d8d-1~exp1~20210711164601.2534"} +!3 = !{!4, !4, i64 0} +!4 = !{!"int", !5, i64 0} +!5 = !{!"omnipotent char", !6, i64 0} +!6 = !{!"Simple C/C++ TBAA"} +!7 = distinct !{!7, !8} +!8 = !{!"llvm.loop.mustprogress"} diff --git a/SingleSource/UnitTests/testcase-Value-1-IR.reference_output b/SingleSource/UnitTests/testcase-Value-1-IR.reference_output new file mode 100644 --- /dev/null +++ b/SingleSource/UnitTests/testcase-Value-1-IR.reference_output @@ -0,0 +1 @@ +0exit 0 diff --git a/SingleSource/UnitTests/testcase-clang-lib-1-IR.ll b/SingleSource/UnitTests/testcase-clang-lib-1-IR.ll new file mode 100644 --- /dev/null +++ b/SingleSource/UnitTests/testcase-clang-lib-1-IR.ll @@ -0,0 +1,33 @@ +; ModuleID = 'testcase-clang-lib-1.c' +source_filename = "testcase-clang-lib-1.c" +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-pc-linux-gnu" + +@.str = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1 + +; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone willreturn uwtable +define dso_local i32 @foo(i32 noundef returned %0) local_unnamed_addr #0 { + ret i32 %0 +} + +; Function Attrs: nofree nounwind uwtable +define dso_local i32 @main() local_unnamed_addr #1 { + %1 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull @.str, i32 noundef 3) + ret i32 0 +} + +; Function Attrs: nofree nounwind +declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2 + +attributes #0 = { mustprogress nofree norecurse nosync nounwind readnone willreturn uwtable "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #1 = { nofree nounwind uwtable "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #2 = { nofree nounwind "frame-pointer"="none" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } + +!llvm.module.flags = !{!0, !1, !2, !3} +!llvm.ident = !{!4} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 7, !"PIC Level", i32 2} +!2 = !{i32 7, !"PIE Level", i32 2} +!3 = !{i32 7, !"uwtable", i32 2} +!4 = !{!"Ubuntu clang version 15.0.0-++20220502063808+e547a333a433-1~exp1~20220502183820.463"} diff --git a/SingleSource/UnitTests/testcase-clang-lib-1-IR.reference_output b/SingleSource/UnitTests/testcase-clang-lib-1-IR.reference_output new file mode 100644 --- /dev/null +++ b/SingleSource/UnitTests/testcase-clang-lib-1-IR.reference_output @@ -0,0 +1,2 @@ +3 +exit 0 diff --git a/SingleSource/UnitTests/testcase-clang-lib-1.c b/SingleSource/UnitTests/testcase-clang-lib-1.c new file mode 100644 --- /dev/null +++ b/SingleSource/UnitTests/testcase-clang-lib-1.c @@ -0,0 +1,14 @@ +// COVERAGE: llvm-project/clang/include/clang/AST/EvaluatedExprVisitor.h (1 new functions) +// COVERAGE: llvm-project/clang/lib/AST/ComputeDependence.cpp (1 new functions) +// COVERAGE: llvm-project/clang/lib/AST/Expr.cpp (2 new functions) +// COVERAGE: llvm-project/clang/lib/CodeGen/CGExprScalar.cpp (1 new functions) +// COVERAGE: llvm-project/clang/lib/Parse/ParseExpr.cpp (1 new functions) +// COVERAGE: llvm-project/clang/lib/Sema/SemaExpr.cpp (2 new functions) +#include +typedef int (*fptr)(int); +int foo(int i) { return i; } +int main() { + int b = _Generic(foo, fptr : 3, int : 4); + printf("%d\n", b); + return 0; +} diff --git a/SingleSource/UnitTests/testcase-clang-lib-1.reference_output b/SingleSource/UnitTests/testcase-clang-lib-1.reference_output new file mode 100644 --- /dev/null +++ b/SingleSource/UnitTests/testcase-clang-lib-1.reference_output @@ -0,0 +1,2 @@ +3 +exit 0 diff --git a/SingleSource/UnitTests/testcase-clang-lib-2-IR.ll b/SingleSource/UnitTests/testcase-clang-lib-2-IR.ll new file mode 100644 --- /dev/null +++ b/SingleSource/UnitTests/testcase-clang-lib-2-IR.ll @@ -0,0 +1,20 @@ +; ModuleID = 'testcase-clang-lib-2.c' +source_filename = "testcase-clang-lib-2.c" +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-pc-linux-gnu" + +; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone willreturn uwtable +define dso_local i32 @main() local_unnamed_addr #0 { + ret i32 0 +} + +attributes #0 = { mustprogress nofree norecurse nosync nounwind readnone willreturn uwtable "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } + +!llvm.module.flags = !{!0, !1, !2, !3} +!llvm.ident = !{!4} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 7, !"PIC Level", i32 2} +!2 = !{i32 7, !"PIE Level", i32 2} +!3 = !{i32 7, !"uwtable", i32 2} +!4 = !{!"Ubuntu clang version 15.0.0-++20220502063808+e547a333a433-1~exp1~20220502183820.463"} diff --git a/SingleSource/UnitTests/testcase-clang-lib-2-IR.reference_output b/SingleSource/UnitTests/testcase-clang-lib-2-IR.reference_output new file mode 100644 --- /dev/null +++ b/SingleSource/UnitTests/testcase-clang-lib-2-IR.reference_output @@ -0,0 +1 @@ +exit 0 diff --git a/SingleSource/UnitTests/testcase-clang-lib-2.c b/SingleSource/UnitTests/testcase-clang-lib-2.c new file mode 100644 --- /dev/null +++ b/SingleSource/UnitTests/testcase-clang-lib-2.c @@ -0,0 +1,14 @@ +// COVERAGE: llvm-project/clang/lib/Edit/Commit.cpp (1 new functions) +// COVERAGE: llvm-project/clang/lib/Edit/EditedSource.cpp (4 new functions) +// COVERAGE: llvm-project/clang/lib/Lex/Lexer.cpp (5 new functions) +// Test should warn against unused values +#include "stdint.h" +extern void abort(); +int main() { + uint32_t a = 4; + uint32_t b = 1; + b = (0 && 9 && a, 2, a); + if (!b) + abort(); + return 0; +} diff --git a/SingleSource/UnitTests/testcase-clang-lib-2.reference_output b/SingleSource/UnitTests/testcase-clang-lib-2.reference_output new file mode 100644 --- /dev/null +++ b/SingleSource/UnitTests/testcase-clang-lib-2.reference_output @@ -0,0 +1 @@ +exit 0