File: unsafe-claim-rv.ll

package info (click to toggle)
llvm-toolchain-5.0 1:5.0.1-2~bpo9+1
  • links: PTS, VCS
  • area: main
  • in suites: stretch-backports
  • size: 553,688 kB
  • sloc: cpp: 2,878,786; ansic: 584,110; asm: 246,252; python: 124,751; objc: 106,925; sh: 21,542; lisp: 8,628; pascal: 5,885; ml: 5,544; perl: 5,312; makefile: 2,208; cs: 2,022; xml: 686; php: 212; csh: 117
file content (47 lines) | stat: -rw-r--r-- 1,361 bytes parent folder | download | duplicates (10)
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* @objc_autoreleaseReturnValue(i8*)
declare i8* @objc_unsafeClaimAutoreleasedReturnValue(i8*)
declare i8* @objc_retain(i8*)
declare void @objc_release(i8*)

define void @foo(i8* %X) {
entry:
  %0 = tail call i8* @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* @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* @objc_autoreleaseReturnValue(i8* %Y.0)
  %3 = tail call i8* @objc_unsafeClaimAutoreleasedReturnValue(i8* %2)
  tail call void @objc_release(i8* %0) 
  ret void
}

; CHECK: if.then
; CHECK: tail call i8* @objc_retain
; CHECK-NEXT: call i8* @objc_autorelease
; CHECK: %Y.0 = phi
; CHECK-NEXT: tail call i8* @objc_unsafeClaimAutoreleasedReturnValue(i8* %Y.0)
; CHECK-NEXT: tail call void @objc_release