-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
[DNM: Draft][SILOpt] TempRValueElimination: 'let' copy source values cant be over… #61502
Conversation
…writen by apply instructions TempRValueElimination checks if a copy of a value can be eliminated. Checking that the original source value was not modified during the copy is one of the requirements for the elimination. Prior to this change, TempRValueElimination checked if apply instructions could've potentially modified the original source value, even if the source value was an immutable 'let'. This prevented some optimization opportunities. With this change, we can recognize that 'let' source value won't be modified by an apply, so that we can proceed with copy elimination.
still needs tests |
@swift-ci please benchmark |
@swift-ci please test |
if ((FullApplySite::isa(inst) || isa<YieldInst>(inst)) && | ||
aa->mayWriteToMemory(inst, copySrc)) { | ||
!isLetObject(copySrc) && aa->mayWriteToMemory(inst, copySrc)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now, you can just use bool swift::isLetAddress(SILValue address)
. That uses the canonical AccessBase utility. It's a bit less ad-hoc and you don't need to DIY.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@meg-gupta pointed out that if you just check AllocStack::isLet()
inside isLetAddress
, then you shouldn't need to touch this pass at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a .sil test to temp_rvalue_opt_ossa.sil?
Closing in favor of #61504 |
I think @meg-gupta will introduce a PR very similar to this, maybe with a comment that we can't safely rely on |
…writen by apply instructions
TempRValueElimination checks if a copy of a value can be eliminated. Checking that the original source value was not modified during the copy is one of the requirements for the elimination. Prior to this change, TempRValueElimination checked if apply instructions could've potentially modified the original source value, even if the source value was an immutable 'let'. This prevented some optimization opportunities. With this change, we can recognize that 'let' source value won't be modified by an apply, so that we can proceed with copy elimination.