Home | History | Annotate | Download | only in ObjCARC
      1 ; RUN: opt -S -objc-arc < %s | FileCheck %s
      2 
      3 ; The optimizer should be able to move the autorelease past two phi nodes
      4 ; and fold it with the release in bb65.
      5 
      6 ; CHECK: bb65:
      7 ; CHECK: call i8* @objc_retainAutorelease
      8 ; CHECK: br label %bb76
      9 
     10 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"
     11 target triple = "x86_64-apple-darwin11.0.0"
     12 
     13 %0 = type opaque
     14 %1 = type opaque
     15 %2 = type opaque
     16 %3 = type opaque
     17 %4 = type opaque
     18 %5 = type opaque
     19 
     20 @"\01L_OBJC_SELECTOR_REFERENCES_11" = external hidden global i8*, section "__DATA, __objc_selrefs, literal_pointers, no_dead_strip"
     21 @"\01L_OBJC_SELECTOR_REFERENCES_421455" = external hidden global i8*, section "__DATA, __objc_selrefs, literal_pointers, no_dead_strip"
     22 @"\01L_OBJC_SELECTOR_REFERENCES_598" = external hidden global i8*, section "__DATA, __objc_selrefs, literal_pointers, no_dead_strip"
     23 @"\01L_OBJC_SELECTOR_REFERENCES_620" = external hidden global i8*, section "__DATA, __objc_selrefs, literal_pointers, no_dead_strip"
     24 @"\01L_OBJC_SELECTOR_REFERENCES_622" = external hidden global i8*, section "__DATA, __objc_selrefs, literal_pointers, no_dead_strip"
     25 @"\01L_OBJC_SELECTOR_REFERENCES_624" = external hidden global i8*, section "__DATA, __objc_selrefs, literal_pointers, no_dead_strip"
     26 @"\01L_OBJC_SELECTOR_REFERENCES_626" = external hidden global i8*, section "__DATA, __objc_selrefs, literal_pointers, no_dead_strip"
     27 
     28 declare i8* @objc_msgSend(i8*, i8*, ...)
     29 
     30 declare i8* @objc_retain(i8*)
     31 
     32 declare void @objc_release(i8*)
     33 
     34 declare i8* @objc_autorelease(i8*)
     35 
     36 define hidden %0* @foo(%1* %arg, %3* %arg3) {
     37 bb:
     38   %tmp16 = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_620", align 8
     39   %tmp17 = bitcast %3* %arg3 to i8*
     40   %tmp18 = call %4* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to %4* (i8*, i8*)*)(i8* %tmp17, i8* %tmp16)
     41   %tmp19 = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_622", align 8
     42   %tmp20 = bitcast %4* %tmp18 to i8*
     43   %tmp21 = call %5* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to %5* (i8*, i8*)*)(i8* %tmp20, i8* %tmp19)
     44   %tmp22 = bitcast %5* %tmp21 to i8*
     45   %tmp23 = call i8* @objc_retain(i8* %tmp22) nounwind
     46   %tmp24 = bitcast i8* %tmp23 to %5*
     47   %tmp26 = icmp eq i8* %tmp23, null
     48   br i1 %tmp26, label %bb81, label %bb27
     49 
     50 bb27:                                             ; preds = %bb
     51   %tmp29 = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_11", align 8
     52   %tmp30 = bitcast %1* %arg to i8*
     53   %tmp31 = call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i8* (i8*, i8*)*)(i8* %tmp30, i8* %tmp29)
     54   %tmp34 = call i8* @objc_retain(i8* %tmp31) nounwind
     55   %tmp37 = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_421455", align 8
     56   %tmp39 = call %0* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to %0* (i8*, i8*)*)(i8* %tmp34, i8* %tmp37)
     57   %tmp40 = bitcast %0* %tmp39 to i8*
     58   %tmp41 = call i8* @objc_retain(i8* %tmp40) nounwind
     59   %tmp42 = bitcast i8* %tmp41 to %0*
     60   %tmp44 = icmp eq i8* %tmp41, null
     61   br i1 %tmp44, label %bb45, label %bb55
     62 
     63 bb45:                                             ; preds = %bb27
     64   %tmp47 = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_624", align 8
     65   %tmp49 = call %0* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to %0* (i8*, i8*)*)(i8* %tmp34, i8* %tmp47)
     66   %tmp51 = bitcast %0* %tmp49 to i8*
     67   %tmp52 = call i8* @objc_retain(i8* %tmp51) nounwind
     68   call void @objc_release(i8* %tmp41) nounwind
     69   br label %bb55
     70 
     71 bb55:                                             ; preds = %bb27, %bb45
     72   %tmp13.0 = phi %0* [ %tmp42, %bb27 ], [ %tmp49, %bb45 ]
     73   %tmp57 = icmp eq %0* %tmp13.0, null
     74   br i1 %tmp57, label %bb76, label %bb58
     75 
     76 bb58:                                             ; preds = %bb55
     77   %tmp60 = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_598", align 8
     78   %tmp61 = bitcast %0* %tmp13.0 to i8*
     79   %tmp62 = call signext i8 bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i8 (i8*, i8*)*)(i8* %tmp61, i8* %tmp60)
     80   %tmp64 = icmp eq i8 %tmp62, 0
     81   br i1 %tmp64, label %bb76, label %bb65
     82 
     83 bb65:                                             ; preds = %bb58
     84   %tmp68 = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_626", align 8
     85   %tmp69 = bitcast %0* %tmp13.0 to i8*
     86   %tmp70 = call %0* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to %0* (i8*, i8*, %5*)*)(i8* %tmp69, i8* %tmp68, %5* %tmp24)
     87   %tmp72 = bitcast %0* %tmp70 to i8*
     88   %tmp73 = call i8* @objc_retain(i8* %tmp72) nounwind
     89   br label %bb76
     90 
     91 bb76:                                             ; preds = %bb58, %bb55, %bb65
     92   %tmp10.0 = phi %0* [ %tmp70, %bb65 ], [ null, %bb58 ], [ null, %bb55 ]
     93   %tmp78 = bitcast %0* %tmp13.0 to i8*
     94   call void @objc_release(i8* %tmp78) nounwind
     95   call void @objc_release(i8* %tmp34) nounwind
     96   br label %bb81
     97 
     98 bb81:                                             ; preds = %bb, %bb76
     99   %tmp10.1 = phi %0* [ %tmp10.0, %bb76 ], [ null, %bb ]
    100   %tmp83 = bitcast %0* %tmp10.1 to i8*
    101   %tmp84 = call i8* @objc_retain(i8* %tmp83) nounwind
    102   %tmp88 = bitcast i8* %tmp87 to %0*
    103   call void @objc_release(i8* %tmp23) nounwind
    104   %tmp87 = call i8* @objc_autorelease(i8* %tmp84) nounwind
    105   %tmp92 = bitcast %0* %tmp10.1 to i8*
    106   call void @objc_release(i8* %tmp92) nounwind
    107   ret %0* %tmp88
    108 }
    109