1; RUN: opt -objc-arc -S < %s | FileCheck %s 2 3declare void @alterRefCount() 4declare void @use(i8*) 5 6@g0 = global i8* null, align 8 7 8; Check that ARC optimizer doesn't reverse the order of the retain call and the 9; release call when there are debug instructions. 10 11; CHECK: call i8* @llvm.objc.retain(i8* %x) 12; CHECK: call void @llvm.objc.release(i8* %x) 13 14define i32 @test(i8* %x, i8* %y, i8 %z, i32 %i) { 15 %i.addr = alloca i32, align 4 16 store i32 %i, i32* %i.addr, align 4 17 %v1 = tail call i8* @llvm.objc.retain(i8* %x) 18 store i8 %z, i8* %x 19 call void @llvm.dbg.declare(metadata i32* %i.addr, metadata !9, metadata !DIExpression()), !dbg !10 20 call void @alterRefCount() 21 tail call void @llvm.objc.release(i8* %x) 22 ret i32 %i 23} 24 25; ARC optimizer shouldn't move the release call, which is a precise release call 26; past the call to @alterRefCount. 27 28; CHECK-LABEL: define void @test2( 29; CHECK: call void @alterRefCount( 30; CHECK: call void @llvm.objc.release( 31 32define void @test2() { 33 %v0 = load i8*, i8** @g0, align 8 34 %v1 = tail call i8* @llvm.objc.retain(i8* %v0) 35 tail call void @use(i8* %v0) 36 tail call void @alterRefCount() 37 tail call void @llvm.objc.release(i8* %v0) 38 ret void 39} 40 41declare void @llvm.dbg.declare(metadata, metadata, metadata) 42declare i8* @llvm.objc.retain(i8*) local_unnamed_addr 43declare void @llvm.objc.release(i8*) local_unnamed_addr 44 45!llvm.module.flags = !{!0, !1} 46 47!0 = !{i32 2, !"Dwarf Version", i32 4} 48!1 = !{i32 2, !"Debug Info Version", i32 3} 49!2 = !DILocalVariable(name: "i", arg: 1, scope: !3, file: !4, line: 1, type: !7) 50!3 = distinct !DISubprogram(name: "test", scope: !4, file: !4, line: 1, type: !5, scopeLine: 1, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !8, retainedNodes: !9) 51!4 = !DIFile(filename: "test.m", directory: "dir") 52!5 = !DISubroutineType(types: !6) 53!6 = !{!7, !7} 54!7 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) 55!8 = distinct !DICompileUnit(language: DW_LANG_ObjC, file: !4, isOptimized: false, runtimeVersion: 2, emissionKind: FullDebug, enums: !9, nameTableKind: None) 56!9 = !{} 57!10 = !DILocation(line: 1, column: 14, scope: !3) 58