aboutsummaryrefslogtreecommitdiffstats
path: root/test/DSGraphs
diff options
context:
space:
mode:
authorVikram S. Adve <vadve@cs.uiuc.edu>2003-07-16 21:48:38 +0000
committerVikram S. Adve <vadve@cs.uiuc.edu>2003-07-16 21:48:38 +0000
commit71b35cd0fe1c17255e1c49af3e8f592725ed1721 (patch)
tree7a016441072febce8ba2af14f57dc0f4d0e8e967 /test/DSGraphs
parenta53e3da92c6dea476c58f99da6d3c5f75be38adc (diff)
downloadexternal_llvm-71b35cd0fe1c17255e1c49af3e8f592725ed1721.zip
external_llvm-71b35cd0fe1c17255e1c49af3e8f592725ed1721.tar.gz
external_llvm-71b35cd0fe1c17255e1c49af3e8f592725ed1721.tar.bz2
Tests for globals with different kinds of behavior in DS Analysis.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7191 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/DSGraphs')
-rw-r--r--test/DSGraphs/ggcollapse.c32
-rw-r--r--test/DSGraphs/ggfuncptr.c34
2 files changed, 66 insertions, 0 deletions
diff --git a/test/DSGraphs/ggcollapse.c b/test/DSGraphs/ggcollapse.c
new file mode 100644
index 0000000..c055caf
--- /dev/null
+++ b/test/DSGraphs/ggcollapse.c
@@ -0,0 +1,32 @@
+#include <stdio.h>
+
+typedef struct Tree_struct {
+ int data;
+ struct Tree_struct *left, *right;
+} Tree;
+
+static Tree T1, T2, T3, T4, T5;
+static Tree *Root, *ANode;
+static int N = 4107;
+
+/* forces *Tb->right to be collapsed */
+void makeMore(Tree* Ta, Tree* Tb)
+{
+ Ta->left = &T1;
+ Ta->right = &T2;
+ Tb->left = &T4;
+ Tb->right = (Tree*) (((char*) &T5) + 5); /* point to fifth byte of T5 */
+}
+
+void makeRoots()
+{
+ T1.left = &T2;
+ makeMore(&T1, &T3);
+}
+
+int main()
+{
+ makeRoots();
+ T3.right = &T4;
+ printf("T3.data = %d\n", T3.data);
+}
diff --git a/test/DSGraphs/ggfuncptr.c b/test/DSGraphs/ggfuncptr.c
new file mode 100644
index 0000000..9349124
--- /dev/null
+++ b/test/DSGraphs/ggfuncptr.c
@@ -0,0 +1,34 @@
+/* Test resolvable and unresolvable calls through function pointers:
+ * -- both should be retained in function graphs until resolved or until main
+ * -- former should get resolved in or before main() and never appear in GG
+ * -- latter should remain unresolved in main() and copied to GG
+ * -- globals in GG pointed to by latter should be marked I, but not other nodes
+ */
+
+#include <stdlib.h>
+
+extern void exit_dummy(int*);
+
+static int X, M, Z;
+
+void makeCalls(void(*GpKnown)(int*), void(*GpUnknown)(int*))
+{
+ if (Z == 0) GpUnknown(&X); /* pass to exit_dummy: never resolved */
+ else GpKnown(&M); /* pass to knownF: resolved in main*/
+ ++Z;
+ printf("&Z = %p\n", &Z); /* "known external": resolved here */
+}
+
+void knownF(int* Y)
+{
+ if (Y == 0) knownF(Y); /* direct call to self: resolved here */
+}
+
+int main(int argc, char** argv)
+{
+ void(*GpKnown)(int*) = knownF;
+ void(*GpUnknown)(int*) = exit_dummy;
+ Z = argc;
+ makeCalls(GpKnown, GpUnknown);
+ return 0;
+}