1 ; RUN: opt -basicaa -objc-arc -S < %s | FileCheck %s
3 target datalayout = "e-p:64:64:64"
5 declare i8* @objc_retain(i8*)
6 declare i8* @objc_retainAutoreleasedReturnValue(i8*)
7 declare void @objc_release(i8*)
8 declare i8* @objc_autorelease(i8*)
9 declare i8* @objc_autoreleaseReturnValue(i8*)
10 declare void @objc_autoreleasePoolPop(i8*)
11 declare i8* @objc_autoreleasePoolPush()
12 declare i8* @objc_retainBlock(i8*)
14 declare i8* @objc_retainedObject(i8*)
15 declare i8* @objc_unretainedObject(i8*)
16 declare i8* @objc_unretainedPointer(i8*)
18 declare void @use_pointer(i8*)
19 declare void @callee()
20 declare void @callee_fnptr(void ()*)
21 declare void @invokee()
22 declare i8* @returner()
24 declare void @llvm.dbg.value(metadata, i64, metadata)
26 declare i8* @objc_msgSend(i8*, i8*, ...)
28 ; Simple retain+release pair deletion, with some intervening control
29 ; flow and harmless instructions.
31 ; CHECK: define void @test0(
34 define void @test0(i32* %x, i1 %p) nounwind {
36 %a = bitcast i32* %x to i8*
37 %0 = call i8* @objc_retain(i8* %a) nounwind
38 br i1 %p, label %t, label %f
42 %b = bitcast i32* %x to float*
43 store float 2.0, float* %b
51 %c = bitcast i32* %x to i8*
52 call void @objc_release(i8* %c) nounwind
56 ; Like test0 but the release isn't always executed when the retain is,
57 ; so the optimization is not safe.
59 ; TODO: Make the objc_release's argument be %0.
61 ; CHECK: define void @test1(
62 ; CHECK: @objc_retain(i8* %a)
63 ; CHECK: @objc_release
65 define void @test1(i32* %x, i1 %p, i1 %q) nounwind {
67 %a = bitcast i32* %x to i8*
68 %0 = call i8* @objc_retain(i8* %a) nounwind
69 br i1 %p, label %t, label %f
73 %b = bitcast i32* %x to float*
74 store float 2.0, float* %b
80 br i1 %q, label %return, label %alt_return
83 %c = bitcast i32* %x to i8*
84 call void @objc_release(i8* %c) nounwind
91 ; Don't do partial elimination into two different CFG diamonds.
93 ; CHECK: define void @test1b(
95 ; CHECK: tail call i8* @objc_retain(i8* %x) [[NUW:#[0-9]+]]
98 ; CHECK: tail call void @objc_release(i8* %x) [[NUW]], !clang.imprecise_release !0
101 define void @test1b(i8* %x, i1 %p, i1 %q) {
103 tail call i8* @objc_retain(i8* %x) nounwind
104 br i1 %p, label %if.then, label %if.end
106 if.then: ; preds = %entry
107 tail call void @callee()
110 if.end: ; preds = %if.then, %entry
111 br i1 %q, label %if.then3, label %if.end5
113 if.then3: ; preds = %if.end
114 tail call void @use_pointer(i8* %x)
117 if.end5: ; preds = %if.then3, %if.end
118 tail call void @objc_release(i8* %x) nounwind, !clang.imprecise_release !0
122 ; Like test0 but the pointer is passed to an intervening call,
123 ; so the optimization is not safe.
125 ; CHECK: define void @test2(
126 ; CHECK: @objc_retain(i8* %a)
127 ; CHECK: @objc_release
129 define void @test2(i32* %x, i1 %p) nounwind {
131 %a = bitcast i32* %x to i8*
132 %0 = call i8* @objc_retain(i8* %a) nounwind
133 br i1 %p, label %t, label %f
137 %b = bitcast i32* %x to float*
138 store float 2.0, float* %b
143 call void @use_pointer(i8* %0)
144 %d = bitcast i32* %x to float*
145 store float 3.0, float* %d
149 %c = bitcast i32* %x to i8*
150 call void @objc_release(i8* %c) nounwind
154 ; Like test0 but the release is in a loop,
155 ; so the optimization is not safe.
157 ; TODO: For now, assume this can't happen.
159 ; CHECK: define void @test3(
160 ; TODO: @objc_retain(i8* %a)
161 ; TODO: @objc_release
163 define void @test3(i32* %x, i1* %q) nounwind {
165 %a = bitcast i32* %x to i8*
166 %0 = call i8* @objc_retain(i8* %a) nounwind
170 %c = bitcast i32* %x to i8*
171 call void @objc_release(i8* %c) nounwind
172 %j = load volatile i1* %q
173 br i1 %j, label %loop, label %return
179 ; TODO: For now, assume this can't happen.
181 ; Like test0 but the retain is in a loop,
182 ; so the optimization is not safe.
184 ; CHECK: define void @test4(
185 ; TODO: @objc_retain(i8* %a)
186 ; TODO: @objc_release
188 define void @test4(i32* %x, i1* %q) nounwind {
193 %a = bitcast i32* %x to i8*
194 %0 = call i8* @objc_retain(i8* %a) nounwind
195 %j = load volatile i1* %q
196 br i1 %j, label %loop, label %return
199 %c = bitcast i32* %x to i8*
200 call void @objc_release(i8* %c) nounwind
204 ; Like test0 but the pointer is conditionally passed to an intervening call,
205 ; so the optimization is not safe.
207 ; CHECK: define void @test5(
208 ; CHECK: @objc_retain(i8*
209 ; CHECK: @objc_release
211 define void @test5(i32* %x, i1 %q, i8* %y) nounwind {
213 %a = bitcast i32* %x to i8*
214 %0 = call i8* @objc_retain(i8* %a) nounwind
215 %s = select i1 %q, i8* %y, i8* %0
216 call void @use_pointer(i8* %s)
218 %c = bitcast i32* %x to i8*
219 call void @objc_release(i8* %c) nounwind
223 ; retain+release pair deletion, where the release happens on two different
226 ; CHECK: define void @test6(
229 define void @test6(i32* %x, i1 %p) nounwind {
231 %a = bitcast i32* %x to i8*
232 %0 = call i8* @objc_retain(i8* %a) nounwind
233 br i1 %p, label %t, label %f
237 %b = bitcast i32* %x to float*
238 store float 2.0, float* %b
239 %ct = bitcast i32* %x to i8*
240 call void @objc_release(i8* %ct) nounwind
246 %cf = bitcast i32* %x to i8*
247 call void @objc_release(i8* %cf) nounwind
254 ; retain+release pair deletion, where the retain happens on two different
257 ; CHECK: define void @test7(
260 define void @test7(i32* %x, i1 %p) nounwind {
262 %a = bitcast i32* %x to i8*
263 br i1 %p, label %t, label %f
266 %0 = call i8* @objc_retain(i8* %a) nounwind
268 %b = bitcast i32* %x to float*
269 store float 2.0, float* %b
273 %1 = call i8* @objc_retain(i8* %a) nounwind
279 %c = bitcast i32* %x to i8*
280 call void @objc_release(i8* %c) nounwind
284 ; Like test7, but there's a retain/retainBlock mismatch. Don't delete!
286 ; CHECK: define void @test7b
288 ; CHECK: call i8* @objc_retainBlock
290 ; CHECK: call i8* @objc_retain
292 ; CHECK: call void @objc_release
294 define void @test7b(i32* %x, i1 %p) nounwind {
296 %a = bitcast i32* %x to i8*
297 br i1 %p, label %t, label %f
300 %0 = call i8* @objc_retainBlock(i8* %a) nounwind
302 %b = bitcast i32* %x to float*
303 store float 2.0, float* %b
307 %1 = call i8* @objc_retain(i8* %a) nounwind
313 %c = bitcast i32* %x to i8*
314 call void @objc_release(i8* %c) nounwind
318 ; retain+release pair deletion, where the retain and release both happen on
319 ; different flow paths. Wild!
321 ; CHECK: define void @test8(
324 define void @test8(i32* %x, i1 %p, i1 %q) nounwind {
326 %a = bitcast i32* %x to i8*
327 br i1 %p, label %t, label %f
330 %0 = call i8* @objc_retain(i8* %a) nounwind
332 %b = bitcast i32* %x to float*
333 store float 2.0, float* %b
337 %1 = call i8* @objc_retain(i8* %a) nounwind
342 br i1 %q, label %u, label %g
346 %cu = bitcast i32* %x to i8*
347 call void @objc_release(i8* %cu) nounwind
351 %cg = bitcast i32* %x to i8*
352 call void @objc_release(i8* %cg) nounwind
359 ; Trivial retain+release pair deletion.
361 ; CHECK: define void @test9(
364 define void @test9(i8* %x) nounwind {
366 %0 = call i8* @objc_retain(i8* %x) nounwind
367 call void @objc_release(i8* %0) nounwind
371 ; Retain+release pair, but on an unknown pointer relationship. Don't delete!
373 ; CHECK: define void @test9b
374 ; CHECK: @objc_retain(i8* %x)
375 ; CHECK: @objc_release(i8* %s)
377 define void @test9b(i8* %x, i1 %j, i8* %p) nounwind {
379 %0 = call i8* @objc_retain(i8* %x) nounwind
380 %s = select i1 %j, i8* %x, i8* %p
381 call void @objc_release(i8* %s) nounwind
385 ; Trivial retain+release pair with intervening calls - don't delete!
387 ; CHECK: define void @test10(
388 ; CHECK: @objc_retain(i8* %x)
390 ; CHECK: @use_pointer
391 ; CHECK: @objc_release
393 define void @test10(i8* %x) nounwind {
395 %0 = call i8* @objc_retain(i8* %x) nounwind
397 call void @use_pointer(i8* %x)
398 call void @objc_release(i8* %0) nounwind
402 ; Trivial retain+autoreleaserelease pair. Don't delete!
403 ; Also, add a tail keyword, since objc_retain can never be passed
406 ; CHECK: define void @test11(
407 ; CHECK: tail call i8* @objc_retain(i8* %x) [[NUW]]
408 ; CHECK: call i8* @objc_autorelease(i8* %0) [[NUW]]
410 define void @test11(i8* %x) nounwind {
412 %0 = call i8* @objc_retain(i8* %x) nounwind
413 call i8* @objc_autorelease(i8* %0) nounwind
414 call void @use_pointer(i8* %x)
418 ; Same as test11 but with no use_pointer call. Delete the pair!
420 ; CHECK: define void @test11a(
422 ; CHECK-NEXT: ret void
424 define void @test11a(i8* %x) nounwind {
426 %0 = call i8* @objc_retain(i8* %x) nounwind
427 call i8* @objc_autorelease(i8* %0) nounwind
431 ; Same as test11 but the value is returned. Do not perform an RV optimization
432 ; since if the frontend emitted code for an __autoreleasing variable, we may
433 ; want it to be in the autorelease pool.
435 ; CHECK: define i8* @test11b(
436 ; CHECK: tail call i8* @objc_retain(i8* %x) [[NUW]]
437 ; CHECK: call i8* @objc_autorelease(i8* %0) [[NUW]]
439 define i8* @test11b(i8* %x) nounwind {
441 %0 = call i8* @objc_retain(i8* %x) nounwind
442 call i8* @objc_autorelease(i8* %0) nounwind
446 ; Trivial retain,release pair with intervening call, but it's dominated
447 ; by another retain - delete!
449 ; CHECK: define void @test12(
451 ; CHECK-NEXT: @objc_retain(i8* %x)
454 define void @test12(i8* %x, i64 %n) {
456 call i8* @objc_retain(i8* %x) nounwind
457 call i8* @objc_retain(i8* %x) nounwind
458 call void @use_pointer(i8* %x)
459 call void @use_pointer(i8* %x)
460 call void @objc_release(i8* %x) nounwind
464 ; Trivial retain,autorelease pair. Don't delete!
466 ; CHECK: define void @test13(
467 ; CHECK: tail call i8* @objc_retain(i8* %x) [[NUW]]
468 ; CHECK: tail call i8* @objc_retain(i8* %x) [[NUW]]
469 ; CHECK: @use_pointer(i8* %x)
470 ; CHECK: call i8* @objc_autorelease(i8* %x) [[NUW]]
472 define void @test13(i8* %x, i64 %n) {
474 call i8* @objc_retain(i8* %x) nounwind
475 call i8* @objc_retain(i8* %x) nounwind
476 call void @use_pointer(i8* %x)
477 call i8* @objc_autorelease(i8* %x) nounwind
481 ; Delete the retain+release pair.
483 ; CHECK: define void @test13b
485 ; CHECK-NEXT: @objc_retain(i8* %x)
486 ; CHECK-NEXT: @use_pointer
487 ; CHECK-NEXT: @use_pointer
488 ; CHECK-NEXT: ret void
489 define void @test13b(i8* %x, i64 %n) {
491 call i8* @objc_retain(i8* %x) nounwind
492 call i8* @objc_retain(i8* %x) nounwind
493 call void @use_pointer(i8* %x)
494 call void @use_pointer(i8* %x)
495 call void @objc_release(i8* %x) nounwind
499 ; Don't delete the retain+release pair because there's an
500 ; autoreleasePoolPop in the way.
502 ; CHECK: define void @test13c
503 ; CHECK: @objc_retain(i8* %x)
504 ; CHECK: @objc_autoreleasePoolPop
505 ; CHECK: @objc_retain(i8* %x)
506 ; CHECK: @use_pointer
507 ; CHECK: @objc_release
509 define void @test13c(i8* %x, i64 %n) {
511 call i8* @objc_retain(i8* %x) nounwind
512 call void @objc_autoreleasePoolPop(i8* undef)
513 call i8* @objc_retain(i8* %x) nounwind
514 call void @use_pointer(i8* %x)
515 call void @use_pointer(i8* %x)
516 call void @objc_release(i8* %x) nounwind
520 ; Like test13c, but there's an autoreleasePoolPush in the way, but that
523 ; CHECK: define void @test13d
525 ; CHECK-NEXT: @objc_retain(i8* %x)
526 ; CHECK-NEXT: @objc_autoreleasePoolPush
527 ; CHECK-NEXT: @use_pointer
528 ; CHECK-NEXT: @use_pointer
529 ; CHECK-NEXT: ret void
530 define void @test13d(i8* %x, i64 %n) {
532 call i8* @objc_retain(i8* %x) nounwind
533 call i8* @objc_autoreleasePoolPush()
534 call i8* @objc_retain(i8* %x) nounwind
535 call void @use_pointer(i8* %x)
536 call void @use_pointer(i8* %x)
537 call void @objc_release(i8* %x) nounwind
541 ; Trivial retain,release pair with intervening call, but it's post-dominated
542 ; by another release - delete!
544 ; CHECK: define void @test14(
546 ; CHECK-NEXT: @use_pointer
547 ; CHECK-NEXT: @use_pointer
548 ; CHECK-NEXT: @objc_release
549 ; CHECK-NEXT: ret void
551 define void @test14(i8* %x, i64 %n) {
553 call i8* @objc_retain(i8* %x) nounwind
554 call void @use_pointer(i8* %x)
555 call void @use_pointer(i8* %x)
556 call void @objc_release(i8* %x) nounwind
557 call void @objc_release(i8* %x) nounwind
561 ; Trivial retain,autorelease pair with intervening call, but it's post-dominated
562 ; by another release. Don't delete anything.
564 ; CHECK: define void @test15(
566 ; CHECK-NEXT: @objc_retain(i8* %x)
567 ; CHECK-NEXT: @use_pointer
568 ; CHECK-NEXT: @objc_autorelease(i8* %x)
569 ; CHECK-NEXT: @objc_release
570 ; CHECK-NEXT: ret void
572 define void @test15(i8* %x, i64 %n) {
574 call i8* @objc_retain(i8* %x) nounwind
575 call void @use_pointer(i8* %x)
576 call i8* @objc_autorelease(i8* %x) nounwind
577 call void @objc_release(i8* %x) nounwind
581 ; Trivial retain,autorelease pair, post-dominated
582 ; by another release. Delete the retain and release.
584 ; CHECK: define void @test15b
586 ; CHECK-NEXT: @objc_autorelease
587 ; CHECK-NEXT: ret void
589 define void @test15b(i8* %x, i64 %n) {
591 call i8* @objc_retain(i8* %x) nounwind
592 call i8* @objc_autorelease(i8* %x) nounwind
593 call void @objc_release(i8* %x) nounwind
597 ; Retain+release pairs in diamonds, all dominated by a retain.
599 ; CHECK: define void @test16(
600 ; CHECK: @objc_retain(i8* %x)
603 define void @test16(i1 %a, i1 %b, i8* %x) {
605 call i8* @objc_retain(i8* %x) nounwind
606 br i1 %a, label %red, label %orange
609 call i8* @objc_retain(i8* %x) nounwind
613 call i8* @objc_retain(i8* %x) nounwind
617 call void @use_pointer(i8* %x)
618 call void @use_pointer(i8* %x)
619 br i1 %b, label %green, label %blue
622 call void @objc_release(i8* %x) nounwind
626 call void @objc_release(i8* %x) nounwind
633 ; Retain+release pairs in diamonds, all post-dominated by a release.
635 ; CHECK: define void @test17(
638 ; CHECK: @objc_release
640 define void @test17(i1 %a, i1 %b, i8* %x) {
642 br i1 %a, label %red, label %orange
645 call i8* @objc_retain(i8* %x) nounwind
649 call i8* @objc_retain(i8* %x) nounwind
653 call void @use_pointer(i8* %x)
654 call void @use_pointer(i8* %x)
655 br i1 %b, label %green, label %blue
658 call void @objc_release(i8* %x) nounwind
662 call void @objc_release(i8* %x) nounwind
666 call void @objc_release(i8* %x) nounwind
672 ; CHECK: define void @test18(
675 define void @test18() {
676 call i8* @objc_retain(i8* null)
677 call void @objc_release(i8* null)
678 call i8* @objc_autorelease(i8* null)
682 ; Delete no-ops where undef can be assumed to be null.
684 ; CHECK: define void @test18b
687 define void @test18b() {
688 call i8* @objc_retain(i8* undef)
689 call void @objc_release(i8* undef)
690 call i8* @objc_autorelease(i8* undef)
694 ; Replace uses of arguments with uses of return values, to reduce
697 ; CHECK: define void @test19(i32* %y) {
698 ; CHECK: %z = bitcast i32* %y to i8*
699 ; CHECK: %0 = bitcast i32* %y to i8*
700 ; CHECK: %1 = tail call i8* @objc_retain(i8* %0)
701 ; CHECK: call void @use_pointer(i8* %z)
702 ; CHECK: call void @use_pointer(i8* %z)
703 ; CHECK: %2 = bitcast i32* %y to i8*
704 ; CHECK: call void @objc_release(i8* %2)
707 define void @test19(i32* %y) {
709 %x = bitcast i32* %y to i8*
710 %0 = call i8* @objc_retain(i8* %x) nounwind
711 %z = bitcast i32* %y to i8*
712 call void @use_pointer(i8* %z)
713 call void @use_pointer(i8* %z)
714 call void @objc_release(i8* %x)
720 ; CHECK: define void @test20(
721 ; CHECK: %tmp1 = tail call i8* @objc_retain(i8* %tmp) [[NUW]]
723 define void @test20(double* %self) {
725 %tmp = bitcast double* %self to i8*
726 %tmp1 = call i8* @objc_retain(i8* %tmp) nounwind
727 invoke void @invokee()
728 to label %invoke.cont23 unwind label %lpad20
730 invoke.cont23: ; preds = %if.then12
731 invoke void @invokee()
732 to label %if.end unwind label %lpad20
734 lpad20: ; preds = %invoke.cont23, %if.then12
735 %tmp502 = phi double* [ undef, %invoke.cont23 ], [ %self, %if.then12 ]
736 %exn = landingpad {i8*, i32} personality i32 (...)* @__gxx_personality_v0
740 if.end: ; preds = %invoke.cont23
744 ; Delete a redundant retain,autorelease when forwaring a call result
745 ; directly to a return value.
747 ; CHECK: define i8* @test21(
748 ; CHECK: call i8* @returner()
749 ; CHECK-NEXT: ret i8* %call
750 define i8* @test21() {
752 %call = call i8* @returner()
753 %0 = call i8* @objc_retain(i8* %call) nounwind
754 %1 = call i8* @objc_autorelease(i8* %0) nounwind
758 ; Move an objc call up through a phi that has null operands.
760 ; CHECK: define void @test22(
762 ; CHECK: %1 = bitcast double* %p to i8*
763 ; CHECK: call void @objc_release(i8* %1)
765 ; CHECK: C: ; preds = %B, %A
766 ; CHECK-NOT: @objc_release
768 define void @test22(double* %p, i1 %a) {
769 br i1 %a, label %A, label %B
775 %h = phi double* [ null, %A ], [ %p, %B ]
776 %c = bitcast double* %h to i8*
777 call void @objc_release(i8* %c)
781 ; Optimize objc_retainBlock.
783 ; CHECK: define void @test23(
786 %block0 = type { i64, i64, i8*, i8* }
787 %block1 = type { i8**, i32, i32, i32 (%struct.__block_literal_1*)*, %block0* }
788 %struct.__block_descriptor = type { i64, i64 }
789 %struct.__block_literal_1 = type { i8**, i32, i32, i8**, %struct.__block_descriptor* }
790 @__block_holder_tmp_1 = external constant %block1
791 define void @test23() {
793 %0 = call i8* @objc_retainBlock(i8* bitcast (%block1* @__block_holder_tmp_1 to i8*)) nounwind, !clang.arc.copy_on_escape !0
794 call void @bar(i32 ()* bitcast (%block1* @__block_holder_tmp_1 to i32 ()*))
795 call void @bar(i32 ()* bitcast (%block1* @__block_holder_tmp_1 to i32 ()*))
796 call void @objc_release(i8* bitcast (%block1* @__block_holder_tmp_1 to i8*)) nounwind
800 ; Don't optimize objc_retainBlock, but do strength reduce it.
802 ; CHECK: define void @test23b
803 ; CHECK: @objc_retain
804 ; CHECK: @objc_release
806 define void @test23b(i8* %p) {
808 %0 = call i8* @objc_retainBlock(i8* %p) nounwind, !clang.arc.copy_on_escape !0
810 call void @use_pointer(i8* %p)
811 call void @objc_release(i8* %p) nounwind
815 ; Don't optimize objc_retainBlock, because there's no copy_on_escape metadata.
817 ; CHECK: define void @test23c(
818 ; CHECK: @objc_retainBlock
819 ; CHECK: @objc_release
821 define void @test23c() {
823 %0 = call i8* @objc_retainBlock(i8* bitcast (%block1* @__block_holder_tmp_1 to i8*)) nounwind
824 call void @bar(i32 ()* bitcast (%block1* @__block_holder_tmp_1 to i32 ()*))
825 call void @bar(i32 ()* bitcast (%block1* @__block_holder_tmp_1 to i32 ()*))
826 call void @objc_release(i8* bitcast (%block1* @__block_holder_tmp_1 to i8*)) nounwind
830 ; Any call can decrement a retain count.
832 ; CHECK: define void @test24(
833 ; CHECK: @objc_retain(i8* %a)
834 ; CHECK: @objc_release
836 define void @test24(i8* %r, i8* %a) {
837 call i8* @objc_retain(i8* %a)
838 call void @use_pointer(i8* %r)
840 call void @objc_release(i8* %a)
844 ; Don't move a retain/release pair if the release can be moved
845 ; but the retain can't be moved to balance it.
847 ; CHECK: define void @test25(
849 ; CHECK: call i8* @objc_retain(i8* %p)
852 ; CHECK: call void @objc_release(i8* %p)
854 define void @test25(i8* %p, i1 %x) {
856 %f0 = call i8* @objc_retain(i8* %p)
858 br i1 %x, label %true, label %done
865 call void @objc_release(i8* %p)
869 ; Don't move a retain/release pair if the retain can be moved
870 ; but the release can't be moved to balance it.
872 ; CHECK: define void @test26(
874 ; CHECK: call i8* @objc_retain(i8* %p)
877 ; CHECK: call void @objc_release(i8* %p)
879 define void @test26(i8* %p, i1 %x) {
881 %f0 = call i8* @objc_retain(i8* %p)
882 br i1 %x, label %true, label %done
890 call void @objc_release(i8* %p)
894 ; Don't sink the retain,release into the loop.
896 ; CHECK: define void @test27(
898 ; CHECK: call i8* @objc_retain(i8* %p)
902 ; CHECK: call void @objc_release
904 define void @test27(i8* %p, i1 %x, i1 %y) {
906 %f0 = call i8* @objc_retain(i8* %p)
907 br i1 %x, label %loop, label %done
912 br i1 %y, label %done, label %loop
915 call void @objc_release(i8* %p)
919 ; Trivial code motion case: Triangle.
921 ; CHECK: define void @test28(
924 ; CHECK: call i8* @objc_retain(
925 ; CHECK: call void @callee()
927 ; CHECK: call void @objc_release
931 define void @test28(i8* %p, i1 %x) {
933 %f0 = call i8* @objc_retain(i8* %p)
934 br i1 %x, label %true, label %done
942 call void @objc_release(i8* %p), !clang.imprecise_release !0
946 ; Trivial code motion case: Triangle, but no metadata. Don't move past
947 ; unrelated memory references!
949 ; CHECK: define void @test28b
950 ; CHECK: call i8* @objc_retain(
953 ; CHECK: call void @callee()
958 ; CHECK: @objc_release
960 define void @test28b(i8* %p, i1 %x, i8* noalias %t) {
962 %f0 = call i8* @objc_retain(i8* %p)
963 br i1 %x, label %true, label %done
972 call void @objc_release(i8* %p)
976 ; Trivial code motion case: Triangle, with metadata. Do move past
977 ; unrelated memory references! And preserve the metadata.
979 ; CHECK: define void @test28c
982 ; CHECK: call i8* @objc_retain(
983 ; CHECK: call void @callee()
985 ; CHECK: call void @objc_release(i8* %p) [[NUW]], !clang.imprecise_release
989 define void @test28c(i8* %p, i1 %x, i8* noalias %t) {
991 %f0 = call i8* @objc_retain(i8* %p)
992 br i1 %x, label %true, label %done
1001 call void @objc_release(i8* %p), !clang.imprecise_release !0
1005 ; Like test28. but with two releases.
1007 ; CHECK: define void @test29(
1010 ; CHECK: call i8* @objc_retain(
1011 ; CHECK: call void @callee()
1013 ; CHECK: call void @objc_release
1014 ; CHECK-NOT: @objc_release
1020 define void @test29(i8* %p, i1 %x, i1 %y) {
1022 %f0 = call i8* @objc_retain(i8* %p)
1023 br i1 %x, label %true, label %done
1028 br i1 %y, label %done, label %ohno
1031 call void @objc_release(i8* %p)
1035 call void @objc_release(i8* %p)
1039 ; Basic case with the use and call in a diamond
1040 ; with an extra release.
1042 ; CHECK: define void @test30(
1045 ; CHECK: call i8* @objc_retain(
1046 ; CHECK: call void @callee()
1048 ; CHECK: call void @objc_release
1049 ; CHECK-NOT: @objc_release
1057 define void @test30(i8* %p, i1 %x, i1 %y, i1 %z) {
1059 %f0 = call i8* @objc_retain(i8* %p)
1060 br i1 %x, label %true, label %false
1065 br i1 %y, label %done, label %ohno
1068 br i1 %z, label %done, label %ohno
1071 call void @objc_release(i8* %p)
1075 call void @objc_release(i8* %p)
1079 ; Basic case with a mergeable release.
1081 ; CHECK: define void @test31(
1082 ; CHECK: call i8* @objc_retain(i8* %p)
1083 ; CHECK: call void @callee()
1085 ; CHECK: call void @objc_release
1086 ; CHECK-NOT: @objc_release
1088 ; CHECK-NOT: @objc_release
1090 ; CHECK-NOT: @objc_release
1092 ; CHECK-NOT: @objc_release
1094 define void @test31(i8* %p, i1 %x) {
1096 %f0 = call i8* @objc_retain(i8* %p)
1099 br i1 %x, label %true, label %false
1101 call void @objc_release(i8* %p)
1104 call void @objc_release(i8* %p)
1108 ; Don't consider bitcasts or getelementptrs direct uses.
1110 ; CHECK: define void @test32(
1113 ; CHECK: call i8* @objc_retain(
1114 ; CHECK: call void @callee()
1116 ; CHECK: call void @objc_release
1120 define void @test32(i8* %p, i1 %x) {
1122 %f0 = call i8* @objc_retain(i8* %p)
1123 br i1 %x, label %true, label %done
1131 %g = bitcast i8* %p to i8*
1132 %h = getelementptr i8* %g, i64 0
1133 call void @objc_release(i8* %g)
1137 ; Do consider icmps to be direct uses.
1139 ; CHECK: define void @test33(
1142 ; CHECK: call i8* @objc_retain(
1143 ; CHECK: call void @callee()
1145 ; CHECK: call void @objc_release
1149 define void @test33(i8* %p, i1 %x, i8* %y) {
1151 %f0 = call i8* @objc_retain(i8* %p)
1152 br i1 %x, label %true, label %done
1156 %v = icmp eq i8* %p, %y
1160 %g = bitcast i8* %p to i8*
1161 %h = getelementptr i8* %g, i64 0
1162 call void @objc_release(i8* %g)
1166 ; Delete retain,release if there's just a possible dec.
1168 ; CHECK: define void @test34(
1171 define void @test34(i8* %p, i1 %x, i8* %y) {
1173 %f0 = call i8* @objc_retain(i8* %p)
1174 br i1 %x, label %true, label %done
1181 %g = bitcast i8* %p to i8*
1182 %h = getelementptr i8* %g, i64 0
1183 call void @objc_release(i8* %g)
1187 ; Delete retain,release if there's just a use.
1189 ; CHECK: define void @test35(
1192 define void @test35(i8* %p, i1 %x, i8* %y) {
1194 %f0 = call i8* @objc_retain(i8* %p)
1195 br i1 %x, label %true, label %done
1198 %v = icmp eq i8* %p, %y
1202 %g = bitcast i8* %p to i8*
1203 %h = getelementptr i8* %g, i64 0
1204 call void @objc_release(i8* %g)
1208 ; Delete a retain,release if there's no actual use.
1210 ; CHECK: define void @test36(
1212 ; CHECK: call void @callee()
1214 ; CHECK: call void @callee()
1217 define void @test36(i8* %p) {
1219 call i8* @objc_retain(i8* %p)
1222 call void @objc_release(i8* %p)
1226 ; Like test36, but with metadata.
1228 ; CHECK: define void @test37(
1231 define void @test37(i8* %p) {
1233 call i8* @objc_retain(i8* %p)
1236 call void @objc_release(i8* %p), !clang.imprecise_release !0
1240 ; Be aggressive about analyzing phis to eliminate possible uses.
1242 ; CHECK: define void @test38(
1245 define void @test38(i8* %p, i1 %u, i1 %m, i8* %z, i8* %y, i8* %x, i8* %w) {
1247 call i8* @objc_retain(i8* %p)
1248 br i1 %u, label %true, label %false
1250 br i1 %m, label %a, label %b
1252 br i1 %m, label %c, label %d
1262 %j = phi i8* [ %z, %a ], [ %y, %b ]
1265 %k = phi i8* [ %w, %c ], [ %x, %d ]
1268 %h = phi i8* [ %j, %e ], [ %k, %f ]
1269 call void @use_pointer(i8* %h)
1270 call void @objc_release(i8* %p), !clang.imprecise_release !0
1274 ; Delete retain,release pairs around loops.
1276 ; CHECK: define void @test39(
1279 define void @test39(i8* %p) {
1281 %0 = call i8* @objc_retain(i8* %p)
1284 loop: ; preds = %loop, %entry
1285 br i1 undef, label %loop, label %exit
1287 exit: ; preds = %loop
1288 call void @objc_release(i8* %0), !clang.imprecise_release !0
1292 ; Delete retain,release pairs around loops containing uses.
1294 ; CHECK: define void @test39b(
1297 define void @test39b(i8* %p) {
1299 %0 = call i8* @objc_retain(i8* %p)
1302 loop: ; preds = %loop, %entry
1304 br i1 undef, label %loop, label %exit
1306 exit: ; preds = %loop
1307 call void @objc_release(i8* %0), !clang.imprecise_release !0
1311 ; Delete retain,release pairs around loops containing potential decrements.
1313 ; CHECK: define void @test39c(
1316 define void @test39c(i8* %p) {
1318 %0 = call i8* @objc_retain(i8* %p)
1321 loop: ; preds = %loop, %entry
1322 call void @use_pointer(i8* %0)
1323 br i1 undef, label %loop, label %exit
1325 exit: ; preds = %loop
1326 call void @objc_release(i8* %0), !clang.imprecise_release !0
1330 ; Delete retain,release pairs around loops even if
1331 ; the successors are in a different order.
1333 ; CHECK: define void @test40(
1336 define void @test40(i8* %p) {
1338 %0 = call i8* @objc_retain(i8* %p)
1341 loop: ; preds = %loop, %entry
1342 call void @use_pointer(i8* %0)
1343 br i1 undef, label %exit, label %loop
1345 exit: ; preds = %loop
1346 call void @objc_release(i8* %0), !clang.imprecise_release !0
1350 ; Do the known-incremented retain+release elimination even if the pointer
1351 ; is also autoreleased.
1353 ; CHECK: define void @test42(
1354 ; CHECK-NEXT: entry:
1355 ; CHECK-NEXT: call i8* @objc_retain(i8* %p)
1356 ; CHECK-NEXT: call i8* @objc_autorelease(i8* %p)
1357 ; CHECK-NEXT: call void @use_pointer(i8* %p)
1358 ; CHECK-NEXT: call void @use_pointer(i8* %p)
1359 ; CHECK-NEXT: ret void
1361 define void @test42(i8* %p) {
1363 call i8* @objc_retain(i8* %p)
1364 call i8* @objc_autorelease(i8* %p)
1365 call i8* @objc_retain(i8* %p)
1366 call void @use_pointer(i8* %p)
1367 call void @use_pointer(i8* %p)
1368 call void @objc_release(i8* %p)
1372 ; Don't the known-incremented retain+release elimination if the pointer is
1373 ; autoreleased and there's an autoreleasePoolPop.
1375 ; CHECK: define void @test43(
1376 ; CHECK-NEXT: entry:
1377 ; CHECK-NEXT: call i8* @objc_retain(i8* %p)
1378 ; CHECK-NEXT: call i8* @objc_autorelease(i8* %p)
1379 ; CHECK-NEXT: call i8* @objc_retain
1380 ; CHECK-NEXT: call void @use_pointer(i8* %p)
1381 ; CHECK-NEXT: call void @use_pointer(i8* %p)
1382 ; CHECK-NEXT: call void @objc_autoreleasePoolPop(i8* undef)
1383 ; CHECK-NEXT: call void @objc_release
1384 ; CHECK-NEXT: ret void
1386 define void @test43(i8* %p) {
1388 call i8* @objc_retain(i8* %p)
1389 call i8* @objc_autorelease(i8* %p)
1390 call i8* @objc_retain(i8* %p)
1391 call void @use_pointer(i8* %p)
1392 call void @use_pointer(i8* %p)
1393 call void @objc_autoreleasePoolPop(i8* undef)
1394 call void @objc_release(i8* %p)
1398 ; Do the known-incremented retain+release elimination if the pointer is
1399 ; autoreleased and there's an autoreleasePoolPush.
1401 ; CHECK: define void @test43b
1402 ; CHECK-NEXT: entry:
1403 ; CHECK-NEXT: call i8* @objc_retain(i8* %p)
1404 ; CHECK-NEXT: call i8* @objc_autorelease(i8* %p)
1405 ; CHECK-NEXT: call void @use_pointer(i8* %p)
1406 ; CHECK-NEXT: call void @use_pointer(i8* %p)
1407 ; CHECK-NEXT: call i8* @objc_autoreleasePoolPush()
1408 ; CHECK-NEXT: ret void
1410 define void @test43b(i8* %p) {
1412 call i8* @objc_retain(i8* %p)
1413 call i8* @objc_autorelease(i8* %p)
1414 call i8* @objc_retain(i8* %p)
1415 call void @use_pointer(i8* %p)
1416 call void @use_pointer(i8* %p)
1417 call i8* @objc_autoreleasePoolPush()
1418 call void @objc_release(i8* %p)
1422 ; Do retain+release elimination for non-provenance pointers.
1424 ; CHECK: define void @test44(
1427 define void @test44(i8** %pp) {
1429 %q = call i8* @objc_retain(i8* %p)
1430 call void @objc_release(i8* %q)
1434 ; Don't delete retain+release with an unknown-provenance
1435 ; may-alias objc_release between them.
1437 ; CHECK: define void @test45(
1438 ; CHECK: call i8* @objc_retain(i8* %p)
1439 ; CHECK: call void @objc_release(i8* %q)
1440 ; CHECK: call void @use_pointer(i8* %p)
1441 ; CHECK: call void @objc_release(i8* %p)
1442 define void @test45(i8** %pp, i8** %qq) {
1445 call i8* @objc_retain(i8* %p)
1446 call void @objc_release(i8* %q)
1447 call void @use_pointer(i8* %p)
1448 call void @objc_release(i8* %p)
1452 ; Don't delete retain and autorelease here.
1454 ; CHECK: define void @test46(
1455 ; CHECK: tail call i8* @objc_retain(i8* %p) [[NUW]]
1457 ; CHECK: call i8* @objc_autorelease(i8* %p) [[NUW]]
1458 define void @test46(i8* %p, i1 %a) {
1460 call i8* @objc_retain(i8* %p)
1461 br i1 %a, label %true, label %false
1464 call i8* @objc_autorelease(i8* %p)
1465 call void @use_pointer(i8* %p)
1472 ; Delete no-op cast calls.
1474 ; CHECK: define i8* @test47(
1477 define i8* @test47(i8* %p) nounwind {
1478 %x = call i8* @objc_retainedObject(i8* %p)
1482 ; Delete no-op cast calls.
1484 ; CHECK: define i8* @test48(
1487 define i8* @test48(i8* %p) nounwind {
1488 %x = call i8* @objc_unretainedObject(i8* %p)
1492 ; Delete no-op cast calls.
1494 ; CHECK: define i8* @test49(
1497 define i8* @test49(i8* %p) nounwind {
1498 %x = call i8* @objc_unretainedPointer(i8* %p)
1502 ; Do delete retain+release with intervening stores of the
1505 ; CHECK: define void @test50(
1508 define void @test50(i8* %p, i8** %pp) {
1509 call i8* @objc_retain(i8* %p)
1511 store i8* %p, i8** %pp
1512 call void @objc_release(i8* %p)
1516 ; Don't delete retain+release with intervening stores through the
1519 ; CHECK: define void @test51(
1520 ; CHECK: call i8* @objc_retain(i8* %p)
1521 ; CHECK: call void @objc_release(i8* %p)
1522 define void @test51(i8* %p) {
1523 call i8* @objc_retain(i8* %p)
1526 call void @objc_release(i8* %p)
1530 ; Don't delete retain+release with intervening use of a pointer of
1531 ; unknown provenance.
1533 ; CHECK: define void @test52(
1534 ; CHECK: call i8* @objc_retain
1535 ; CHECK: call void @callee()
1536 ; CHECK: call void @use_pointer(i8* %z)
1537 ; CHECK: call void @objc_release
1538 define void @test52(i8** %zz, i8** %pp) {
1540 %1 = call i8* @objc_retain(i8* %p)
1543 call void @use_pointer(i8* %z)
1544 call void @objc_release(i8* %p)
1548 ; Like test52, but the pointer has function type, so it's assumed to
1549 ; be not reference counted.
1550 ; Oops. That's wrong. Clang sometimes uses function types gratuitously.
1551 ; See rdar://10551239.
1553 ; CHECK: define void @test53(
1556 define void @test53(void ()** %zz, i8** %pp) {
1558 %1 = call i8* @objc_retain(i8* %p)
1560 %z = load void ()** %zz
1561 call void @callee_fnptr(void ()* %z)
1562 call void @objc_release(i8* %p)
1566 ; Convert autorelease to release if the value is unused.
1568 ; CHECK: define void @test54(
1569 ; CHECK: call i8* @returner()
1570 ; CHECK-NEXT: call void @objc_release(i8* %t) [[NUW]], !clang.imprecise_release !0
1571 ; CHECK-NEXT: ret void
1572 define void @test54() {
1573 %t = call i8* @returner()
1574 call i8* @objc_autorelease(i8* %t)
1578 ; Nested retain+release pairs. Delete them both.
1580 ; CHECK: define void @test55(
1583 define void @test55(i8* %x) {
1585 %0 = call i8* @objc_retain(i8* %x) nounwind
1586 %1 = call i8* @objc_retain(i8* %x) nounwind
1587 call void @objc_release(i8* %x) nounwind
1588 call void @objc_release(i8* %x) nounwind
1592 ; Nested retain+release pairs where the inner pair depends
1593 ; on the outer pair to be removed, and then the outer pair
1594 ; can be partially eliminated. Plus an extra outer pair to
1595 ; eliminate, for fun.
1597 ; CHECK: define void @test56(
1600 ; CHECK-NEXT: %0 = tail call i8* @objc_retain(i8* %x) [[NUW]]
1601 ; CHECK-NEXT: tail call void @use_pointer(i8* %x)
1602 ; CHECK-NEXT: tail call void @use_pointer(i8* %x)
1603 ; CHECK-NEXT: tail call void @objc_release(i8* %x) [[NUW]], !clang.imprecise_release !0
1604 ; CHECK-NEXT: br label %if.end
1607 define void @test56(i8* %x, i32 %n) {
1609 %0 = tail call i8* @objc_retain(i8* %x) nounwind
1610 %1 = tail call i8* @objc_retain(i8* %0) nounwind
1611 %tobool = icmp eq i32 %n, 0
1612 br i1 %tobool, label %if.end, label %if.then
1614 if.then: ; preds = %entry
1615 %2 = tail call i8* @objc_retain(i8* %1) nounwind
1616 tail call void @use_pointer(i8* %2)
1617 tail call void @use_pointer(i8* %2)
1618 tail call void @objc_release(i8* %2) nounwind, !clang.imprecise_release !0
1621 if.end: ; preds = %entry, %if.then
1622 tail call void @objc_release(i8* %1) nounwind, !clang.imprecise_release !0
1623 tail call void @objc_release(i8* %0) nounwind, !clang.imprecise_release !0
1627 ; When there are adjacent retain+release pairs, the first one is
1628 ; known unnecessary because the presence of the second one means that
1629 ; the first one won't be deleting the object.
1631 ; CHECK: define void @test57(
1632 ; CHECK-NEXT: entry:
1633 ; CHECK-NEXT: call void @use_pointer(i8* %x)
1634 ; CHECK-NEXT: call void @use_pointer(i8* %x)
1635 ; CHECK-NEXT: %0 = tail call i8* @objc_retain(i8* %x) [[NUW]]
1636 ; CHECK-NEXT: call void @use_pointer(i8* %x)
1637 ; CHECK-NEXT: call void @use_pointer(i8* %x)
1638 ; CHECK-NEXT: call void @objc_release(i8* %x) [[NUW]]
1639 ; CHECK-NEXT: ret void
1641 define void @test57(i8* %x) nounwind {
1643 call i8* @objc_retain(i8* %x) nounwind
1644 call void @use_pointer(i8* %x)
1645 call void @use_pointer(i8* %x)
1646 call void @objc_release(i8* %x) nounwind
1647 call i8* @objc_retain(i8* %x) nounwind
1648 call void @use_pointer(i8* %x)
1649 call void @use_pointer(i8* %x)
1650 call void @objc_release(i8* %x) nounwind
1654 ; An adjacent retain+release pair is sufficient even if it will be
1657 ; CHECK: define void @test58(
1658 ; CHECK-NEXT: entry:
1659 ; CHECK-NEXT: call void @use_pointer(i8* %x)
1660 ; CHECK-NEXT: call void @use_pointer(i8* %x)
1661 ; CHECK-NEXT: ret void
1663 define void @test58(i8* %x) nounwind {
1665 call i8* @objc_retain(i8* %x) nounwind
1666 call void @use_pointer(i8* %x)
1667 call void @use_pointer(i8* %x)
1668 call void @objc_release(i8* %x) nounwind
1669 call i8* @objc_retain(i8* %x) nounwind
1670 call void @objc_release(i8* %x) nounwind
1674 ; Don't delete the second retain+release pair in an adjacent set.
1676 ; CHECK: define void @test59(
1677 ; CHECK-NEXT: entry:
1678 ; CHECK-NEXT: %0 = tail call i8* @objc_retain(i8* %x) [[NUW]]
1679 ; CHECK-NEXT: call void @use_pointer(i8* %x)
1680 ; CHECK-NEXT: call void @use_pointer(i8* %x)
1681 ; CHECK-NEXT: call void @objc_release(i8* %x) [[NUW]]
1682 ; CHECK-NEXT: ret void
1684 define void @test59(i8* %x) nounwind {
1686 %a = call i8* @objc_retain(i8* %x) nounwind
1687 call void @objc_release(i8* %x) nounwind
1688 %b = call i8* @objc_retain(i8* %x) nounwind
1689 call void @use_pointer(i8* %x)
1690 call void @use_pointer(i8* %x)
1691 call void @objc_release(i8* %x) nounwind
1695 ; Constant pointers to objects don't need reference counting.
1697 @constptr = external constant i8*
1698 @something = external global i8*
1700 ; CHECK: define void @test60(
1703 define void @test60() {
1704 %t = load i8** @constptr
1705 %s = load i8** @something
1706 call i8* @objc_retain(i8* %s)
1708 call void @use_pointer(i8* %t)
1709 call void @objc_release(i8* %s)
1713 ; Constant pointers to objects don't need to be considered related to other
1716 ; CHECK: define void @test61(
1719 define void @test61() {
1720 %t = load i8** @constptr
1721 call i8* @objc_retain(i8* %t)
1723 call void @use_pointer(i8* %t)
1724 call void @objc_release(i8* %t)
1728 ; Delete a retain matched by releases when one is inside the loop and the
1729 ; other is outside the loop.
1731 ; CHECK: define void @test62(
1734 define void @test62(i8* %x, i1* %p) nounwind {
1739 call i8* @objc_retain(i8* %x)
1741 br i1 %q, label %loop.more, label %exit
1744 call void @objc_release(i8* %x)
1748 call void @objc_release(i8* %x)
1752 ; Like test62 but with no release in exit.
1753 ; Don't delete anything!
1755 ; CHECK: define void @test63(
1757 ; CHECK: tail call i8* @objc_retain(i8* %x)
1759 ; CHECK: call void @objc_release(i8* %x)
1761 define void @test63(i8* %x, i1* %p) nounwind {
1766 call i8* @objc_retain(i8* %x)
1768 br i1 %q, label %loop.more, label %exit
1771 call void @objc_release(i8* %x)
1778 ; Like test62 but with no release in loop.more.
1779 ; Don't delete anything!
1781 ; CHECK: define void @test64(
1783 ; CHECK: tail call i8* @objc_retain(i8* %x)
1785 ; CHECK: call void @objc_release(i8* %x)
1787 define void @test64(i8* %x, i1* %p) nounwind {
1792 call i8* @objc_retain(i8* %x)
1794 br i1 %q, label %loop.more, label %exit
1800 call void @objc_release(i8* %x)
1804 ; Move an autorelease past a phi with a null.
1806 ; CHECK: define i8* @test65(
1808 ; CHECK: call i8* @objc_autorelease(
1810 ; CHECK-NOT: @objc_autorelease
1812 define i8* @test65(i1 %x) {
1814 br i1 %x, label %return, label %if.then
1816 if.then: ; preds = %entry
1817 %c = call i8* @returner()
1818 %s = call i8* @objc_retainAutoreleasedReturnValue(i8* %c) nounwind
1821 return: ; preds = %if.then, %entry
1822 %retval = phi i8* [ %s, %if.then ], [ null, %entry ]
1823 %q = call i8* @objc_autorelease(i8* %retval) nounwind
1827 ; Don't move an autorelease past an autorelease pool boundary.
1829 ; CHECK: define i8* @test65b(
1831 ; CHECK-NOT: @objc_autorelease
1833 ; CHECK: call i8* @objc_autorelease(
1835 define i8* @test65b(i1 %x) {
1837 %t = call i8* @objc_autoreleasePoolPush()
1838 br i1 %x, label %return, label %if.then
1840 if.then: ; preds = %entry
1841 %c = call i8* @returner()
1842 %s = call i8* @objc_retainAutoreleasedReturnValue(i8* %c) nounwind
1845 return: ; preds = %if.then, %entry
1846 %retval = phi i8* [ %s, %if.then ], [ null, %entry ]
1847 call void @objc_autoreleasePoolPop(i8* %t)
1848 %q = call i8* @objc_autorelease(i8* %retval) nounwind
1852 ; Don't move an autoreleaseReuturnValue, which would break
1853 ; the RV optimization.
1855 ; CHECK: define i8* @test65c(
1857 ; CHECK-NOT: @objc_autorelease
1859 ; CHECK: call i8* @objc_autoreleaseReturnValue(
1861 define i8* @test65c(i1 %x) {
1863 br i1 %x, label %return, label %if.then
1865 if.then: ; preds = %entry
1866 %c = call i8* @returner()
1867 %s = call i8* @objc_retainAutoreleasedReturnValue(i8* %c) nounwind
1870 return: ; preds = %if.then, %entry
1871 %retval = phi i8* [ %s, %if.then ], [ null, %entry ]
1872 %q = call i8* @objc_autoreleaseReturnValue(i8* %retval) nounwind
1876 ; An objc_retain can serve as a may-use for a different pointer.
1879 ; CHECK: define void @test66(
1880 ; CHECK: %tmp7 = tail call i8* @objc_retain(i8* %cond) [[NUW]]
1881 ; CHECK: tail call void @objc_release(i8* %cond) [[NUW]]
1883 define void @test66(i8* %tmp5, i8* %bar, i1 %tobool, i1 %tobool1, i8* %call) {
1885 br i1 %tobool, label %cond.true, label %cond.end
1890 cond.end: ; preds = %cond.true, %entry
1891 %cond = phi i8* [ %tmp5, %cond.true ], [ %call, %entry ]
1892 %tmp7 = tail call i8* @objc_retain(i8* %cond) nounwind
1893 tail call void @objc_release(i8* %call) nounwind
1894 %tmp8 = select i1 %tobool1, i8* %cond, i8* %bar
1895 %tmp9 = tail call i8* @objc_retain(i8* %tmp8) nounwind
1896 tail call void @objc_release(i8* %cond) nounwind
1900 declare void @bar(i32 ()*)
1902 ; A few real-world testcases.
1904 @.str4 = private unnamed_addr constant [33 x i8] c"-[A z] = { %f, %f, { %f, %f } }\0A\00"
1905 @"OBJC_IVAR_$_A.myZ" = global i64 20, section "__DATA, __objc_const", align 8
1906 declare i32 @printf(i8* nocapture, ...) nounwind
1907 declare i32 @puts(i8* nocapture) nounwind
1908 @str = internal constant [16 x i8] c"-[ Top0 _getX ]\00"
1910 ; CHECK: @"\01-[A z]"
1914 define {<2 x float>, <2 x float>} @"\01-[A z]"({}* %self, i8* nocapture %_cmd) nounwind {
1916 %0 = bitcast {}* %self to i8*
1917 %1 = tail call i8* @objc_retain(i8* %0) nounwind
1918 tail call void @llvm.dbg.value(metadata !{{}* %self}, i64 0, metadata !0)
1919 tail call void @llvm.dbg.value(metadata !{{}* %self}, i64 0, metadata !0)
1920 %ivar = load i64* @"OBJC_IVAR_$_A.myZ", align 8
1921 %add.ptr = getelementptr i8* %0, i64 %ivar
1922 %tmp1 = bitcast i8* %add.ptr to float*
1923 %tmp2 = load float* %tmp1, align 4
1924 %conv = fpext float %tmp2 to double
1925 %add.ptr.sum = add i64 %ivar, 4
1926 %tmp6 = getelementptr inbounds i8* %0, i64 %add.ptr.sum
1927 %2 = bitcast i8* %tmp6 to float*
1928 %tmp7 = load float* %2, align 4
1929 %conv8 = fpext float %tmp7 to double
1930 %add.ptr.sum36 = add i64 %ivar, 8
1931 %tmp12 = getelementptr inbounds i8* %0, i64 %add.ptr.sum36
1932 %arrayidx = bitcast i8* %tmp12 to float*
1933 %tmp13 = load float* %arrayidx, align 4
1934 %conv14 = fpext float %tmp13 to double
1935 %tmp12.sum = add i64 %ivar, 12
1936 %arrayidx19 = getelementptr inbounds i8* %0, i64 %tmp12.sum
1937 %3 = bitcast i8* %arrayidx19 to float*
1938 %tmp20 = load float* %3, align 4
1939 %conv21 = fpext float %tmp20 to double
1940 %call = tail call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([33 x i8]* @.str4, i64 0, i64 0), double %conv, double %conv8, double %conv14, double %conv21)
1941 %ivar23 = load i64* @"OBJC_IVAR_$_A.myZ", align 8
1942 %add.ptr24 = getelementptr i8* %0, i64 %ivar23
1943 %4 = bitcast i8* %add.ptr24 to i128*
1944 %srcval = load i128* %4, align 4
1945 tail call void @objc_release(i8* %0) nounwind
1946 %tmp29 = trunc i128 %srcval to i64
1947 %tmp30 = bitcast i64 %tmp29 to <2 x float>
1948 %tmp31 = insertvalue {<2 x float>, <2 x float>} undef, <2 x float> %tmp30, 0
1949 %tmp32 = lshr i128 %srcval, 64
1950 %tmp33 = trunc i128 %tmp32 to i64
1951 %tmp34 = bitcast i64 %tmp33 to <2 x float>
1952 %tmp35 = insertvalue {<2 x float>, <2 x float>} %tmp31, <2 x float> %tmp34, 1
1953 ret {<2 x float>, <2 x float>} %tmp35
1956 ; CHECK: @"\01-[Top0 _getX]"
1960 define i32 @"\01-[Top0 _getX]"({}* %self, i8* nocapture %_cmd) nounwind {
1962 %0 = bitcast {}* %self to i8*
1963 %1 = tail call i8* @objc_retain(i8* %0) nounwind
1964 %puts = tail call i32 @puts(i8* getelementptr inbounds ([16 x i8]* @str, i64 0, i64 0))
1965 tail call void @objc_release(i8* %0) nounwind
1969 @"\01L_OBJC_METH_VAR_NAME_" = internal global [5 x i8] c"frob\00", section "__TEXT,__cstring,cstring_literals", align 1@"\01L_OBJC_SELECTOR_REFERENCES_" = internal global i8* getelementptr inbounds ([5 x i8]* @"\01L_OBJC_METH_VAR_NAME_", i64 0, i64 0), section "__DATA, __objc_selrefs, literal_pointers, no_dead_strip"
1970 @"\01L_OBJC_IMAGE_INFO" = internal constant [2 x i32] [i32 0, i32 16], section "__DATA, __objc_imageinfo, regular, no_dead_strip"
1971 @llvm.used = appending global [3 x i8*] [i8* getelementptr inbounds ([5 x i8]* @"\01L_OBJC_METH_VAR_NAME_", i32 0, i32 0), i8* bitcast (i8** @"\01L_OBJC_SELECTOR_REFERENCES_" to i8*), i8* bitcast ([2 x i32]* @"\01L_OBJC_IMAGE_INFO" to i8*)], section "llvm.metadata"
1973 ; A simple loop. Eliminate the retain and release inside of it!
1975 ; CHECK: define void @loop
1978 ; CHECK: @objc_msgSend
1981 define void @loop(i8* %x, i64 %n) {
1983 %0 = tail call i8* @objc_retain(i8* %x) nounwind
1984 %cmp9 = icmp sgt i64 %n, 0
1985 br i1 %cmp9, label %for.body, label %for.end
1987 for.body: ; preds = %entry, %for.body
1988 %i.010 = phi i64 [ %inc, %for.body ], [ 0, %entry ]
1989 %1 = tail call i8* @objc_retain(i8* %x) nounwind
1990 %tmp5 = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_", align 8
1991 %call = tail call i8* (i8*, i8*, ...)* @objc_msgSend(i8* %1, i8* %tmp5)
1992 tail call void @objc_release(i8* %1) nounwind, !clang.imprecise_release !0
1993 %inc = add nsw i64 %i.010, 1
1994 %exitcond = icmp eq i64 %inc, %n
1995 br i1 %exitcond, label %for.end, label %for.body
1997 for.end: ; preds = %for.body, %entry
1998 tail call void @objc_release(i8* %x) nounwind, !clang.imprecise_release !0
2002 ; ObjCARCOpt can delete the retain,release on self.
2004 ; CHECK: define void @TextEditTest
2005 ; CHECK-NOT: call i8* @objc_retain(i8* %tmp7)
2008 %0 = type { i8* (i8*, %struct._message_ref_t*, ...)*, i8* }
2014 %struct.NSConstantString = type { i32*, i32, i8*, i64 }
2015 %struct._NSRange = type { i64, i64 }
2016 %struct.__CFString = type opaque
2017 %struct.__method_list_t = type { i32, i32, [0 x %struct._objc_method] }
2018 %struct._class_ro_t = type { i32, i32, i32, i8*, i8*, %struct.__method_list_t*, %struct._objc_protocol_list*, %struct._ivar_list_t*, i8*, %struct._prop_list_t* }
2019 %struct._class_t = type { %struct._class_t*, %struct._class_t*, %struct._objc_cache*, i8* (i8*, i8*)**, %struct._class_ro_t* }
2020 %struct._ivar_list_t = type { i32, i32, [0 x %struct._ivar_t] }
2021 %struct._ivar_t = type { i64*, i8*, i8*, i32, i32 }
2022 %struct._message_ref_t = type { i8*, i8* }
2023 %struct._objc_cache = type opaque
2024 %struct._objc_method = type { i8*, i8*, i8* }
2025 %struct._objc_protocol_list = type { i64, [0 x %struct._protocol_t*] }
2026 %struct._prop_list_t = type { i32, i32, [0 x %struct._message_ref_t] }
2027 %struct._protocol_t = type { i8*, i8*, %struct._objc_protocol_list*, %struct.__method_list_t*, %struct.__method_list_t*, %struct.__method_list_t*, %struct.__method_list_t*, %struct._prop_list_t*, i32, i32 }
2029 @"\01L_OBJC_CLASSLIST_REFERENCES_$_17" = external hidden global %struct._class_t*, section "__DATA, __objc_classrefs, regular, no_dead_strip", align 8
2030 @kUTTypePlainText = external constant %struct.__CFString*
2031 @"\01L_OBJC_SELECTOR_REFERENCES_19" = external hidden global i8*, section "__DATA, __objc_selrefs, literal_pointers, no_dead_strip"
2032 @"\01L_OBJC_SELECTOR_REFERENCES_21" = external hidden global i8*, section "__DATA, __objc_selrefs, literal_pointers, no_dead_strip"
2033 @"\01L_OBJC_SELECTOR_REFERENCES_23" = external hidden global i8*, section "__DATA, __objc_selrefs, literal_pointers, no_dead_strip"
2034 @"\01L_OBJC_SELECTOR_REFERENCES_25" = external hidden global i8*, section "__DATA, __objc_selrefs, literal_pointers, no_dead_strip"
2035 @"\01L_OBJC_CLASSLIST_REFERENCES_$_26" = external hidden global %struct._class_t*, section "__DATA, __objc_classrefs, regular, no_dead_strip", align 8
2036 @"\01L_OBJC_SELECTOR_REFERENCES_28" = external hidden global i8*, section "__DATA, __objc_selrefs, literal_pointers, no_dead_strip"
2037 @"\01L_OBJC_CLASSLIST_REFERENCES_$_29" = external hidden global %struct._class_t*, section "__DATA, __objc_classrefs, regular, no_dead_strip", align 8
2038 @"\01L_OBJC_SELECTOR_REFERENCES_31" = external hidden global i8*, section "__DATA, __objc_selrefs, literal_pointers, no_dead_strip"
2039 @"\01L_OBJC_SELECTOR_REFERENCES_33" = external hidden global i8*, section "__DATA, __objc_selrefs, literal_pointers, no_dead_strip"
2040 @"\01L_OBJC_SELECTOR_REFERENCES_35" = external hidden global i8*, section "__DATA, __objc_selrefs, literal_pointers, no_dead_strip"
2041 @"\01L_OBJC_SELECTOR_REFERENCES_37" = external hidden global i8*, section "__DATA, __objc_selrefs, literal_pointers, no_dead_strip"
2042 @"\01L_OBJC_CLASSLIST_REFERENCES_$_38" = external hidden global %struct._class_t*, section "__DATA, __objc_classrefs, regular, no_dead_strip", align 8
2043 @"\01L_OBJC_SELECTOR_REFERENCES_40" = external hidden global i8*, section "__DATA, __objc_selrefs, literal_pointers, no_dead_strip"
2044 @"\01L_OBJC_SELECTOR_REFERENCES_42" = external hidden global i8*, section "__DATA, __objc_selrefs, literal_pointers, no_dead_strip"
2045 @_unnamed_cfstring_44 = external hidden constant %struct.NSConstantString, section "__DATA,__cfstring"
2046 @"\01L_OBJC_SELECTOR_REFERENCES_46" = external hidden global i8*, section "__DATA, __objc_selrefs, literal_pointers, no_dead_strip"
2047 @"\01L_OBJC_SELECTOR_REFERENCES_48" = external hidden global i8*, section "__DATA, __objc_selrefs, literal_pointers, no_dead_strip"
2048 @"\01l_objc_msgSend_fixup_isEqual_" = external hidden global %0, section "__DATA, __objc_msgrefs, coalesced", align 16
2049 @"\01L_OBJC_CLASSLIST_REFERENCES_$_50" = external hidden global %struct._class_t*, section "__DATA, __objc_classrefs, regular, no_dead_strip", align 8
2050 @NSCocoaErrorDomain = external constant %1*
2051 @"\01L_OBJC_CLASSLIST_REFERENCES_$_51" = external hidden global %struct._class_t*, section "__DATA, __objc_classrefs, regular, no_dead_strip", align 8
2052 @NSFilePathErrorKey = external constant %1*
2053 @"\01L_OBJC_SELECTOR_REFERENCES_53" = external hidden global i8*, section "__DATA, __objc_selrefs, literal_pointers, no_dead_strip"
2054 @"\01L_OBJC_SELECTOR_REFERENCES_55" = external hidden global i8*, section "__DATA, __objc_selrefs, literal_pointers, no_dead_strip"
2055 @"\01L_OBJC_CLASSLIST_REFERENCES_$_56" = external hidden global %struct._class_t*, section "__DATA, __objc_classrefs, regular, no_dead_strip", align 8
2056 @"\01L_OBJC_SELECTOR_REFERENCES_58" = external hidden global i8*, section "__DATA, __objc_selrefs, literal_pointers, no_dead_strip"
2057 @"\01L_OBJC_SELECTOR_REFERENCES_60" = external hidden global i8*, section "__DATA, __objc_selrefs, literal_pointers, no_dead_strip"
2059 declare %1* @truncatedString(%1*, i64)
2060 define void @TextEditTest(%2* %self, %3* %pboard) {
2062 %err = alloca %4*, align 8
2063 %tmp7 = bitcast %2* %self to i8*
2064 %tmp8 = call i8* @objc_retain(i8* %tmp7) nounwind
2065 store %4* null, %4** %err, align 8
2066 %tmp1 = load %struct._class_t** @"\01L_OBJC_CLASSLIST_REFERENCES_$_17", align 8
2067 %tmp2 = load %struct.__CFString** @kUTTypePlainText, align 8
2068 %tmp3 = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_19", align 8
2069 %tmp4 = bitcast %struct._class_t* %tmp1 to i8*
2070 %call5 = call i8* (i8*, i8*, ...)* @objc_msgSend(i8* %tmp4, i8* %tmp3, %struct.__CFString* %tmp2)
2071 %tmp5 = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_21", align 8
2072 %tmp6 = bitcast %3* %pboard to i8*
2073 %call76 = call i8* (i8*, i8*, ...)* @objc_msgSend(i8* %tmp6, i8* %tmp5, i8* %call5)
2074 %tmp9 = call i8* @objc_retain(i8* %call76) nounwind
2075 %tobool = icmp eq i8* %tmp9, null
2076 br i1 %tobool, label %end, label %land.lhs.true
2078 land.lhs.true: ; preds = %entry
2079 %tmp11 = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_23", align 8
2080 %call137 = call i8* (i8*, i8*, ...)* @objc_msgSend(i8* %tmp6, i8* %tmp11, i8* %tmp9)
2081 %tmp = bitcast i8* %call137 to %1*
2082 %tmp10 = call i8* @objc_retain(i8* %call137) nounwind
2083 call void @objc_release(i8* null) nounwind
2084 %tmp12 = call i8* @objc_retain(i8* %call137) nounwind
2085 call void @objc_release(i8* null) nounwind
2086 %tobool16 = icmp eq i8* %call137, null
2087 br i1 %tobool16, label %end, label %if.then
2089 if.then: ; preds = %land.lhs.true
2090 %tmp19 = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_25", align 8
2091 %call21 = call signext i8 bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i8 (i8*, i8*)*)(i8* %call137, i8* %tmp19)
2092 %tobool22 = icmp eq i8 %call21, 0
2093 br i1 %tobool22, label %if.then44, label %land.lhs.true23
2095 land.lhs.true23: ; preds = %if.then
2096 %tmp24 = load %struct._class_t** @"\01L_OBJC_CLASSLIST_REFERENCES_$_26", align 8
2097 %tmp26 = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_28", align 8
2098 %tmp27 = bitcast %struct._class_t* %tmp24 to i8*
2099 %call2822 = call i8* (i8*, i8*, ...)* @objc_msgSend(i8* %tmp27, i8* %tmp26, i8* %call137)
2100 %tmp13 = bitcast i8* %call2822 to %5*
2101 %tmp14 = call i8* @objc_retain(i8* %call2822) nounwind
2102 call void @objc_release(i8* null) nounwind
2103 %tobool30 = icmp eq i8* %call2822, null
2104 br i1 %tobool30, label %if.then44, label %if.end
2106 if.end: ; preds = %land.lhs.true23
2107 %tmp32 = load %struct._class_t** @"\01L_OBJC_CLASSLIST_REFERENCES_$_29", align 8
2108 %tmp33 = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_31", align 8
2109 %tmp34 = bitcast %struct._class_t* %tmp32 to i8*
2110 %call35 = call i8* (i8*, i8*, ...)* @objc_msgSend(i8* %tmp34, i8* %tmp33)
2111 %tmp37 = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_33", align 8
2112 %call3923 = call i8* (i8*, i8*, ...)* @objc_msgSend(i8* %call35, i8* %tmp37, i8* %call2822, i32 signext 1, %4** %err)
2113 %cmp = icmp eq i8* %call3923, null
2114 br i1 %cmp, label %if.then44, label %end
2116 if.then44: ; preds = %if.end, %land.lhs.true23, %if.then
2117 %url.025 = phi %5* [ %tmp13, %if.end ], [ %tmp13, %land.lhs.true23 ], [ null, %if.then ]
2118 %tmp49 = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_35", align 8
2119 %call51 = call %struct._NSRange bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to %struct._NSRange (i8*, i8*, i64, i64)*)(i8* %call137, i8* %tmp49, i64 0, i64 0)
2120 %call513 = extractvalue %struct._NSRange %call51, 0
2121 %call514 = extractvalue %struct._NSRange %call51, 1
2122 %tmp52 = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_37", align 8
2123 %call548 = call i8* (i8*, i8*, ...)* @objc_msgSend(i8* %call137, i8* %tmp52, i64 %call513, i64 %call514)
2124 %tmp55 = load %struct._class_t** @"\01L_OBJC_CLASSLIST_REFERENCES_$_38", align 8
2125 %tmp56 = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_40", align 8
2126 %tmp57 = bitcast %struct._class_t* %tmp55 to i8*
2127 %call58 = call i8* (i8*, i8*, ...)* @objc_msgSend(i8* %tmp57, i8* %tmp56)
2128 %tmp59 = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_42", align 8
2129 %call6110 = call i8* (i8*, i8*, ...)* @objc_msgSend(i8* %call548, i8* %tmp59, i8* %call58)
2130 %tmp15 = call i8* @objc_retain(i8* %call6110) nounwind
2131 call void @objc_release(i8* %call137) nounwind
2132 %tmp64 = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_46", align 8
2133 %call66 = call signext i8 bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i8 (i8*, i8*, %1*)*)(i8* %call6110, i8* %tmp64, %1* bitcast (%struct.NSConstantString* @_unnamed_cfstring_44 to %1*))
2134 %tobool67 = icmp eq i8 %call66, 0
2135 br i1 %tobool67, label %if.end74, label %if.then68
2137 if.then68: ; preds = %if.then44
2138 %tmp70 = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_48", align 8
2139 %call7220 = call i8* (i8*, i8*, ...)* @objc_msgSend(i8* %call6110, i8* %tmp70)
2140 %tmp16 = call i8* @objc_retain(i8* %call7220) nounwind
2141 call void @objc_release(i8* %call6110) nounwind
2144 if.end74: ; preds = %if.then68, %if.then44
2145 %filename.0.in = phi i8* [ %call7220, %if.then68 ], [ %call6110, %if.then44 ]
2146 %filename.0 = bitcast i8* %filename.0.in to %1*
2147 %tmp17 = load i8** bitcast (%0* @"\01l_objc_msgSend_fixup_isEqual_" to i8**), align 16
2148 %tmp18 = bitcast i8* %tmp17 to i8 (i8*, %struct._message_ref_t*, i8*, ...)*
2149 %call78 = call signext i8 (i8*, %struct._message_ref_t*, i8*, ...)* %tmp18(i8* %call137, %struct._message_ref_t* bitcast (%0* @"\01l_objc_msgSend_fixup_isEqual_" to %struct._message_ref_t*), i8* %filename.0.in)
2150 %tobool79 = icmp eq i8 %call78, 0
2151 br i1 %tobool79, label %land.lhs.true80, label %if.then109
2153 land.lhs.true80: ; preds = %if.end74
2154 %tmp82 = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_25", align 8
2155 %call84 = call signext i8 bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i8 (i8*, i8*)*)(i8* %filename.0.in, i8* %tmp82)
2156 %tobool86 = icmp eq i8 %call84, 0
2157 br i1 %tobool86, label %if.then109, label %if.end106
2159 if.end106: ; preds = %land.lhs.true80
2160 %tmp88 = load %struct._class_t** @"\01L_OBJC_CLASSLIST_REFERENCES_$_26", align 8
2161 %tmp90 = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_28", align 8
2162 %tmp91 = bitcast %struct._class_t* %tmp88 to i8*
2163 %call9218 = call i8* (i8*, i8*, ...)* @objc_msgSend(i8* %tmp91, i8* %tmp90, i8* %filename.0.in)
2164 %tmp20 = bitcast i8* %call9218 to %5*
2165 %tmp21 = call i8* @objc_retain(i8* %call9218) nounwind
2166 %tmp22 = bitcast %5* %url.025 to i8*
2167 call void @objc_release(i8* %tmp22) nounwind
2168 %tmp94 = load %struct._class_t** @"\01L_OBJC_CLASSLIST_REFERENCES_$_29", align 8
2169 %tmp95 = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_31", align 8
2170 %tmp96 = bitcast %struct._class_t* %tmp94 to i8*
2171 %call97 = call i8* (i8*, i8*, ...)* @objc_msgSend(i8* %tmp96, i8* %tmp95)
2172 %tmp99 = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_33", align 8
2173 %call10119 = call i8* (i8*, i8*, ...)* @objc_msgSend(i8* %call97, i8* %tmp99, i8* %call9218, i32 signext 1, %4** %err)
2174 %phitmp = icmp eq i8* %call10119, null
2175 br i1 %phitmp, label %if.then109, label %end
2177 if.then109: ; preds = %if.end106, %land.lhs.true80, %if.end74
2178 %url.129 = phi %5* [ %tmp20, %if.end106 ], [ %url.025, %if.end74 ], [ %url.025, %land.lhs.true80 ]
2179 %tmp110 = load %4** %err, align 8
2180 %tobool111 = icmp eq %4* %tmp110, null
2181 br i1 %tobool111, label %if.then112, label %if.end125
2183 if.then112: ; preds = %if.then109
2184 %tmp113 = load %struct._class_t** @"\01L_OBJC_CLASSLIST_REFERENCES_$_50", align 8
2185 %tmp114 = load %1** @NSCocoaErrorDomain, align 8
2186 %tmp115 = load %struct._class_t** @"\01L_OBJC_CLASSLIST_REFERENCES_$_51", align 8
2187 %call117 = call %1* @truncatedString(%1* %filename.0, i64 1034)
2188 %tmp118 = load %1** @NSFilePathErrorKey, align 8
2189 %tmp119 = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_53", align 8
2190 %tmp120 = bitcast %struct._class_t* %tmp115 to i8*
2191 %call12113 = call i8* (i8*, i8*, ...)* @objc_msgSend(i8* %tmp120, i8* %tmp119, %1* %call117, %1* %tmp118, i8* null)
2192 %tmp122 = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_55", align 8
2193 %tmp123 = bitcast %struct._class_t* %tmp113 to i8*
2194 %call12414 = call i8* (i8*, i8*, ...)* @objc_msgSend(i8* %tmp123, i8* %tmp122, %1* %tmp114, i64 258, i8* %call12113)
2195 %tmp23 = call i8* @objc_retain(i8* %call12414) nounwind
2196 %tmp25 = call i8* @objc_autorelease(i8* %tmp23) nounwind
2197 %tmp28 = bitcast i8* %tmp25 to %4*
2198 store %4* %tmp28, %4** %err, align 8
2201 if.end125: ; preds = %if.then112, %if.then109
2202 %tmp127 = phi %4* [ %tmp110, %if.then109 ], [ %tmp28, %if.then112 ]
2203 %tmp126 = load %struct._class_t** @"\01L_OBJC_CLASSLIST_REFERENCES_$_56", align 8
2204 %tmp128 = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_58", align 8
2205 %tmp129 = bitcast %struct._class_t* %tmp126 to i8*
2206 %call13015 = call i8* (i8*, i8*, ...)* @objc_msgSend(i8* %tmp129, i8* %tmp128, %4* %tmp127)
2207 %tmp131 = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_60", align 8
2208 %call13317 = call i8* (i8*, i8*, ...)* @objc_msgSend(i8* %call13015, i8* %tmp131)
2211 end: ; preds = %if.end125, %if.end106, %if.end, %land.lhs.true, %entry
2212 %filename.2 = phi %1* [ %filename.0, %if.end106 ], [ %filename.0, %if.end125 ], [ %tmp, %land.lhs.true ], [ null, %entry ], [ %tmp, %if.end ]
2213 %origFilename.0 = phi %1* [ %tmp, %if.end106 ], [ %tmp, %if.end125 ], [ %tmp, %land.lhs.true ], [ null, %entry ], [ %tmp, %if.end ]
2214 %url.2 = phi %5* [ %tmp20, %if.end106 ], [ %url.129, %if.end125 ], [ null, %land.lhs.true ], [ null, %entry ], [ %tmp13, %if.end ]
2215 call void @objc_release(i8* %tmp9) nounwind, !clang.imprecise_release !0
2216 %tmp29 = bitcast %5* %url.2 to i8*
2217 call void @objc_release(i8* %tmp29) nounwind, !clang.imprecise_release !0
2218 %tmp30 = bitcast %1* %origFilename.0 to i8*
2219 call void @objc_release(i8* %tmp30) nounwind, !clang.imprecise_release !0
2220 %tmp31 = bitcast %1* %filename.2 to i8*
2221 call void @objc_release(i8* %tmp31) nounwind, !clang.imprecise_release !0
2222 call void @objc_release(i8* %tmp7) nounwind, !clang.imprecise_release !0
2228 declare i32 @__gxx_personality_v0(...)
2230 ; CHECK: attributes #0 = { nounwind readnone }
2231 ; CHECK: attributes [[NUW]] = { nounwind }