1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-01-31 20:51:52 +01:00
Pete Cooper f6c9646a94 Change the objc ARC optimizer to use the new objc.* intrinsics
We're moving ARC optimisation and ARC emission in clang away from runtime methods
and towards intrinsics.  This is the part which actually uses the intrinsics in the ARC
optimizer when both analyzing the existing calls and emitting new ones.

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

Reviewers: ahatanak
llvm-svn: 349534
2018-12-18 20:32:49 +00:00

47 lines
1.6 KiB
LLVM

; RUN: opt -S -basicaa -objc-arc < %s | FileCheck %s
; rdar://11434915
; Delete the weak calls and replace them with just the net retain.
; CHECK: define void @test0(i8* %p) {
; CHECK-NEXT: call i8* @llvm.objc.retain(i8* %p)
; CHECK-NEXT: ret void
define void @test0(i8* %p) {
%weakBlock = alloca i8*, align 8
%tmp7 = call i8* @llvm.objc.initWeak(i8** %weakBlock, i8* %p) nounwind
%tmp26 = call i8* @llvm.objc.loadWeakRetained(i8** %weakBlock) nounwind
call void @llvm.objc.destroyWeak(i8** %weakBlock) nounwind
ret void
}
; CHECK: define i8* @test1(i8* %p) {
; CHECK-NEXT: call i8* @llvm.objc.retain(i8* %p)
; CHECK-NEXT: ret i8* %p
define i8* @test1(i8* %p) {
%weakBlock = alloca i8*, align 8
%tmp7 = call i8* @llvm.objc.initWeak(i8** %weakBlock, i8* %p) nounwind
%tmp26 = call i8* @llvm.objc.loadWeakRetained(i8** %weakBlock) nounwind
call void @llvm.objc.destroyWeak(i8** %weakBlock) nounwind
ret i8* %tmp26
}
; CHECK: define i8* @test2(i8* %p, i8* %q) {
; CHECK-NEXT: call i8* @llvm.objc.retain(i8* %q)
; CHECK-NEXT: ret i8* %q
define i8* @test2(i8* %p, i8* %q) {
%weakBlock = alloca i8*, align 8
%tmp7 = call i8* @llvm.objc.initWeak(i8** %weakBlock, i8* %p) nounwind
%tmp19 = call i8* @llvm.objc.storeWeak(i8** %weakBlock, i8* %q) nounwind
%tmp26 = call i8* @llvm.objc.loadWeakRetained(i8** %weakBlock) nounwind
call void @llvm.objc.destroyWeak(i8** %weakBlock) nounwind
ret i8* %tmp26
}
declare i8* @llvm.objc.initWeak(i8**, i8*)
declare void @llvm.objc.destroyWeak(i8**)
declare i8* @llvm.objc.loadWeakRetained(i8**)
declare i8* @llvm.objc.storeWeak(i8** %weakBlock, i8* %q)