Skip to content

Commit a37bc80

Browse files
committed
[IRGen] NFC: Deleted dead LoweredValue kind.
Follow-up to #10077 .
1 parent 29acda5 commit a37bc80

File tree

1 file changed

+2
-83
lines changed

1 file changed

+2
-83
lines changed

lib/IRGen/IRGenSIL.cpp

Lines changed: 2 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -125,16 +125,7 @@ struct CoroutineState {
125125
class LoweredValue {
126126
public:
127127
enum class Kind {
128-
/// The first two LoweredValue kinds correspond to a SIL address value.
129-
///
130-
/// The LoweredValue of an existential alloc_stack keeps an owning container
131-
/// in addition to the address of the allocated buffer.
132-
/// Depending on the allocated type, the container may be equal to the
133-
/// buffer itself (for types with known sizes) or it may be the address
134-
/// of a fixed-size container which points to the heap-allocated buffer.
135-
/// In this case the address-part may be null, which means that the buffer
136-
/// is not allocated yet.
137-
ContainedAddress,
128+
/// The first three LoweredValue kinds correspond to a SIL address value.
138129

139130
/// The LoweredValue of a resilient, generic, or loadable typed alloc_stack
140131
/// keeps an optional stackrestore point in addition to the address of the
@@ -178,8 +169,7 @@ class LoweredValue {
178169
using ExplosionVector = SmallVector<llvm::Value *, 4>;
179170
using SingletonExplosion = llvm::Value*;
180171

181-
using Members = ExternalUnionMembers<ContainedAddress,
182-
StackAddress,
172+
using Members = ExternalUnionMembers<StackAddress,
183173
OwnedAddress,
184174
DynamicallyEnforcedAddress,
185175
ExplosionVector,
@@ -191,7 +181,6 @@ class LoweredValue {
191181

192182
static Members::Index getMemberIndexForKind(Kind kind) {
193183
switch (kind) {
194-
case Kind::ContainedAddress: return Members::indexOf<ContainedAddress>();
195184
case Kind::StackAddress: return Members::indexOf<StackAddress>();
196185
case Kind::OwnedAddress: return Members::indexOf<OwnedAddress>();
197186
case Kind::DynamicallyEnforcedAddress: return Members::indexOf<DynamicallyEnforcedAddress>();
@@ -231,22 +220,6 @@ class LoweredValue {
231220
Storage.emplace<DynamicallyEnforcedAddress>(kind, address);
232221
}
233222

234-
enum ContainerForUnallocatedAddress_t { ContainerForUnallocatedAddress };
235-
236-
/// Create an address value for an alloc_stack, consisting of a container and
237-
/// a not yet allocated buffer.
238-
LoweredValue(const Address &container, ContainerForUnallocatedAddress_t)
239-
: kind(Kind::ContainedAddress) {
240-
Storage.emplace<ContainedAddress>(kind, container, Address());
241-
}
242-
243-
/// Create an address value for an alloc_stack, consisting of a container and
244-
/// the address of the allocated buffer.
245-
LoweredValue(const ContainedAddress &address)
246-
: kind(Kind::ContainedAddress) {
247-
Storage.emplace<ContainedAddress>(kind, address);
248-
}
249-
250223
LoweredValue(const FunctionPointer &fn)
251224
: kind(Kind::FunctionPointer) {
252225
Storage.emplace<FunctionPointer>(kind, fn);
@@ -304,10 +277,6 @@ class LoweredValue {
304277
return (kind == Kind::StackAddress ||
305278
kind == Kind::DynamicallyEnforcedAddress);
306279
}
307-
bool isUnallocatedAddressInBuffer() const {
308-
return kind == Kind::ContainedAddress &&
309-
!Storage.get<ContainedAddress>(kind).getAddress().isValid();
310-
}
311280
bool isBoxWithAddress() const {
312281
return kind == Kind::OwnedAddress;
313282
}
@@ -316,28 +285,13 @@ class LoweredValue {
316285
return Storage.get<StackAddress>(kind);
317286
}
318287

319-
Address getContainerOfAddress() const {
320-
const auto &containedAddress = Storage.get<ContainedAddress>(kind);
321-
assert(containedAddress.getContainer().isValid() && "address has no container");
322-
return containedAddress.getContainer();
323-
}
324-
325-
Address getAddressInContainer() const {
326-
const auto &containedAddress = Storage.get<ContainedAddress>(kind);
327-
assert(containedAddress.getContainer().isValid() &&
328-
"address has no container");
329-
return containedAddress.getAddress();
330-
}
331-
332288
const DynamicallyEnforcedAddress &getDynamicallyEnforcedAddress() const {
333289
return Storage.get<DynamicallyEnforcedAddress>(kind);
334290
}
335291

336292
Address getAnyAddress() const {
337293
if (kind == LoweredValue::Kind::StackAddress) {
338294
return Storage.get<StackAddress>(kind).getAddress();
339-
} else if (kind == LoweredValue::Kind::ContainedAddress) {
340-
return getAddressInContainer();
341295
} else {
342296
return getDynamicallyEnforcedAddress().Addr;
343297
}
@@ -501,24 +455,6 @@ class IRGenSILFunction :
501455
setLoweredValue(v, DynamicallyEnforcedAddress{address, scratch});
502456
}
503457

504-
void setContainerOfUnallocatedAddress(SILValue v,
505-
const Address &buffer) {
506-
assert(isAddress(v) && "address for non-address value?!");
507-
setLoweredValue(v,
508-
LoweredValue(buffer, LoweredValue::ContainerForUnallocatedAddress));
509-
}
510-
511-
void overwriteAllocatedAddress(SILValue v, const Address &address) {
512-
assert(isAddress(v) && "address for non-address value?!");
513-
auto it = LoweredValues.find(v);
514-
assert(it != LoweredValues.end() && "no existing entry for overwrite?");
515-
assert(it->second.isUnallocatedAddressInBuffer() &&
516-
"not an unallocated address");
517-
it->second = ContainedAddress(it->second.getContainerOfAddress(), address);
518-
}
519-
520-
void setAllocatedAddressForBuffer(SILValue v, const Address &allocedAddress);
521-
522458
/// Create a new Explosion corresponding to the given SIL value.
523459
void setLoweredExplosion(SILValue v, Explosion &e) {
524460
assert(v->getType().isObject() && "explosion for address value?!");
@@ -1813,7 +1749,6 @@ void LoweredValue::getExplosion(IRGenFunction &IGF, SILType type,
18131749
ex.add(Storage.get<StackAddress>(kind).getAddressPointer());
18141750
return;
18151751

1816-
case Kind::ContainedAddress:
18171752
case Kind::DynamicallyEnforcedAddress:
18181753
case Kind::CoroutineState:
18191754
llvm_unreachable("not a value");
@@ -1849,7 +1784,6 @@ llvm::Value *LoweredValue::getSingletonExplosion(IRGenFunction &IGF,
18491784
SILType type) const {
18501785
switch (kind) {
18511786
case Kind::StackAddress:
1852-
case Kind::ContainedAddress:
18531787
case Kind::DynamicallyEnforcedAddress:
18541788
case Kind::CoroutineState:
18551789
llvm_unreachable("not a value");
@@ -3418,7 +3352,6 @@ Callee LoweredValue::getCallee(IRGenFunction &IGF,
34183352

34193353
case LoweredValue::Kind::EmptyExplosion:
34203354
case LoweredValue::Kind::OwnedAddress:
3421-
case LoweredValue::Kind::ContainedAddress:
34223355
case LoweredValue::Kind::StackAddress:
34233356
case LoweredValue::Kind::DynamicallyEnforcedAddress:
34243357
case LoweredValue::Kind::CoroutineState:
@@ -3842,7 +3775,6 @@ getPartialApplicationFunction(IRGenSILFunction &IGF, SILValue v,
38423775
auto fnType = v->getType().castTo<SILFunctionType>();
38433776

38443777
switch (lv.kind) {
3845-
case LoweredValue::Kind::ContainedAddress:
38463778
case LoweredValue::Kind::StackAddress:
38473779
case LoweredValue::Kind::DynamicallyEnforcedAddress:
38483780
case LoweredValue::Kind::OwnedAddress:
@@ -7541,24 +7473,12 @@ void IRGenSILFunction::visitWitnessMethodInst(swift::WitnessMethodInst *i) {
75417473
setLoweredFunctionPointer(i, fn);
75427474
}
75437475

7544-
void IRGenSILFunction::setAllocatedAddressForBuffer(SILValue v,
7545-
const Address &allocedAddress) {
7546-
overwriteAllocatedAddress(v, allocedAddress);
7547-
7548-
// Emit the debug info for the variable if any.
7549-
if (auto allocStack = dyn_cast<AllocStackInst>(v)) {
7550-
emitDebugInfoForAllocStack(allocStack, getTypeInfo(v->getType()),
7551-
allocedAddress.getAddress());
7552-
}
7553-
}
7554-
75557476
void IRGenSILFunction::visitCopyAddrInst(swift::CopyAddrInst *i) {
75567477
SILType addrTy = i->getSrc()->getType();
75577478
const TypeInfo &addrTI = getTypeInfo(addrTy);
75587479
Address src = getLoweredAddress(i->getSrc());
75597480
// See whether we have a deferred fixed-size buffer initialization.
75607481
auto &loweredDest = getLoweredValue(i->getDest());
7561-
assert(!loweredDest.isUnallocatedAddressInBuffer());
75627482
Address dest = loweredDest.getAnyAddress();
75637483
if (i->isInitializationOfDest()) {
75647484
if (i->isTakeOfSrc()) {
@@ -7582,7 +7502,6 @@ void IRGenSILFunction::visitExplicitCopyAddrInst(
75827502
Address src = getLoweredAddress(i->getSrc());
75837503
// See whether we have a deferred fixed-size buffer initialization.
75847504
auto &loweredDest = getLoweredValue(i->getDest());
7585-
assert(!loweredDest.isUnallocatedAddressInBuffer());
75867505
Address dest = loweredDest.getAnyAddress();
75877506
if (i->isInitializationOfDest()) {
75887507
if (i->isTakeOfSrc()) {

0 commit comments

Comments
 (0)