diff options
author | Chris Lattner <sabre@nondot.org> | 2004-05-23 21:24:50 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2004-05-23 21:24:50 +0000 |
commit | 4cb1f3c10d6de2733099cd04a0a11b44b70c67b1 (patch) | |
tree | 20cb72ae0642da0ae92c13c5e4d1f4f35c08093a /test/CodeGen/Generic/GC | |
parent | 99c59e8e217cd08bc53f7a260dce6c7a66b583f9 (diff) | |
download | external_llvm-4cb1f3c10d6de2733099cd04a0a11b44b70c67b1.zip external_llvm-4cb1f3c10d6de2733099cd04a0a11b44b70c67b1.tar.gz external_llvm-4cb1f3c10d6de2733099cd04a0a11b44b70c67b1.tar.bz2 |
Add a simple testcase for garbage collection support
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13697 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGen/Generic/GC')
-rw-r--r-- | test/CodeGen/Generic/GC/alloc_loop.ll | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/test/CodeGen/Generic/GC/alloc_loop.ll b/test/CodeGen/Generic/GC/alloc_loop.ll new file mode 100644 index 0000000..de9d475 --- /dev/null +++ b/test/CodeGen/Generic/GC/alloc_loop.ll @@ -0,0 +1,52 @@ +implementation + +declare sbyte* %llvm_gc_allocate(uint) +declare void %llvm_gc_initialize() + +declare void %llvm.gcroot(sbyte**, sbyte*) +declare void %llvm.gcwrite(sbyte*, sbyte**) + +int %main() { +entry: + %A = alloca sbyte* + %B = alloca sbyte** + + call void %llvm_gc_initialize() + + ;; void *A; + call void %llvm.gcroot(sbyte** %A, sbyte* null) + + ;; A = gcalloc(10); + %Aptr = call sbyte* %llvm_gc_allocate(uint 10) + store sbyte* %Aptr, sbyte** %A + + ;; void **B; + %tmp.1 = cast sbyte*** %B to sbyte ** + call void %llvm.gcroot(sbyte** %tmp.1, sbyte* null) + + ;; B = gcalloc(4); + %B = call sbyte* %llvm_gc_allocate(uint 8) + %tmp.2 = cast sbyte* %B to sbyte** + store sbyte** %tmp.2, sbyte*** %B + + ;; *B = A; + %B.1 = load sbyte*** %B + %A.1 = load sbyte** %A + call void %llvm.gcwrite(sbyte* %A.1, sbyte** %B.1) + + br label %AllocLoop + +AllocLoop: + %i = phi uint [ 0, %entry ], [ %indvar.next, %AllocLoop ] + ;; Allocated mem: allocated memory is immediately dead. + call sbyte* %llvm_gc_allocate(uint 100) + + %indvar.next = add uint %i, 1 + %exitcond = seteq uint %indvar.next, 10000000 + br bool %exitcond, label %Exit, label %AllocLoop + +Exit: + ret int 0 +} + +declare void %__main() |