ARC injects unneeded retain/release on void function
Originator: | robnapier | ||
Number: | rdar://10002493 | Date Originated: | 22-Aug-2011 05:46 PM |
Status: | Behaves correctly | Resolved: | 30-Jan-2012 03:28 PM |
Product: | Product Version: | ||
Classification: | Reproducible: |
22-Aug-2011 05:46 PM Rob Napier: 'main.m' was successfully uploaded 22-Aug-2011 05:46 PM Rob Napier: Summary: When calling an IMP in a void context, ARC injects an extra _objc_retainAutoreleasedReturnValue and _objc_release, even though the result is thrown away. When using normal ObjC [foo bar], ARC correctly avoids this. Steps to Reproduce: See attached test program. Starred assembly should not be needed since the result is a void. for (count = 0; count < kTotalCount; ++count) { setStringMethod(string, selector, @"stuff"); } LBB0_5: ## =>This Inner Loop Header: Depth=1 cmpq $100000000, -48(%rbp) ## imm = 0x5F5E100 jae LBB0_8 ## BB#6: ## in Loop: Header=BB0_5 Depth=1 leaq L__unnamed_cfstring_(%rip), %rax .loc 1 35 7 ## /Users/rnapier/src/TestIMP/TestIMP/main.m:35:7 Ltmp11: movq -64(%rbp), %rcx movq -24(%rbp), %rdx movq -56(%rbp), %rsi movq %rdx, %rdi movq %rax, %rdx movb $0, %al callq *%rcx * movq %rax, %rdi * callq _objc_retainAutoreleasedReturnValue * movq %rax, %rdi * callq _objc_release Ltmp12: ## BB#7: ## in Loop: Header=BB0_5 Depth=1 .loc 1 34 42 ## /Users/rnapier/src/TestIMP/TestIMP/main.m:34:42 movq -48(%rbp), %rax addq $1, %rax movq %rax, -48(%rbp) jmp LBB0_5 Expected Results: The starred assembly should be optimized out as it is for the objc_msgSend case: for (count = 0; count < kTotalCount; ++count) { [string setString:@"stuff"]; } LBB0_1: ## =>This Inner Loop Header: Depth=1 cmpq $100000000, -48(%rbp) ## imm = 0x5F5E100 jae LBB0_4 ## BB#2: ## in Loop: Header=BB0_1 Depth=1 leaq L__unnamed_cfstring_(%rip), %rax .loc 1 23 7 ## /Users/rnapier/src/TestIMP/TestIMP/main.m:23:7 Ltmp8: movq -24(%rbp), %rcx movq L_OBJC_SELECTOR_REFERENCES_5(%rip), %rsi movq %rcx, %rdi movq %rax, %rdx callq _objc_msgSend Ltmp9: ## BB#3: ## in Loop: Header=BB0_1 Depth=1 .loc 1 22 42 ## /Users/rnapier/src/TestIMP/TestIMP/main.m:22:42 movq -48(%rbp), %rax addq $1, %rax movq %rax, -48(%rbp) jmp LBB0_1 Actual Results: Regression: Notes:
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!