Setting GlobalDirective in TargetAsmInfo by default rather than
[oota-llvm.git] / test / CodeGen / Generic / GC / simple_ocaml.ll
1 ; RUN: llvm-as < %s | llc | grep caml.*__frametable
2 ; RUN: llvm-as < %s | llc -march=x86 | grep {movl       .0}
3
4 %struct.obj = type { i8*, %struct.obj* }
5
6 define %struct.obj* @fun(%struct.obj* %head) gc "ocaml" {
7 entry:
8         %gcroot.0 = alloca i8*
9         %gcroot.1 = alloca i8*
10         
11         call void @llvm.gcroot(i8** %gcroot.0, i8* null)
12         call void @llvm.gcroot(i8** %gcroot.1, i8* null)
13         
14         %local.0 = bitcast i8** %gcroot.0 to %struct.obj**
15         %local.1 = bitcast i8** %gcroot.1 to %struct.obj**
16
17         store %struct.obj* %head, %struct.obj** %local.0
18         br label %bb.loop
19 bb.loop:
20         %t0 = load %struct.obj** %local.0
21         %t1 = getelementptr %struct.obj* %t0, i32 0, i32 1
22         %t2 = bitcast %struct.obj* %t0 to i8*
23         %t3 = bitcast %struct.obj** %t1 to i8**
24         %t4 = call i8* @llvm.gcread(i8* %t2, i8** %t3)
25         %t5 = bitcast i8* %t4 to %struct.obj*
26         %t6 = icmp eq %struct.obj* %t5, null
27         br i1 %t6, label %bb.loop, label %bb.end
28 bb.end:
29         %t7 = malloc %struct.obj
30         store %struct.obj* %t7, %struct.obj** %local.1
31         %t8 = bitcast %struct.obj* %t7 to i8*
32         %t9 = load %struct.obj** %local.0
33         %t10 = getelementptr %struct.obj* %t9, i32 0, i32 1
34         %t11 = bitcast %struct.obj* %t9 to i8*
35         %t12 = bitcast %struct.obj** %t10 to i8**
36         call void @llvm.gcwrite(i8* %t8, i8* %t11, i8** %t12)
37         ret %struct.obj* %t7
38 }
39
40 declare void @llvm.gcroot(i8** %value, i8* %tag)
41 declare void @llvm.gcwrite(i8* %value, i8* %obj, i8** %field)
42 declare i8* @llvm.gcread(i8* %obj, i8** %field)