aboutsummaryrefslogtreecommitdiffstats
path: root/test/LLC/badfuncptr.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/LLC/badfuncptr.c')
-rw-r--r--test/LLC/badfuncptr.c74
1 files changed, 74 insertions, 0 deletions
diff --git a/test/LLC/badfuncptr.c b/test/LLC/badfuncptr.c
new file mode 100644
index 0000000..8da7fbe
--- /dev/null
+++ b/test/LLC/badfuncptr.c
@@ -0,0 +1,74 @@
+/*
+ * Program: llc
+ *
+ * Test Name: badfuncptr.c
+ *
+ * Test Problem:
+ * Indirect call via function pointer is mishandled in reg. alloc.
+ * The indirect call address was allocated the same register as the
+ * first outgoing argument, so it was overwritten before the call.
+ *
+ * Test Resolution:
+ * In PhyRegAlloc.cpp, mark the live range for the indirect call
+ * address as having a Call Interference. This has to be done
+ * as a special case since it may not be live after the call.
+ *
+ * Resolution Status:
+ * Fixed on 3/29/02 -- Adve.
+ */
+/* For copyright information, see olden_v1.0/COPYRIGHT */
+
+#include <stdlib.h>
+/* #include "hash.h" */
+/*--------*/
+/* hash.h */
+/*--------*/
+/* For copyright information, see olden_v1.0/COPYRIGHT */
+
+#include "stdio.h"
+
+typedef struct hash_entry {
+ unsigned int key;
+ void *entry;
+ struct hash_entry *next;
+} *HashEntry;
+
+typedef struct hash {
+ HashEntry *array;
+ int (*mapfunc)(unsigned int);
+ int size;
+} *Hash;
+
+Hash MakeHash(int size, int (*map)(unsigned int));
+void *HashLookup(unsigned int key, Hash hash);
+void HashInsert(void *entry,unsigned int key, Hash hash);
+void HashDelete(unsigned int key, Hash hash);
+/*--------*/
+/* END hash.h */
+/*--------*/
+
+#define assert(num,a) if (!(a)) {printf("Assertion failure:%d in hash\n",num); exit(-1);}
+
+void *HashLookup(unsigned int key, Hash hash)
+{
+ int j;
+ HashEntry ent;
+
+ j = (hash->mapfunc)(key); /* 14% miss in hash->mapfunc */
+ assert(1,j>=0);
+ assert(2,j<hash->size);
+ for (ent = hash->array[j]; /* 17% miss in hash->array[j] */ /* adt_pf can't detect :( */
+ ent && /* 47% miss in ent->key */ /* adt_pf can detect :) */
+ ent->key!=key;
+ ent=ent->next); /* 8% miss in ent->next */ /* adt_pf can detect :) */
+ if (ent) return ent->entry;
+ return NULL;
+}
+
+/* essentially dummy main so testing does not fail */
+int
+main()
+{
+ printf("&HashLookup = 0x%p\n", HashLookup);
+ return 0;
+}