1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 11:13:28 +01:00
llvm-mirror/test/SafepointIRVerifier/basic-use-after-reloc.ll
Anna Thomas 2f21b887d3 [SafepointIRVerifier] Add verifier pass for finding GC relocation bugs
Original Patch and summary by Philip Reames.

RewriteStatepointsForGC tries to rewrite a function in a manner where
the optimizer can't end up using a pointer value after it might have
been relocated by a safepoint. This pass checks the invariant that
RSForGC is supposed to establish and that (if we constructed semantics
correctly) later passes must preserve.

This has been a really useful diagnostic tool when initially developing
the rewriting scheme and has found numerous bugs.

Differential Revision: https://reviews.llvm.org/D15940

Reviewed by: swaroop.sridhar, mjacob

Subscribers: llvm-commits
llvm-svn: 307112
2017-07-05 01:16:29 +00:00

24 lines
1.2 KiB
LLVM

; RUN: opt -safepoint-ir-verifier-print-only -verify-safepoint-ir -S %s 2>&1 | FileCheck %s
; This test checks that if a value is used immediately after a
; safepoint without using the relocated value that the verifier
; catches this.
%jObject = type { [8 x i8] }
; Function Attrs: nounwind
define %jObject addrspace(1)* @test(%jObject addrspace(1)* %arg) gc "statepoint-example" {
bci_0:
%safepoint_token3 = tail call token (i64, i32, double (double)*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_f64f64f(i64 0, i32 0, double (double)* undef, i32 1, i32 0, double undef, i32 0, i32 5, i32 0, i32 -1, i32 0, i32 0, i32 0, %jObject addrspace(1)* %arg)
%arg2.relocated4 = call coldcc %jObject addrspace(1)* @llvm.experimental.gc.relocate.p1jObject(token %safepoint_token3, i32 13, i32 13)
ret %jObject addrspace(1)* %arg
; CHECK: Illegal use of unrelocated value found!
; CHECK-NEXT: Def: %jObject addrspace(1)* %arg
; CHECK-NEXT: Use: ret %jObject addrspace(1)* %arg
}
; Function Attrs: nounwind
declare %jObject addrspace(1)* @llvm.experimental.gc.relocate.p1jObject(token, i32, i32) #3
declare token @llvm.experimental.gc.statepoint.p0f_f64f64f(i64, i32, double (double)*, i32, i32, ...)