1 ; RUN: llc -mtriple=x86_64 < %s
3 declare ptr @llvm_gc_allocate(i32)
4 declare void @llvm_gc_initialize(i32)
6 declare void @llvm.gcroot(ptr, ptr)
7 declare void @llvm.gcwrite(ptr, ptr, ptr)
9 define i32 @main() gc "shadow-stack" {
14 call void @llvm_gc_initialize(i32 1048576) ; Start with 1MB heap
17 call void @llvm.gcroot(ptr %A, ptr null)
20 %Aptr = call ptr @llvm_gc_allocate(i32 10)
21 store ptr %Aptr, ptr %A
24 call void @llvm.gcroot(ptr %B, ptr null)
27 %B.upgrd.1 = call ptr @llvm_gc_allocate(i32 8)
28 store ptr %B.upgrd.1, ptr %B
31 %B.1 = load ptr, ptr %B
32 %A.1 = load ptr, ptr %A
33 call void @llvm.gcwrite(ptr %A.1, ptr %B.upgrd.1, ptr %B.1)
38 %i = phi i32 [ 0, %entry ], [ %indvar.next, %AllocLoop ]
39 ;; Allocated mem: allocated memory is immediately dead.
40 call ptr @llvm_gc_allocate(i32 100)
42 %indvar.next = add i32 %i, 1
43 %exitcond = icmp eq i32 %indvar.next, 10000000
44 br i1 %exitcond, label %Exit, label %AllocLoop
50 declare void @__main()