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

Will Dietz wdietz2 at illinois.edu
Wed Sep 15 12:14:03 PDT 2010


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

URL: http://llvm.org/viewvc/llvm-project?rev=113999&view=rev
Log:
Added (failing) test case for indirect call to cloned functions.
Illustrates issue where an original function can indirectly call
a cloned function as if it were an original (making the arguments wrong).

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

Added: poolalloc/trunk/test/pa/regression/2010-09-14-Fptr.c
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/test/pa/regression/2010-09-14-Fptr.c?rev=113999&view=auto
==============================================================================
--- poolalloc/trunk/test/pa/regression/2010-09-14-Fptr.c (added)
+++ poolalloc/trunk/test/pa/regression/2010-09-14-Fptr.c Wed Sep 15 14:14:03 2010
@@ -0,0 +1,42 @@
+/* 
+ * 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;
+}
+
+int main(int argc, char ** argv)
+{
+  int val = MAGIC;
+  getFP()(&val);
+}





More information about the llvm-commits mailing list