brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.3 KiB · 1e324be Raw
96 lines · plain
1; RUN: opt -S %s -passes=verify | FileCheck %s2 3declare void @use(...)4declare ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token, i32, i32)5declare token @llvm.experimental.gc.statepoint.p0(i64, i32, ptr, i32, i32, ...)6declare i32 @"personality_function"()7 8;; Basic usage9define ptr addrspace(1) @test1(ptr addrspace(1) %arg) gc "statepoint-example" {10entry:11  %safepoint_token = call token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 0, i32 0, ptr elementtype(void ()) undef, i32 0, i32 0, i32 0, i32 0) ["gc-live" (ptr addrspace(1) %arg, ptr addrspace(1) %arg, ptr addrspace(1) %arg, ptr addrspace(1) %arg), "deopt" (i32 0, i32 0, i32 0, i32 10, i32 0)]12  %reloc = call ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token %safepoint_token, i32 0, i32 1)13  ;; It is perfectly legal to relocate the same value multiple times...14  %reloc2 = call ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token %safepoint_token, i32 0, i32 1)15  %reloc3 = call ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token %safepoint_token, i32 1, i32 0)16  ret ptr addrspace(1) %reloc17; CHECK-LABEL: test118; CHECK: statepoint19; CHECK: gc.relocate20; CHECK: gc.relocate21; CHECK: gc.relocate22; CHECK: ret ptr addrspace(1) %reloc23}24 25; This test catches two cases where the verifier was too strict:26; 1) A base doesn't need to be relocated if it's never used again27; 2) A value can be replaced by one which is known equal.  This28; means a potentially derived pointer can be known base and that29; we can't check that derived pointer are never bases.30define void @test2(ptr addrspace(1) %arg, ptr addrspace(1) %arg2) gc "statepoint-example" {31entry:32  %c = icmp eq ptr addrspace(1) %arg,  %arg233  br i1 %c, label %equal, label %notequal34 35notequal:36  ret void37 38equal:39  %safepoint_token = call token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 0, i32 0, ptr elementtype(void ()) undef, i32 0, i32 0, i32 0, i32 0) ["gc-live" (ptr addrspace(1) %arg, ptr addrspace(1) %arg, ptr addrspace(1) %arg, ptr addrspace(1) %arg), "deopt" (i32 0, i32 0, i32 0, i32 10, i32 0)]40  %reloc = call ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token %safepoint_token, i32 0, i32 0)41  call void undef(ptr addrspace(1) %reloc)42  ret void43; CHECK-LABEL: test244; CHECK-LABEL: equal45; CHECK: statepoint46; CHECK-NEXT: %reloc = call47; CHECK-NEXT: call48; CHECK-NEXT: ret voi49}50 51; Basic test for invoke statepoints52define ptr addrspace(1) @test3(ptr addrspace(1) %obj, ptr addrspace(1) %obj1) gc "statepoint-example" personality ptr @"personality_function" {53; CHECK-LABEL: test354entry:55  ; CHECK-LABEL: entry56  ; CHECK: statepoint57  %0 = invoke token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 0, i32 0, ptr elementtype(void ()) undef, i32 0, i32 0, i32 0, i32 0) ["gc-live" (ptr addrspace(1) %obj, ptr addrspace(1) %obj1), "deopt" (i32 0, i32 -1, i32 0, i32 0, i32 0)]58          to label %normal_dest unwind label %exceptional_return59 60normal_dest:61  ; CHECK-LABEL: normal_dest:62  ; CHECK: gc.relocate63  ; CHECK: gc.relocate64  ; CHECK: ret65  %obj.relocated = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token %0, i32 0, i32 0)66  %obj1.relocated = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token %0, i32 1, i32 1)67  ret ptr addrspace(1) %obj.relocated68 69exceptional_return:70  ; CHECK-LABEL: exceptional_return71  ; CHECK: gc.relocate72  ; CHECK: gc.relocate73  %landing_pad = landingpad token74          cleanup75  %obj.relocated1 = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token %landing_pad, i32 0, i32 0)76  %obj1.relocated1 = call coldcc ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token %landing_pad, i32 1, i32 1)77  ret ptr addrspace(1) %obj1.relocated178}79 80; Test for statepoint with sret attribute.81; This should be allowed as long as the wrapped function is not vararg.82%struct = type { i64, i64, i64 }83 84declare void @fn_sret(ptr sret(%struct))85 86define void @test_sret() gc "statepoint-example" {87  %x = alloca %struct88  %statepoint_token = call token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 0, i32 0, ptr elementtype(void (ptr)) @fn_sret, i32 1, i32 0, ptr sret(%struct) %x, i32 0, i32 0)89  ret void90  ; CHECK-LABEL: test_sret91  ; CHECK: alloca92  ; CHECK: statepoint93  ; CHECK-SAME: sret94  ; CHECK: ret95}96