1 ; RUN: llvm-as < %s | llc
4 declare i8* @llvm_gc_allocate(i32)
5 declare void @llvm_gc_initialize(i32)
7 declare void @llvm.gcroot(i8**, i8*)
8 declare void @llvm.gcwrite(i8*, i8*, i8**)
10 define i32 @main() gc "shadow-stack" {
15 call void @llvm_gc_initialize(i32 1048576) ; Start with 1MB heap
18 call void @llvm.gcroot(i8** %A, i8* null)
21 %Aptr = call i8* @llvm_gc_allocate(i32 10)
22 store i8* %Aptr, i8** %A
25 %tmp.1 = bitcast i8*** %B to i8**
26 call void @llvm.gcroot(i8** %tmp.1, i8* null)
29 %B.upgrd.1 = call i8* @llvm_gc_allocate(i32 8)
30 %tmp.2 = bitcast i8* %B.upgrd.1 to i8**
31 store i8** %tmp.2, i8*** %B
36 call void @llvm.gcwrite(i8* %A.1, i8* %B.upgrd.1, i8** %B.1)
41 %i = phi i32 [ 0, %entry ], [ %indvar.next, %AllocLoop ]
42 ;; Allocated mem: allocated memory is immediately dead.
43 call i8* @llvm_gc_allocate(i32 100)
45 %indvar.next = add i32 %i, 1
46 %exitcond = icmp eq i32 %indvar.next, 10000000
47 br i1 %exitcond, label %Exit, label %AllocLoop
53 declare void @__main()