@@ -315,12 +315,27 @@ struct TypeTreeLeafTypeRange {
315315 return std::nullopt ;
316316
317317 // A drop_deinit only consumes the deinit bit of its operand.
318- auto *ddi = dyn_cast<DropDeinitInst>(op->getUser ());
319- if (ddi) {
318+ if (isa<DropDeinitInst>(op->getUser ())) {
320319 auto upperBound = *startEltOffset + TypeSubElementCount (projectedValue);
321320 return {{upperBound - 1 , upperBound}};
322321 }
323322
323+ // An `inject_enum_addr` only initializes the enum tag.
324+ if (auto inject = dyn_cast<InjectEnumAddrInst>(op->getUser ())) {
325+ auto upperBound = *startEltOffset + TypeSubElementCount (projectedValue);
326+ unsigned payloadUpperBound = 0 ;
327+ if (inject->getElement ()->hasAssociatedValues ()) {
328+ auto payloadTy = projectedValue->getType ()
329+ .getEnumElementType (inject->getElement (), op->getFunction ());
330+
331+ payloadUpperBound = *startEltOffset
332+ + TypeSubElementCount (payloadTy, op->getFunction ());
333+ }
334+ // TODO: account for deinit component if enum has deinit.
335+ assert (!projectedValue->getType ().isValueTypeWithDeinit ());
336+ return {{payloadUpperBound, upperBound}};
337+ }
338+
324339 // Uses that borrow a value do not involve the deinit bit.
325340 //
326341 // FIXME: This shouldn't be limited to applies.
@@ -984,7 +999,7 @@ class FieldSensitivePrunedLiveness {
984999 return *&iter->second ;
9851000 }
9861001
987- // / If \p user has had uses recored , return a pointer to the InterestingUser
1002+ // / If \p user has had uses recorded , return a pointer to the InterestingUser
9881003 // / where they've been recorded.
9891004 InterestingUser const *getInterestingUser (SILInstruction *user) const {
9901005 auto iter = users.find (user);
0 commit comments