Home | History | Annotate | Download | only in ObjCARC
      1 ; RUN: opt -objc-arc-expand -S < %s | FileCheck %s
      2 
      3 target datalayout = "e-p:64:64:64"
      4 
      5 declare i8* @objc_retain(i8*)
      6 declare i8* @objc_autorelease(i8*)
      7 declare i8* @objc_retainAutoreleasedReturnValue(i8*)
      8 declare i8* @objc_autoreleaseReturnValue(i8*)
      9 declare i8* @objc_retainAutorelease(i8*)
     10 declare i8* @objc_retainAutoreleaseReturnValue(i8*)
     11 declare i8* @objc_retainBlock(i8*)
     12 
     13 declare void @use_pointer(i8*)
     14 
     15 ; CHECK: define void @test_retain(i8* %x) [[NUW:#[0-9]+]] {
     16 ; CHECK: call i8* @objc_retain(i8* %x)
     17 ; CHECK: call void @use_pointer(i8* %x)
     18 ; CHECK: }
     19 define void @test_retain(i8* %x) nounwind {
     20 entry:
     21   %0 = call i8* @objc_retain(i8* %x) nounwind
     22   call void @use_pointer(i8* %0)
     23   ret void
     24 }
     25 
     26 ; CHECK: define void @test_retainAutoreleasedReturnValue(i8* %x) [[NUW]] {
     27 ; CHECK: call i8* @objc_retainAutoreleasedReturnValue(i8* %x)
     28 ; CHECK: call void @use_pointer(i8* %x)
     29 ; CHECK: }
     30 define void @test_retainAutoreleasedReturnValue(i8* %x) nounwind {
     31 entry:
     32   %0 = call i8* @objc_retainAutoreleasedReturnValue(i8* %x) nounwind
     33   call void @use_pointer(i8* %0)
     34   ret void
     35 }
     36 
     37 ; CHECK: define void @test_retainAutorelease(i8* %x) [[NUW]] {
     38 ; CHECK: call i8* @objc_retainAutorelease(i8* %x)
     39 ; CHECK: call void @use_pointer(i8* %x)
     40 ; CHECK: }
     41 define void @test_retainAutorelease(i8* %x) nounwind {
     42 entry:
     43   %0 = call i8* @objc_retainAutorelease(i8* %x) nounwind
     44   call void @use_pointer(i8* %0)
     45   ret void
     46 }
     47 
     48 ; CHECK: define void @test_retainAutoreleaseReturnValue(i8* %x) [[NUW]] {
     49 ; CHECK: call i8* @objc_retainAutoreleaseReturnValue(i8* %x)
     50 ; CHECK: call void @use_pointer(i8* %x)
     51 ; CHECK: }
     52 define void @test_retainAutoreleaseReturnValue(i8* %x) nounwind {
     53 entry:
     54   %0 = call i8* @objc_retainAutoreleaseReturnValue(i8* %x) nounwind
     55   call void @use_pointer(i8* %0)
     56   ret void
     57 }
     58 
     59 ; CHECK: define void @test_autorelease(i8* %x) [[NUW]] {
     60 ; CHECK: call i8* @objc_autorelease(i8* %x)
     61 ; CHECK: call void @use_pointer(i8* %x)
     62 ; CHECK: }
     63 define void @test_autorelease(i8* %x) nounwind {
     64 entry:
     65   %0 = call i8* @objc_autorelease(i8* %x) nounwind
     66   call void @use_pointer(i8* %0)
     67   ret void
     68 }
     69 
     70 ; CHECK: define void @test_autoreleaseReturnValue(i8* %x) [[NUW]] {
     71 ; CHECK: call i8* @objc_autoreleaseReturnValue(i8* %x)
     72 ; CHECK: call void @use_pointer(i8* %x)
     73 ; CHECK: }
     74 define void @test_autoreleaseReturnValue(i8* %x) nounwind {
     75 entry:
     76   %0 = call i8* @objc_autoreleaseReturnValue(i8* %x) nounwind
     77   call void @use_pointer(i8* %0)
     78   ret void
     79 }
     80 
     81 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
     82 ; RetainBlock is not strictly forwarding. Do not touch it. ;
     83 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
     84 
     85 ; CHECK: define void @test_retainBlock(i8* %x) [[NUW]] {
     86 ; CHECK: call i8* @objc_retainBlock(i8* %x)
     87 ; CHECK: call void @use_pointer(i8* %0)
     88 ; CHECK: }
     89 define void @test_retainBlock(i8* %x) nounwind {
     90 entry:
     91   %0 = call i8* @objc_retainBlock(i8* %x) nounwind
     92   call void @use_pointer(i8* %0)
     93   ret void
     94 }
     95