[llvm-commits] [poolalloc] r132091 - in /poolalloc/trunk/test/type_checks: ./ correct/ correct/basic.c correct/basic_repeat.c correct/dg.exp correct/vprintf.c correct/vprintf1.c error/ error/IntUnion.c error/alloc.c error/dg.exp error/testEndian.c

Arushi Aggarwal aggarwa4 at illinois.edu
Wed May 25 15:32:13 PDT 2011


Author: aggarwa4
Date: Wed May 25 17:32:13 2011
New Revision: 132091

URL: http://llvm.org/viewvc/llvm-project?rev=132091&view=rev
Log:
Added simple tests for type checking.

Added:
    poolalloc/trunk/test/type_checks/
    poolalloc/trunk/test/type_checks/correct/
    poolalloc/trunk/test/type_checks/correct/basic.c
    poolalloc/trunk/test/type_checks/correct/basic_repeat.c
    poolalloc/trunk/test/type_checks/correct/dg.exp
    poolalloc/trunk/test/type_checks/correct/vprintf.c
    poolalloc/trunk/test/type_checks/correct/vprintf1.c
    poolalloc/trunk/test/type_checks/error/
    poolalloc/trunk/test/type_checks/error/IntUnion.c
    poolalloc/trunk/test/type_checks/error/alloc.c
    poolalloc/trunk/test/type_checks/error/dg.exp
    poolalloc/trunk/test/type_checks/error/testEndian.c

Added: poolalloc/trunk/test/type_checks/correct/basic.c
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/test/type_checks/correct/basic.c?rev=132091&view=auto
==============================================================================
--- poolalloc/trunk/test/type_checks/correct/basic.c (added)
+++ poolalloc/trunk/test/type_checks/correct/basic.c Wed May 25 17:32:13 2011
@@ -0,0 +1,41 @@
+/*
+ * Build into bitcode
+ * RUN: llvm-gcc -O0 %s --emit-llvm -c -o %t.bc
+ * RUN: adsaopt -internalize -mem2reg -typechecks %t.bc -o %t.tc.bc
+ * RUN: tc-link %t.tc.bc -o %t.tc1.bc
+ * RUN: llc %t.tc1.bc -o %t.tc1.s
+ * RUN: llvm-gcc %t.tc1.s -o %t.tc2
+ * Execute
+ * RUN: %t.tc2 >& %t.tc.out
+ */
+#include <stdarg.h>
+#include <stdio.h>
+//This is a basic use of vararg pointer use
+
+//--build the code into a .bc
+//RUN: llvm-gcc -O0 %s -S --emit-llvm -o - | llvm-as > %t.bc
+//--check if ds-aa breaks, breaks opts, or results in miscompiled code
+//RUN: lli %t.bc > %t.refout
+//RUN: dsaopt %t.bc -ds-aa -O3 -o - | lli > %t.out
+//RUN: diff %t.refout %t.out
+//--check properties of this particular test
+//N/A
+
+static int get( int unused, ... )
+{
+  va_list ap;
+  va_start( ap, unused );
+  int *val = va_arg( ap, int* );
+  va_end( ap );
+
+  return *val;
+}
+
+int main()
+{
+  int stack_val = 5;
+
+  int ret = get( 0, &stack_val );
+
+  return ret - 5;
+}

Added: poolalloc/trunk/test/type_checks/correct/basic_repeat.c
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/test/type_checks/correct/basic_repeat.c?rev=132091&view=auto
==============================================================================
--- poolalloc/trunk/test/type_checks/correct/basic_repeat.c (added)
+++ poolalloc/trunk/test/type_checks/correct/basic_repeat.c Wed May 25 17:32:13 2011
@@ -0,0 +1,44 @@
+/*
+ * Build into bitcode
+ * RUN: llvm-gcc -O0 %s --emit-llvm -c -o %t.bc
+ * RUN: adsaopt -internalize -mem2reg -typechecks %t.bc -o %t.tc.bc
+ * RUN: tc-link %t.tc.bc -o %t.tc1.bc
+ * RUN: llc %t.tc1.bc -o %t.tc1.s
+ * RUN: llvm-gcc %t.tc1.s -o %t.tc2
+ * Execute
+ * RUN: %t.tc2 >& %t.tc.out
+ */
+#include <stdarg.h>
+#include <stdio.h>
+//This is a basic use of vararg pointer use
+
+//--build the code into a .bc
+//RUN: llvm-gcc -O0 %s -S --emit-llvm -o - | llvm-as > %t.bc
+//--check if ds-aa breaks, breaks opts, or results in miscompiled code
+//RUN: lli %t.bc > %t.refout
+//RUN: dsaopt %t.bc -ds-aa -O3 -o - | lli > %t.out
+//RUN: diff %t.refout %t.out
+//--check properties of this particular test
+//N/A
+
+static int get( int unused, ... )
+{
+  va_list ap;
+  va_start( ap, unused );
+  int *val = va_arg( ap, int* );
+  va_end( ap );
+  va_start( ap, unused );
+  int *val1 = va_arg( ap, int* );
+  va_end( ap );
+
+  return *val;
+}
+
+int main()
+{
+  int stack_val = 5;
+
+  int ret = get( 0, &stack_val );
+
+  return ret - 5;
+}

Added: poolalloc/trunk/test/type_checks/correct/dg.exp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/test/type_checks/correct/dg.exp?rev=132091&view=auto
==============================================================================
--- poolalloc/trunk/test/type_checks/correct/dg.exp (added)
+++ poolalloc/trunk/test/type_checks/correct/dg.exp Wed May 25 17:32:13 2011
@@ -0,0 +1,3 @@
+load_lib llvm.exp
+
+RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.{ll,c,cpp}]]

Added: poolalloc/trunk/test/type_checks/correct/vprintf.c
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/test/type_checks/correct/vprintf.c?rev=132091&view=auto
==============================================================================
--- poolalloc/trunk/test/type_checks/correct/vprintf.c (added)
+++ poolalloc/trunk/test/type_checks/correct/vprintf.c Wed May 25 17:32:13 2011
@@ -0,0 +1,31 @@
+/*
+ * Build into bitcode
+ * RUN: llvm-gcc -O0 %s --emit-llvm -c -o %t.bc
+ * RUN: adsaopt -internalize -mem2reg -typechecks %t.bc -o %t.tc.bc
+ * RUN: tc-link %t.tc.bc -o %t.tc1.bc
+ * RUN: llc %t.tc1.bc -o %t.tc1.s
+ * RUN: llvm-gcc %t.tc1.s -o %t.tc2
+ * Execute
+ * RUN: %t.tc2 >& %t.tc.out
+ */
+/* vprintf example */
+#include <stdio.h>
+#include <stdarg.h>
+
+void WriteFormatted (char * format, ...)
+{
+  va_list args;
+  va_start (args, format);
+  int a = va_arg(args, int);
+  printf("%d\n", a);
+  vprintf (format, args);
+  va_end (args);
+}
+
+int main ()
+{
+  WriteFormatted ("Call with %d variable argument.\n",55, 1);
+  WriteFormatted ("Call with %d variable %s.\n",55, 2,"arguments");
+
+  return 0;
+}

Added: poolalloc/trunk/test/type_checks/correct/vprintf1.c
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/test/type_checks/correct/vprintf1.c?rev=132091&view=auto
==============================================================================
--- poolalloc/trunk/test/type_checks/correct/vprintf1.c (added)
+++ poolalloc/trunk/test/type_checks/correct/vprintf1.c Wed May 25 17:32:13 2011
@@ -0,0 +1,29 @@
+/*
+ * Build into bitcode
+ * RUN: llvm-gcc -O0 %s --emit-llvm -c -o %t.bc
+ * RUN: adsaopt -internalize -mem2reg -typechecks %t.bc -o %t.tc.bc
+ * RUN: tc-link %t.tc.bc -o %t.tc1.bc
+ * RUN: llc %t.tc1.bc -o %t.tc1.s
+ * RUN: llvm-gcc %t.tc1.s -o %t.tc2
+ * Execute
+ * RUN: %t.tc2 >& %t.tc.out
+ */
+/* vprintf example */
+#include <stdio.h>
+#include <stdarg.h>
+
+void WriteFormatted (char * format, ...)
+{
+  va_list args;
+  va_start (args, format);
+  vprintf (format, args);
+  va_end (args);
+}
+
+int main ()
+{
+  WriteFormatted ("Call with %d variable argument.\n",1);
+  WriteFormatted ("Call with %d variable %s.\n",2,"arguments");
+
+  return 0;
+}

Added: poolalloc/trunk/test/type_checks/error/IntUnion.c
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/test/type_checks/error/IntUnion.c?rev=132091&view=auto
==============================================================================
--- poolalloc/trunk/test/type_checks/error/IntUnion.c (added)
+++ poolalloc/trunk/test/type_checks/error/IntUnion.c Wed May 25 17:32:13 2011
@@ -0,0 +1,37 @@
+/*
+ * Build into bitcode
+ * RUN: llvm-gcc -O0 %s --emit-llvm -c -o %t.bc
+ * RUN: adsaopt -internalize -mem2reg -typechecks %t.bc -o %t.tc.bc
+ * RUN: tc-link %t.tc.bc -o %t.tc1.bc
+ * RUN: llc %t.tc1.bc -o %t.tc1.s
+ * RUN: llvm-gcc %t.tc1.s -o %t.tc2
+ * Execute
+ * RUN: %t.tc2 >& %t.tc.out
+ * ;XFAIL:*
+ */
+
+int first_ones[65536];
+
+int FirstOne(unsigned long arg1)
+{
+  union doub {
+    unsigned short i[4];
+    unsigned long  d;
+  };
+  union doub x;
+  x.d=arg1;
+  if (x.i[3])
+    return (first_ones[x.i[3]]);
+  if (x.i[2])
+    return (first_ones[x.i[2]]+16);
+  if (x.i[1])
+    return (first_ones[x.i[1]]+32);
+  if (x.i[0])
+    return (first_ones[x.i[0]]+48);
+  return(64);
+}
+
+int main() {
+  int a = FirstOne(12345678);
+  return 0;
+}

Added: poolalloc/trunk/test/type_checks/error/alloc.c
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/test/type_checks/error/alloc.c?rev=132091&view=auto
==============================================================================
--- poolalloc/trunk/test/type_checks/error/alloc.c (added)
+++ poolalloc/trunk/test/type_checks/error/alloc.c Wed May 25 17:32:13 2011
@@ -0,0 +1,41 @@
+/*
+ * Build into bitcode
+ * RUN: llvm-gcc -O0 %s --emit-llvm -c -o %t.bc
+ * RUN: adsaopt -internalize -mem2reg -typechecks %t.bc -o %t.tc.bc
+ * RUN: tc-link %t.tc.bc -o %t.tc1.bc
+ * RUN: llc %t.tc1.bc -o %t.tc1.s
+ * RUN: llvm-gcc %t.tc1.s -o %t.tc2
+ * Execute
+ * RUN: %t.tc2 >& %t.tc.out
+ * ;XFAIL:*
+ */
+#include<stdlib.h>
+
+void **alloc_matrix (int nrmin, int nrmax, int ncmin, int ncmax,
+                     size_t elsize) {
+
+
+  int i;
+  char **cptr;
+
+  cptr = (char **) malloc ((nrmax - nrmin + 1) * sizeof (char *));
+  cptr -= nrmin;
+  for (i=nrmin;i<=nrmax;i++) {
+    cptr[i] = (char *) malloc ((ncmax - ncmin + 1) * elsize);
+    cptr[i] -= ncmin * elsize / sizeof(char);  /* sizeof(char) = 1 */
+  }
+  return ((void **) cptr);
+}
+
+int main() {
+  int i;
+  int j;
+  int pins_per_clb = 5;
+  int ** pinloc = (int **) alloc_matrix (0, 3, 0, pins_per_clb-1, sizeof (int));
+
+   for (i=0;i<=3;i++)
+     for (j=0;j<pins_per_clb;j++)  {
+       pinloc[i][j] = 0;
+     }
+
+}

Added: poolalloc/trunk/test/type_checks/error/dg.exp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/test/type_checks/error/dg.exp?rev=132091&view=auto
==============================================================================
--- poolalloc/trunk/test/type_checks/error/dg.exp (added)
+++ poolalloc/trunk/test/type_checks/error/dg.exp Wed May 25 17:32:13 2011
@@ -0,0 +1,3 @@
+load_lib llvm.exp
+
+RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.{ll,c,cpp}]]

Added: poolalloc/trunk/test/type_checks/error/testEndian.c
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/test/type_checks/error/testEndian.c?rev=132091&view=auto
==============================================================================
--- poolalloc/trunk/test/type_checks/error/testEndian.c (added)
+++ poolalloc/trunk/test/type_checks/error/testEndian.c Wed May 25 17:32:13 2011
@@ -0,0 +1,34 @@
+/*
+ * Build into bitcode
+ * RUN: llvm-gcc -O0 %s --emit-llvm -c -o %t.bc
+ * RUN: adsaopt -internalize -mem2reg -typechecks %t.bc -o %t.tc.bc
+ * RUN: tc-link %t.tc.bc -o %t.tc1.bc
+ * RUN: llc %t.tc1.bc -o %t.tc1.s
+ * RUN: llvm-gcc %t.tc1.s -o %t.tc2
+ * Execute
+ * RUN: %t.tc2 >& %t.tc.out
+ * ;XFAIL:*
+ */
+
+#include<stdio.h>
+
+
+typedef unsigned char byte;    //!< byte type definition
+
+int testEndian()
+{
+  short s;
+  byte *p;
+
+  p=(byte*)&s;
+
+  s=1;
+
+  return (*p==0);
+}
+
+int main() {
+  testEndian();
+  return 0;
+}
+





More information about the llvm-commits mailing list