[llvm-commits] [poolalloc] r106341 - in /poolalloc/trunk/test/var_arg: basic.c extern.c multiple_callee.c multiple_callee_nomodref.c va_copy.c

Will Dietz wdietz2 at illinois.edu
Fri Jun 18 15:56:58 PDT 2010


Author: wdietz2
Date: Fri Jun 18 17:56:58 2010
New Revision: 106341

URL: http://llvm.org/viewvc/llvm-project?rev=106341&view=rev
Log:
Improve var_arg tests (test va_copy, extern calls, modref behavior)
clean up multiple_callee, reduce test case to just -gvn
remove 2>/dev/null, the dsa passes shouldn't print to stderr on success

Added:
    poolalloc/trunk/test/var_arg/extern.c
    poolalloc/trunk/test/var_arg/multiple_callee_nomodref.c
    poolalloc/trunk/test/var_arg/va_copy.c
Modified:
    poolalloc/trunk/test/var_arg/basic.c
    poolalloc/trunk/test/var_arg/multiple_callee.c

Modified: poolalloc/trunk/test/var_arg/basic.c
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/test/var_arg/basic.c?rev=106341&r1=106340&r2=106341&view=diff
==============================================================================
--- poolalloc/trunk/test/var_arg/basic.c (original)
+++ poolalloc/trunk/test/var_arg/basic.c Fri Jun 18 17:56:58 2010
@@ -6,7 +6,7 @@
 //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 - 2>/dev/null | lli > %t.out
+//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

Added: poolalloc/trunk/test/var_arg/extern.c
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/test/var_arg/extern.c?rev=106341&view=auto
==============================================================================
--- poolalloc/trunk/test/var_arg/extern.c (added)
+++ poolalloc/trunk/test/var_arg/extern.c Fri Jun 18 17:56:58 2010
@@ -0,0 +1,44 @@
+#include <stdio.h>
+//This tests mod/ref behavior of extern var-arg functions
+//We *should* special-case those we know about...
+//..but for now we don't:
+//XFAIL: *
+
+//--build the code into a .bc
+//RUN: llvm-gcc -c -O0 %s -S --emit-llvm -o - | llvm-as > %t.bc
+//--check if ds-aa breaks, or breaks opts
+//RUN: dsaopt %t.bc -ds-aa -O3 -o /dev/null
+//--check properties of this particular test
+//RUN: dsaopt %t.bc -ds-aa -aa-eval -o /dev/null \
+//  RUN: -print-all-alias-modref-info >& %t.aa
+
+//Unknown external function
+//Everything going into this should be assumed to be mod/ref'd
+extern "C" void unknown_extern(int, ...);
+
+int main()
+{
+  int stack_val1 = 5;
+  int stack_val2 = 10;
+  int stack_val3 = 15;
+  int stack_val4 = 20;
+  int stack_val5 = 25;
+  int stack_val6 = 30;
+
+  //We should special case this--offhand, modref might be best
+  //RUN: cat %t.aa | grep {Ptr:.*stack_val1.*scanf} | grep {^\[ \]*ModRef}
+  //RUN: cat %t.aa | grep {Ptr:.*stack_val2.*scanf} | grep {^\[ \]*ModRef}
+  scanf("%d, %d\n", &stack_val1, stack_val2);
+
+  //We should special case this--ref's vars, not mod
+  //RUN: cat %t.aa | grep {Ptr:.*stack_val3.*printf} | grep {^\[ \]*Ref}
+  //RUN: cat %t.aa | grep {Ptr:.*stack_val4.*printf} | grep {^\[ \]*Ref}
+  printf("%d, %d\n", &stack_val3, &stack_val4);
+
+  //unknown--this these should be marked modref
+  //RUN: cat %t.aa | grep {Ptr:.*stack_val5.*unknown_extern} | grep {^\[ \]*ModRef}
+  //RUN: cat %t.aa | grep {Ptr:.*stack_val6.*unknown_extern} | grep {^\[ \]*ModRef}
+  unknown_extern( 0, &stack_val5, &stack_val6);
+
+  return 0;
+}

Modified: poolalloc/trunk/test/var_arg/multiple_callee.c
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/test/var_arg/multiple_callee.c?rev=106341&r1=106340&r2=106341&view=diff
==============================================================================
--- poolalloc/trunk/test/var_arg/multiple_callee.c (original)
+++ poolalloc/trunk/test/var_arg/multiple_callee.c Fri Jun 18 17:56:58 2010
@@ -11,10 +11,11 @@
 //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 -instcombine -ds-aa -gvn -ds-aa -dce -o - 2>/dev/null | lli > %t.out
+//RUN: dsaopt %t.bc -ds-aa -gvn -o - | lli > %t.out
 //RUN: diff %t.refout %t.out
 //--check properties of this particular test
-//RUN: dsaopt %t.bc -ds-aa -aa-eval -print-all-alias-modref-info >& %t.aa
+//RUN: dsaopt %t.bc -ds-aa -aa-eval -o /dev/null \
+//  RUN: -print-all-alias-modref-info >& %t.aa
 //ds-aa should tell us that assign modifies p1
 //RUN: cat %t.aa | grep {Ptr:.*p1.*@assign} | grep {^\[ \]*ModRef}
 //ds-aa should tell us that assign does something to p2

Added: poolalloc/trunk/test/var_arg/multiple_callee_nomodref.c
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/test/var_arg/multiple_callee_nomodref.c?rev=106341&view=auto
==============================================================================
--- poolalloc/trunk/test/var_arg/multiple_callee_nomodref.c (added)
+++ poolalloc/trunk/test/var_arg/multiple_callee_nomodref.c Fri Jun 18 17:56:58 2010
@@ -0,0 +1,65 @@
+#include <stdarg.h>
+//This tests having multiple parameters
+//In particular, this verifies that dsa doesn't unnecessarily
+//set the mod/ref flag for functions.
+
+//What to check:
+//'val' should alias stack_val and stack_val2
+//'p1' and 'p2' should alias
+//'p1' and 'p2' should be modref'd by assign
+//(accordingly stack_val/stack_val2 are modref'd)
+//
+//--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 -gvn -o - | lli > %t.out
+//RUN: diff %t.refout %t.out
+//--check properties of this particular test
+//RUN: dsaopt %t.bc -ds-aa -aa-eval -o /dev/null \
+//  RUN: -print-all-alias-modref-info >& %t.aa
+//ds-aa should tell us that assign doesn't mod/ref p1
+//RUN: cat %t.aa | grep {Ptr:.*p1.*@assign} | grep NoModRef
+//ds-aa should tell us that assign doesn't mod/ref p2
+//RUN: cat %t.aa | grep {Ptr:.*p2.*@assign} | grep NoModRef
+
+
+static int assign( int count, ... )
+{
+  va_list ap;
+  va_start( ap, count );
+
+  int sum = 0;
+  int i = 1;
+  int ** old = va_arg( ap, int** );
+  for ( ; i < count; ++i )
+  {
+    int **val = va_arg( ap, int** );
+    //Unlike 'multiple_callee.c', don't mod/ref the value
+    //*old = *val;
+    old = val;
+  }
+
+  va_end( ap );
+
+  return sum;
+}
+
+int main()
+{
+  int stack_val = 5;
+  int stack_val2 = 10;
+
+  int * p1 = &stack_val;
+  int * p2 = &stack_val2;
+
+  //Doesn't mod/ref either param
+  assign( 2, &p1, &p2 );
+
+  //p1 is still intact, pointing to stack_val
+  if ( p1 == &stack_val )
+  {
+    return 0;
+  }
+  return -1;
+}

Added: poolalloc/trunk/test/var_arg/va_copy.c
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/test/var_arg/va_copy.c?rev=106341&view=auto
==============================================================================
--- poolalloc/trunk/test/var_arg/va_copy.c (added)
+++ poolalloc/trunk/test/var_arg/va_copy.c Fri Jun 18 17:56:58 2010
@@ -0,0 +1,46 @@
+#include <stdarg.h>
+#include <stdio.h>
+//This tests va_copy, which should just merge it's arguments...
+
+//--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 - 2>/dev/null | lli > %t.out
+//RUN: diff %t.refout %t.out
+//--check properties of this particular test
+//RUN: dsaopt %t.bc -ds-aa -aa-eval -o /dev/null \
+//  RUN: -print-all-alias-modref-info >& %t.aa
+//FIXME: Find a better way to get at this information...
+//--get the registers loaded from val1 and val2
+//RUN: llvm-dis %t.bc -f -o %t.ll
+//RUN: cat %t.ll | grep load | grep "@val1" | sed -e {s/ =.*$//} -e {s/^\[ \]*//} > %t.val1
+//RUN: cat %t.ll | grep load | grep "@val2" | sed -e {s/ =.*$//} -e {s/^\[ \]*//} > %t.val2
+//--verify that they alias (they're int*'s)
+//RUN: cat %t.aa | grep -f %t.val1 | grep -f %t.val2 | grep {^\[ \]*MayAlias}
+
+int *val1, *val2;
+
+static int get( int unused, ... )
+{
+  va_list ap, ap_copy;
+  va_start( ap, unused );
+  va_copy( ap_copy, ap );
+
+  val1 = va_arg( ap, int* );
+  va_end( ap );
+
+  val2 = va_arg( ap_copy, int* );
+  va_end( ap_copy );
+
+  return *val1 - *val2;
+}
+
+int main()
+{
+  int stack_val = 5;
+
+  int ret = get( 0, &stack_val );
+
+  return ret;
+}





More information about the llvm-commits mailing list