Skip to content

Commit 07a47a0

Browse files
committed
SILGen: Remove InOutInitialization and its related "AddressBinding" initialization kind.
We don't need these now that we don't set up argument bindings via initializations. Swift SVN r24413
1 parent 78a53ec commit 07a47a0

File tree

4 files changed

+1
-69
lines changed

4 files changed

+1
-69
lines changed

lib/SILGen/Initialization.h

-10
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,6 @@ class Initialization {
4747
/// This Initialization is for a _ binding or other ignored value; the
4848
/// corresponding result can be discarded.
4949
Ignored,
50-
/// This Initialization is for an inout or address-only argument binding,
51-
/// which is initialized using bindAddress().
52-
AddressBinding,
5350
/// This Initialization is to bind a 'let' declaration into VarLocs
5451
/// directly.
5552
LetValue,
@@ -84,13 +81,6 @@ class Initialization {
8481
/// SILValue of that buffer's address. If not, returns an invalid SILValue.
8582
virtual SILValue getAddressOrNull() const = 0;
8683

87-
/// Binds an address value to this initialization. Called only on
88-
/// initializations with Kind::AddressBinding.
89-
virtual void bindAddress(SILValue address, SILGenFunction &gen,
90-
SILLocation loc) {
91-
llvm_unreachable("unexpected address value in initialization!");
92-
}
93-
9484
/// Provide a value to this initialization. Called only on
9585
/// initializations with Kind::Translating.
9686
virtual void translateValue(SILGenFunction &gen, SILLocation loc,

lib/SILGen/RValue.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,6 @@ class CopyIntoTupleValues
239239
values = values.slice(1);
240240

241241
switch (I->kind) {
242-
case Initialization::Kind::AddressBinding:
243-
llvm_unreachable("cannot emit into a inout binding");
244242
case Initialization::Kind::Tuple:
245243
llvm_unreachable("tuple initialization not destructured?!");
246244

@@ -321,8 +319,6 @@ class InitializeTupleValues
321319
values = values.slice(1);
322320

323321
switch (I->kind) {
324-
case Initialization::Kind::AddressBinding:
325-
llvm_unreachable("cannot emit into a inout binding");
326322
case Initialization::Kind::Tuple:
327323
llvm_unreachable("tuple initialization not destructured?!");
328324

lib/SILGen/SILGenDecl.cpp

+1-53
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ bool Initialization::canForwardInBranch() const {
7474
return true;
7575

7676
// These initializations expect to be activated exactly once.
77-
case Kind::AddressBinding:
7877
case Kind::LetValue:
7978
case Kind::Translating:
8079
return false;
@@ -126,8 +125,6 @@ Initialization::getSubInitializationsForTuple(SILGenFunction &gen, CanType type,
126125
// This could actually be done by collecting translated values, if
127126
// we introduce new needs for translating initializations.
128127
llvm_unreachable("cannot destructure a translating initialization");
129-
case Kind::AddressBinding:
130-
llvm_unreachable("cannot destructure an address binding initialization");
131128
}
132129
llvm_unreachable("bad initialization kind");
133130
}
@@ -461,52 +458,6 @@ class CleanupWriteBackToInOut : public Cleanup {
461458
}
462459
};
463460

464-
/// Initialize a writeback buffer that receives the "in" value of a inout
465-
/// argument on function entry and writes the "out" value back to the inout
466-
/// address on function exit.
467-
class InOutInitialization : public Initialization {
468-
/// The VarDecl for the inout symbol.
469-
VarDecl *vd;
470-
public:
471-
InOutInitialization(VarDecl *vd)
472-
: Initialization(Initialization::Kind::AddressBinding), vd(vd) {}
473-
474-
SILValue getAddressOrNull() const override {
475-
llvm_unreachable("inout argument should be bound by bindAddress");
476-
}
477-
ArrayRef<InitializationPtr> getSubInitializations() const override {
478-
return {};
479-
}
480-
481-
void bindAddress(SILValue address, SILGenFunction &gen,
482-
SILLocation loc) override {
483-
CanType objectType =
484-
cast<InOutType>(vd->getType()->getCanonicalType()).getObjectType();
485-
486-
// As a special case, don't introduce a local variable for
487-
// Builtin.UnsafeValueBuffer, which is not copyable.
488-
if (isa<BuiltinUnsafeValueBufferType>(objectType)) {
489-
// FIXME: mark a debug location?
490-
gen.VarLocs[vd] = SILGenFunction::VarLoc::get(address);
491-
return;
492-
}
493-
494-
// Allocate the local variable for the inout.
495-
auto initVar = gen.emitLocalVariableWithCleanup(vd, false);
496-
497-
// Initialize with the value from the inout with an "autogenerated"
498-
// copyaddr.
499-
loc.markAsPrologue();
500-
loc.markAutoGenerated();
501-
gen.B.createCopyAddr(loc, address, initVar->getAddress(),
502-
IsNotTake, IsInitialization);
503-
initVar->finishInitialization(gen);
504-
505-
// Set up a cleanup to write back to the inout.
506-
gen.Cleanups.pushCleanup<CleanupWriteBackToInOut>(vd, address);
507-
}
508-
};
509-
510461
/// Initialize a variable of reference-storage type.
511462
class ReferenceStorageInitialization : public Initialization {
512463
InitializationPtr VarInit;
@@ -666,10 +617,7 @@ SILGenFunction::emitInitializationForVarDecl(VarDecl *vd, Type patternType) {
666617

667618
CanType varType = vd->getType()->getCanonicalType();
668619

669-
// If this is an inout parameter, set up the writeback variable.
670-
if (isa<InOutType>(varType)) {
671-
return InitializationPtr(new InOutInitialization(vd));
672-
}
620+
assert(!isa<InOutType>(varType) && "local variables should never be inout");
673621

674622
// If this is a 'let' initialization for a non-global, set up a
675623
// let binding, which stores the initialization value into VarLocs directly.

lib/SILGen/SILGenExpr.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -1019,8 +1019,6 @@ static SILValue getAddressForInPlaceInitialization(Initialization *I) {
10191019

10201020
SILValue address;
10211021
switch (I->kind) {
1022-
case Initialization::Kind::AddressBinding:
1023-
llvm_unreachable("can't emit into address binding");
10241022
case Initialization::Kind::LetValue:
10251023
// Emit into the buffer that 'let's produce for address-only values if
10261024
// we have it.

0 commit comments

Comments
 (0)