Skip to content

Commit fd31b66

Browse files
author
Amritpan Kaur
committed
[LValue] Move PhysicalPathComponent tail assign into set method.
1 parent b0fd4c3 commit fd31b66

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

lib/SILGen/LValue.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,9 @@ class PhysicalPathComponent : public PathComponent {
226226
return current;
227227
}
228228

229+
void set(SILGenFunction &SGF, SILLocation loc,
230+
ArgumentSource &&value, ManagedValue base) &&;
231+
229232
/// Determines whether this component has any actor-isolation.
230233
bool hasActorIsolation() const { return ActorIso.hasValue(); }
231234
};

lib/SILGen/SILGenLValue.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,15 @@ InOutConversionScope::~InOutConversionScope() {
467467
void PathComponent::_anchor() {}
468468
void PhysicalPathComponent::_anchor() {}
469469

470+
void PhysicalPathComponent::set(SILGenFunction &SGF, SILLocation loc,
471+
ArgumentSource &&value, ManagedValue base) && {
472+
auto finalDestAddr = std::move(*this).project(SGF, loc, base);
473+
assert(finalDestAddr.getType().isAddress());
474+
475+
auto srcRValue = std::move(value).getAsRValue(SGF).ensurePlusOne(SGF, loc);
476+
std::move(srcRValue).assignInto(SGF, loc, finalDestAddr.getValue());
477+
}
478+
470479
void PathComponent::dump() const {
471480
dump(llvm::errs());
472481
}
@@ -4899,12 +4908,7 @@ void SILGenFunction::emitAssignToLValue(SILLocation loc,
48994908

49004909
// Write to the tail component.
49014910
if (component.isPhysical()) {
4902-
auto finalDestAddr =
4903-
std::move(component).project(*this, loc, destAddr);
4904-
assert(finalDestAddr.getType().isAddress());
4905-
4906-
auto value = std::move(src).getAsRValue(*this).ensurePlusOne(*this, loc);
4907-
std::move(value).assignInto(*this, loc, finalDestAddr.getValue());
4911+
std::move(component.asPhysical()).set(*this, loc, std::move(src), destAddr);
49084912
} else {
49094913
std::move(component.asLogical()).set(*this, loc, std::move(src), destAddr);
49104914
}

0 commit comments

Comments
 (0)