reference, declarationdefinition
definition → references, declarations, derived classes, virtual overrides
reference to multiple definitions → definitions
unreferenced
    1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43
   44
   45
   46
   47
; RUN: opt -objc-arc -S < %s | FileCheck %s

; Generated by compiling:
;
; id baz(void *X) { return (__bridge_transfer id)X; }
; 
; void foo(id X) {
; void *Y = 0;
; if (X)
;   Y = (__bridge_retained void *)X;
; baz(Y);
; }
;
; clang -x objective-c -mllvm -enable-objc-arc-opts=0 -fobjc-arc -S -emit-llvm test.m
;
; And then hand-reduced further. 

declare i8* @llvm.objc.autoreleaseReturnValue(i8*)
declare i8* @llvm.objc.unsafeClaimAutoreleasedReturnValue(i8*)
declare i8* @llvm.objc.retain(i8*)
declare void @llvm.objc.release(i8*)

define void @foo(i8* %X) {
entry:
  %0 = tail call i8* @llvm.objc.retain(i8* %X) 
  %tobool = icmp eq i8* %0, null
  br i1 %tobool, label %if.end, label %if.then

if.then:                                          ; preds = %entry
  %1 = tail call i8* @llvm.objc.retain(i8* nonnull %0)
  br label %if.end

if.end:                                           ; preds = %if.then, %entry
  %Y.0 = phi i8* [ %1, %if.then ], [ null, %entry ]
  %2 = tail call i8* @llvm.objc.autoreleaseReturnValue(i8* %Y.0)
  %3 = tail call i8* @llvm.objc.unsafeClaimAutoreleasedReturnValue(i8* %2)
  tail call void @llvm.objc.release(i8* %0) 
  ret void
}

; CHECK: if.then
; CHECK: tail call i8* @llvm.objc.retain
; CHECK-NEXT: call i8* @llvm.objc.autorelease
; CHECK: %Y.0 = phi
; CHECK-NEXT: tail call i8* @llvm.objc.unsafeClaimAutoreleasedReturnValue(i8* %Y.0)
; CHECK-NEXT: tail call void @llvm.objc.release