1; RUN: opt -S -objc-arc < %s | FileCheck %s 2; rdar://10209613 3 4; CHECK: define void @test 5; CHECK: %3 = call i8* @objc_retainBlock(i8* %2) nounwind 6; CHECK: @objc_msgSend 7; CHECK-NEXT: @objc_release(i8* %3) 8 9%0 = type opaque 10%struct.__block_descriptor = type { i64, i64 } 11 12@_NSConcreteStackBlock = external global i8* 13@__block_descriptor_tmp = external hidden constant { i64, i64, i8*, i8*, i8*, i8* } 14@"\01L_OBJC_SELECTOR_REFERENCES_" = external hidden global i8*, section "__DATA, __objc_selrefs, literal_pointers, no_dead_strip" 15 16define void @test(%0* %array) uwtable { 17entry: 18 %block = alloca <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, %0* }>, align 8 19 %0 = bitcast %0* %array to i8* 20 %1 = tail call i8* @objc_retain(i8* %0) nounwind 21 %block.isa = getelementptr inbounds <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, %0* }>* %block, i64 0, i32 0 22 store i8* bitcast (i8** @_NSConcreteStackBlock to i8*), i8** %block.isa, align 8 23 %block.flags = getelementptr inbounds <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, %0* }>* %block, i64 0, i32 1 24 store i32 1107296256, i32* %block.flags, align 8 25 %block.reserved = getelementptr inbounds <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, %0* }>* %block, i64 0, i32 2 26 store i32 0, i32* %block.reserved, align 4 27 %block.invoke = getelementptr inbounds <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, %0* }>* %block, i64 0, i32 3 28 store i8* bitcast (void (i8*)* @__test_block_invoke_0 to i8*), i8** %block.invoke, align 8 29 %block.descriptor = getelementptr inbounds <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, %0* }>* %block, i64 0, i32 4 30 store %struct.__block_descriptor* bitcast ({ i64, i64, i8*, i8*, i8*, i8* }* @__block_descriptor_tmp to %struct.__block_descriptor*), %struct.__block_descriptor** %block.descriptor, align 8 31 %block.captured = getelementptr inbounds <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, %0* }>* %block, i64 0, i32 5 32 store %0* %array, %0** %block.captured, align 8 33 %2 = bitcast <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, %0* }>* %block to i8* 34 %3 = call i8* @objc_retainBlock(i8* %2) nounwind 35 %tmp2 = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_", align 8 36 call void bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to void (i8*, i8*, i8*)*)(i8* %0, i8* %tmp2, i8* %3) 37 call void @objc_release(i8* %3) nounwind 38 %strongdestroy = load %0** %block.captured, align 8 39 %4 = bitcast %0* %strongdestroy to i8* 40 call void @objc_release(i8* %4) nounwind, !clang.imprecise_release !0 41 ret void 42} 43 44declare i8* @objc_retain(i8*) 45 46declare void @__test_block_invoke_0(i8* nocapture) uwtable 47 48declare i8* @objc_retainBlock(i8*) 49 50declare i8* @objc_msgSend(i8*, i8*, ...) nonlazybind 51 52declare void @objc_release(i8*) 53 54!0 = metadata !{} 55