summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-07-25 20:53:58 +0000
committerChris Lattner <sabre@nondot.org>2003-07-25 20:53:58 +0000
commite41fb36b261da177701487682f2e5805bd20bfa6 (patch)
tree9580fb62d0fac8d48292a4f133d12042a0042695 /test
parente7e221ad2417600457fac2eddedcb216c8f77924 (diff)
downloadllvm-e41fb36b261da177701487682f2e5805bd20bfa6.tar.gz
llvm-e41fb36b261da177701487682f2e5805bd20bfa6.tar.bz2
llvm-e41fb36b261da177701487682f2e5805bd20bfa6.tar.xz
Checkin of Vikram's ggfuncptr.c test adapted for automatic checking
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7324 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r--test/Analysis/DSGraph/GlobalsGraphFuncPtr.ll66
1 files changed, 66 insertions, 0 deletions
diff --git a/test/Analysis/DSGraph/GlobalsGraphFuncPtr.ll b/test/Analysis/DSGraph/GlobalsGraphFuncPtr.ll
new file mode 100644
index 0000000000..cb974a97e9
--- /dev/null
+++ b/test/Analysis/DSGraph/GlobalsGraphFuncPtr.ll
@@ -0,0 +1,66 @@
+; 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
+;
+; RUN: analyze %s -datastructure-gc -dsgc-check-flags=KnownPtr:S,UnknownPtr:SI -dsgc-dspass=bu
+
+%Z = internal global int 0
+%X = internal global int 0
+%M = internal global int 0
+%.str_1 = internal constant [9 x sbyte] c"&Z = %p\0A\00"
+
+implementation
+
+declare int %printf(sbyte*, ...)
+declare void %exit_dummy(int*)
+
+internal void %makeCalls(void (int*)* %GpKnown.1, void (int*)* %GpUnknown.1,
+ int* %GpKnownPtr, int* %GpUnknownPtr) {
+ %tmp.0 = load int* %Z
+ %tmp.1.not = setne int %tmp.0, 0
+ br bool %tmp.1.not, label %else, label %then
+
+then:
+ ; pass to exit_dummy: never resolved
+ call void %GpUnknown.1( int* %GpUnknownPtr )
+ %tmp.61 = load int* %Z
+ %inc1 = add int %tmp.61, 1
+ store int %inc1, int* %Z
+ %tmp.71 = call int (sbyte*, ...)* %printf( sbyte* getelementptr ([9 x sbyte]* %.str_1, long 0, long 0), int* %Z )
+ ret void
+
+else:
+ ; pass to knownF: resolved in main
+ call void %GpKnown.1( int* %GpKnownPtr )
+ %tmp.6 = load int* %Z
+ %inc = add int %tmp.6, 1
+ store int %inc, int* %Z
+
+ ; "known external": resolved here
+ %tmp.7 = call int (sbyte*, ...)* %printf( sbyte* getelementptr ([9 x sbyte]* %.str_1, long 0, long 0), int* %Z )
+ ret void
+}
+
+internal void %knownF(int* %Y.1) {
+ %tmp.1 = seteq int* %Y.1, null
+ br bool %tmp.1, label %then, label %UnifiedExitNode
+
+then:
+ call void %knownF( int* %Y.1 ) ; direct call to self: resolved here
+ br label %UnifiedExitNode
+
+UnifiedExitNode:
+ ret void
+}
+
+int %main(int %argc.1) {
+ %KnownPtr = alloca int
+ %UnknownPtr = alloca int
+ store int 1, int* %Z
+ call void %makeCalls( void (int*)* %knownF, void (int*)* %exit_dummy,
+ int* %KnownPtr, int* %UnknownPtr )
+ ret int 0
+}
+