-
Notifications
You must be signed in to change notification settings - Fork 10.6k
[opt] Update alloc_refs on the stack to have stack memory kind. #31423
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -100,7 +100,6 @@ AccessedStorage::AccessedStorage(SILValue base, Kind kind) { | |
| value = base; | ||
| break; | ||
| case Stack: | ||
| assert(isa<AllocStackInst>(base)); | ||
| value = base; | ||
| break; | ||
| case Nested: | ||
|
|
@@ -772,3 +771,22 @@ void swift::visitAccessedAddress(SILInstruction *I, | |
| return; | ||
| } | ||
| } | ||
|
|
||
| template <typename Impl, typename Result> | ||
| Result swift::AccessUseDefChainVisitor<Impl, Result>::visitClassAccess( | ||
| RefElementAddrInst *field) { | ||
| auto operand = field->getOperand(); | ||
| while (isa<StructElementAddrInst>(operand) || | ||
| isa<RefElementAddrInst>(operand) || | ||
| isa<TupleElementAddrInst>(operand) || isa<LoadInst>(operand)) | ||
| operand = operand.getDefiningInstruction()->getOperand(0); | ||
|
||
|
|
||
| if (isa<AllocStackInst>(operand)) | ||
| return asImpl().visitBase(field, AccessedStorage::Stack); | ||
|
||
| if (auto allocRef = dyn_cast<AllocRefInst>(operand)) { | ||
| if (allocRef->isAllocatingStack()) | ||
| return asImpl().visitBase(field, AccessedStorage::Stack); | ||
|
||
| } | ||
|
|
||
| return asImpl().visitBase(field, AccessedStorage::Class); | ||
| } | ||
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.
I'd like to keep the assertion here but, it would require duplicating the code in
visitClassAccessand I don't think it's worth it just for the assertion. WDYT?