Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

missed autorelease elision #31273

Open
compnerd opened this issue Feb 10, 2017 · 1 comment
Open

missed autorelease elision #31273

compnerd opened this issue Feb 10, 2017 · 1 comment
Labels

Comments

@compnerd
Copy link
Member

Bugzilla Link 31925
Version trunk
OS All
Attachments reduced.m
CC @ahatanak,@rjmccall,@smeenai

Extended Description

After the introduction of returned attribute on arguments, it is possible that the GetRCIdentityRoot is able to peer through too many cases, breaking an assumption that the GetArgRCIdentityRoot would get the associated function call. The attached test case demonstrates this.

@ahatanak
Copy link
Collaborator

ahatanak commented Dec 8, 2020

This is what's happening:

  1. Function attribute pass adds attribute 'returned' to @​f's parameter as the function returns %0.

define i8* @​f(i8* %0) local_unnamed_addr #​0 {
%2 = tail call i8* @​llvm.objc.autoreleaseReturnValue(i8* %0) #​1
ret i8* %0
}

  1. initcombine replaces %4 passed to the call to @​llvm.objc.retainAutoreleasedReturnValue with %3 since @​f's parameter has attribute 'returned'.

define void @​g(%struct.__CFString* %0) local_unnamed_addr #​2 {
%2 = call i8* @​llvm.objc.autoreleasePoolPush() #​1
%3 = bitcast %struct.__CFString* %0 to i8*
%4 = call i8* @​f(i8* %3) #​3, !clang.arc.no_objc_arc_exceptions !​10
%5 = call i8* @​llvm.objc.retainAutoreleasedReturnValue(i8* %4) #​1

  1. ObjCARCOpt::OptimizeRetainRVCall no longer understands that the call to @​llvm.objc.retainAutoreleasedReturnValue uses the result of the call to @​f, so it turns the @​llvm.objc.retainAutoreleasedReturnValue call to a @​llvm.objc.retain call.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants