2 ; REQUIRES: default_triple
5 declare i8* @llvm_gc_allocate(i32)
6 declare void @llvm_gc_initialize(i32)
8 declare void @llvm.gcroot(i8**, i8*)
9 declare void @llvm.gcwrite(i8*, i8*, i8**)
11 define i32 @main() gc "shadow-stack" {
16 call void @llvm_gc_initialize(i32 1048576) ; Start with 1MB heap
19 call void @llvm.gcroot(i8** %A, i8* null)
22 %Aptr = call i8* @llvm_gc_allocate(i32 10)
23 store i8* %Aptr, i8** %A
26 %tmp.1 = bitcast i8*** %B to i8**
27 call void @llvm.gcroot(i8** %tmp.1, i8* null)
30 %B.upgrd.1 = call i8* @llvm_gc_allocate(i32 8)
31 %tmp.2 = bitcast i8* %B.upgrd.1 to i8**
32 store i8** %tmp.2, i8*** %B
35 %B.1 = load i8**, i8*** %B
36 %A.1 = load i8*, i8** %A
37 call void @llvm.gcwrite(i8* %A.1, i8* %B.upgrd.1, i8** %B.1)
42 %i = phi i32 [ 0, %entry ], [ %indvar.next, %AllocLoop ]
43 ;; Allocated mem: allocated memory is immediately dead.
44 call i8* @llvm_gc_allocate(i32 100)
46 %indvar.next = add i32 %i, 1
47 %exitcond = icmp eq i32 %indvar.next, 10000000
48 br i1 %exitcond, label %Exit, label %AllocLoop
54 declare void @__main()