50 lines · plain
1; RUN: not llvm-as -o /dev/null %s 2>&1 | FileCheck %s2; PR16333 4declare void @llvm.gcroot(ptr, ptr)5 6define void @caller_must_use_gc() {7 ; CHECK: Enclosing function does not use GC.8 ; CHECK-NEXT: call void @llvm.gcroot(ptr %alloca, ptr null)9 %alloca = alloca ptr10 call void @llvm.gcroot(ptr %alloca, ptr null)11 ret void12}13 14define void @must_be_alloca() gc "test" {15; CHECK: llvm.gcroot parameter #1 must be an alloca.16; CHECK-NEXT: call void @llvm.gcroot(ptr null, ptr null)17 call void @llvm.gcroot(ptr null, ptr null)18 ret void19}20 21define void @non_ptr_alloca_null() gc "test" {22 ; CHECK: llvm.gcroot parameter #1 must either be a pointer alloca, or argument #2 must be a non-null constant.23 ; CHECK-NEXT: call void @llvm.gcroot(ptr %alloca, ptr null)24 %alloca = alloca i3225 call void @llvm.gcroot(ptr %alloca, ptr null)26 ret void27}28 29define void @non_constant_arg1(ptr %arg) gc "test" {30 ; CHECK: llvm.gcroot parameter #2 must be a constant.31 ; CHECK-NEXT: call void @llvm.gcroot(ptr %alloca, ptr %arg)32 %alloca = alloca ptr33 call void @llvm.gcroot(ptr %alloca, ptr %arg)34 ret void35}36 37define void @non_ptr_alloca_non_null() gc "test" {38; CHECK-NOT: llvm.gcroot parameter39 %alloca = alloca i3240 call void @llvm.gcroot(ptr %alloca, ptr inttoptr (i64 123 to ptr))41 ret void42}43 44define void @casted_alloca() gc "test" {45; CHECK-NOT: llvm.gcroot parameter46 %alloca = alloca ptr47 call void @llvm.gcroot(ptr %alloca, ptr null)48 ret void49}50