[llvm-commits] [poolalloc] r114011 - /poolalloc/trunk/test/pa/regression/2010-09-14-Fptr_helper.c

Will Dietz wdietz2 at illinois.edu
Wed Sep 15 12:43:10 PDT 2010


Author: wdietz2
Date: Wed Sep 15 14:43:03 2010
New Revision: 114011

URL: http://llvm.org/viewvc/llvm-project?rev=114011&view=rev
Log:
Added duplicate of '2010-09-14-Fptr' test case, illustrating that the issue
isn't just main-specific, and to catch fixes that attempt to classify it as such.

Added:
    poolalloc/trunk/test/pa/regression/2010-09-14-Fptr_helper.c

Added: poolalloc/trunk/test/pa/regression/2010-09-14-Fptr_helper.c
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/test/pa/regression/2010-09-14-Fptr_helper.c?rev=114011&view=auto
==============================================================================
--- poolalloc/trunk/test/pa/regression/2010-09-14-Fptr_helper.c (added)
+++ poolalloc/trunk/test/pa/regression/2010-09-14-Fptr_helper.c Wed Sep 15 14:43:03 2010
@@ -0,0 +1,50 @@
+// This is the same as 2010-09-Fptr.c, but does it with a helper
+// to verify/illustrate that the issue is /not/ "main"-specific.
+// (and to catch fixes that attempt to fix it as such)
+/* 
+ * Build this file into bitcode and run poolalloc on it
+ * RUN: llvm-gcc -O0 %s --emit-llvm -c -o %t.bc
+ * RUN: paopt %t.bc -poolalloc -o %t.pa.bc 2>&1
+ * RUN: llc %t.pa.bc -o %t.pa.s
+ * RUN: llvm-gcc %t.pa.s -o %t.pa
+ *
+ * Build the program without poolalloc:
+ * RUN: llvm-gcc -o %t.native %s
+ *
+ * Execute the program to verify it's correct:
+ * RUN: ./%t.pa >& %t.pa.out
+ * RUN: /%t.native >& %t.native.out
+ *
+ * Diff the two executions
+ * RUN: diff %t.pa.out %t.native.out
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <assert.h>
+
+#define MAGIC 0xBEEF
+
+typedef void (*FP)(int *);
+
+void callee(int * v)
+{
+  printf("*v: %d\n", *v);
+  assert(*v == MAGIC);
+}
+
+FP getFP()
+{
+  return callee;
+}
+
+void helper(int *v)
+{
+  getFP()(v);
+}
+
+int main(int argc, char ** argv)
+{
+  int val = MAGIC;
+  helper(&val);
+}





More information about the llvm-commits mailing list