Home | History | Annotate | Download | only in ObjCARC
      1 ; RUN: opt -S -objc-arc -objc-arc-contract < %s | FileCheck %s
      2 
      3 ; Test that the optimizer can create an objc_retainAutoreleaseReturnValue
      4 ; declaration even if no objc_retain declaration exists.
      5 ; rdar://9401303
      6 
      7 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
      8 declare i8* @objc_unretainedObject(i8*)
      9 declare i8* @objc_retainAutoreleasedReturnValue(i8*)
     10 declare i8* @objc_autoreleaseReturnValue(i8*)
     11 
     12 ; CHECK:      define i8* @foo(i8* %p) {
     13 ; CHECK-NEXT: entry:
     14 ; CHECK-NEXT:   %0 = tail call i8* @objc_retainAutoreleaseReturnValue(i8* %p) nounwind
     15 ; CHECK-NEXT:   ret i8* %0
     16 ; CHECK-NEXT: }
     17 
     18 define i8* @foo(i8* %p) {
     19 entry:
     20   %call = tail call i8* @objc_unretainedObject(i8* %p)
     21   %0 = tail call i8* @objc_retainAutoreleasedReturnValue(i8* %call) nounwind
     22   %1 = tail call i8* @objc_autoreleaseReturnValue(i8* %0) nounwind
     23   ret i8* %1
     24 }
     25 
     26