mirror of
https://github.com/RPCSX/llvm.git
synced 2024-11-30 23:20:54 +00:00
351b7a10e2
Listing all of the attributes for the callee of a call/invoke instruction is way too much and makes the IR unreadable. Use references to attributes instead. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@175877 91177308-0d34-0410-b5e6-96231b3b80d8
139 lines
4.2 KiB
LLVM
139 lines
4.2 KiB
LLVM
; RUN: opt -S -basicaa -objc-arc < %s | FileCheck %s
|
|
|
|
declare i8* @objc_loadWeak(i8**)
|
|
declare i8* @objc_loadWeakRetained(i8**)
|
|
declare i8* @objc_storeWeak(i8**, i8*)
|
|
declare i8* @objc_initWeak(i8**, i8*)
|
|
declare void @use_pointer(i8*)
|
|
declare void @callee()
|
|
|
|
; Basic redundant @objc_loadWeak elimination.
|
|
|
|
; CHECK: define void @test0(i8** %p) {
|
|
; CHECK-NEXT: %y = call i8* @objc_loadWeak(i8** %p)
|
|
; CHECK-NEXT: call void @use_pointer(i8* %y)
|
|
; CHECK-NEXT: ret void
|
|
; CHECK-NEXT: }
|
|
define void @test0(i8** %p) {
|
|
%x = call i8* @objc_loadWeak(i8** %p)
|
|
%y = call i8* @objc_loadWeak(i8** %p)
|
|
call void @use_pointer(i8* %y)
|
|
ret void
|
|
}
|
|
|
|
; DCE the @objc_loadWeak.
|
|
|
|
; CHECK: define void @test1(i8** %p) {
|
|
; CHECK-NEXT: %y = call i8* @objc_loadWeakRetained(i8** %p)
|
|
; CHECK-NEXT: call void @use_pointer(i8* %y)
|
|
; CHECK-NEXT: ret void
|
|
; CHECK-NEXT: }
|
|
define void @test1(i8** %p) {
|
|
%x = call i8* @objc_loadWeak(i8** %p)
|
|
%y = call i8* @objc_loadWeakRetained(i8** %p)
|
|
call void @use_pointer(i8* %y)
|
|
ret void
|
|
}
|
|
|
|
; Basic redundant @objc_loadWeakRetained elimination.
|
|
|
|
; CHECK: define void @test2(i8** %p) {
|
|
; CHECK-NEXT: %x = call i8* @objc_loadWeak(i8** %p)
|
|
; CHECK-NEXT: store i8 3, i8* %x
|
|
; CHECK-NEXT: %1 = tail call i8* @objc_retain(i8* %x)
|
|
; CHECK-NEXT: call void @use_pointer(i8* %x)
|
|
; CHECK-NEXT: ret void
|
|
; CHECK-NEXT: }
|
|
define void @test2(i8** %p) {
|
|
%x = call i8* @objc_loadWeak(i8** %p)
|
|
store i8 3, i8* %x
|
|
%y = call i8* @objc_loadWeakRetained(i8** %p)
|
|
call void @use_pointer(i8* %y)
|
|
ret void
|
|
}
|
|
|
|
; Basic redundant @objc_loadWeakRetained elimination, this time
|
|
; with a readonly call instead of a store.
|
|
|
|
; CHECK: define void @test3(i8** %p) {
|
|
; CHECK-NEXT: %x = call i8* @objc_loadWeak(i8** %p)
|
|
; CHECK-NEXT: call void @use_pointer(i8* %x) [[RO:#[0-9]+]]
|
|
; CHECK-NEXT: %1 = tail call i8* @objc_retain(i8* %x)
|
|
; CHECK-NEXT: call void @use_pointer(i8* %x)
|
|
; CHECK-NEXT: ret void
|
|
; CHECK-NEXT: }
|
|
define void @test3(i8** %p) {
|
|
%x = call i8* @objc_loadWeak(i8** %p)
|
|
call void @use_pointer(i8* %x) readonly
|
|
%y = call i8* @objc_loadWeakRetained(i8** %p)
|
|
call void @use_pointer(i8* %y)
|
|
ret void
|
|
}
|
|
|
|
; A regular call blocks redundant weak load elimination.
|
|
|
|
; CHECK: define void @test4(i8** %p) {
|
|
; CHECK-NEXT: %x = call i8* @objc_loadWeak(i8** %p)
|
|
; CHECK-NEXT: call void @use_pointer(i8* %x) [[RO]]
|
|
; CHECK-NEXT: call void @callee()
|
|
; CHECK-NEXT: %y = call i8* @objc_loadWeak(i8** %p)
|
|
; CHECK-NEXT: call void @use_pointer(i8* %y)
|
|
; CHECK-NEXT: ret void
|
|
; CHECK-NEXT: }
|
|
define void @test4(i8** %p) {
|
|
%x = call i8* @objc_loadWeak(i8** %p)
|
|
call void @use_pointer(i8* %x) readonly
|
|
call void @callee()
|
|
%y = call i8* @objc_loadWeak(i8** %p)
|
|
call void @use_pointer(i8* %y)
|
|
ret void
|
|
}
|
|
|
|
; Store to load forwarding.
|
|
|
|
; CHECK: define void @test5(i8** %p, i8* %n) {
|
|
; CHECK-NEXT: %1 = call i8* @objc_storeWeak(i8** %p, i8* %n)
|
|
; CHECK-NEXT: call void @use_pointer(i8* %n)
|
|
; CHECK-NEXT: ret void
|
|
; CHECK-NEXT: }
|
|
define void @test5(i8** %p, i8* %n) {
|
|
call i8* @objc_storeWeak(i8** %p, i8* %n)
|
|
%y = call i8* @objc_loadWeak(i8** %p)
|
|
call void @use_pointer(i8* %y)
|
|
ret void
|
|
}
|
|
|
|
; Store to load forwarding with objc_initWeak.
|
|
|
|
; CHECK: define void @test6(i8** %p, i8* %n) {
|
|
; CHECK-NEXT: %1 = call i8* @objc_initWeak(i8** %p, i8* %n)
|
|
; CHECK-NEXT: call void @use_pointer(i8* %n)
|
|
; CHECK-NEXT: ret void
|
|
; CHECK-NEXT: }
|
|
define void @test6(i8** %p, i8* %n) {
|
|
call i8* @objc_initWeak(i8** %p, i8* %n)
|
|
%y = call i8* @objc_loadWeak(i8** %p)
|
|
call void @use_pointer(i8* %y)
|
|
ret void
|
|
}
|
|
|
|
; Don't forward if there's a may-alias store in the way.
|
|
|
|
; CHECK: define void @test7(i8** %p, i8* %n, i8** %q, i8* %m) {
|
|
; CHECK-NEXT: call i8* @objc_initWeak(i8** %p, i8* %n)
|
|
; CHECK-NEXT: call i8* @objc_storeWeak(i8** %q, i8* %m)
|
|
; CHECK-NEXT: %y = call i8* @objc_loadWeak(i8** %p)
|
|
; CHECK-NEXT: call void @use_pointer(i8* %y)
|
|
; CHECK-NEXT: ret void
|
|
; CHECK-NEXT: }
|
|
define void @test7(i8** %p, i8* %n, i8** %q, i8* %m) {
|
|
call i8* @objc_initWeak(i8** %p, i8* %n)
|
|
call i8* @objc_storeWeak(i8** %q, i8* %m)
|
|
%y = call i8* @objc_loadWeak(i8** %p)
|
|
call void @use_pointer(i8* %y)
|
|
ret void
|
|
}
|
|
|
|
; CHECK: attributes #0 = { nounwind }
|
|
; CHECK: attributes [[RO]] = { readonly }
|