Skip to content

Commit 16f9438

Browse files
committed
DI: Consistently use 'Use' instead of 'InstInfo' to name DIMemoryUse values
1 parent ff698f2 commit 16f9438

File tree

1 file changed

+37
-37
lines changed

1 file changed

+37
-37
lines changed

lib/SILOptimizer/Mandatory/DefiniteInitialization.cpp

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -547,12 +547,12 @@ namespace {
547547
void handleInOutUse(const DIMemoryUse &Use);
548548
void handleEscapeUse(const DIMemoryUse &Use);
549549

550-
void handleLoadUseFailure(const DIMemoryUse &InstInfo,
550+
void handleLoadUseFailure(const DIMemoryUse &Use,
551551
bool SuperInitDone,
552552
bool FailedSelfUse);
553553

554-
void handleSelfInitUse(DIMemoryUse &InstInfo);
555-
void updateInstructionForInitState(DIMemoryUse &InstInfo);
554+
void handleSelfInitUse(DIMemoryUse &Use);
555+
void updateInstructionForInitState(DIMemoryUse &Use);
556556

557557

558558
void processUninitializedRelease(SILInstruction *Release,
@@ -928,17 +928,17 @@ void LifetimeChecker::emitSelfConsumedDiagnostic(SILInstruction *Inst) {
928928
}
929929

930930
void LifetimeChecker::handleStoreUse(unsigned UseID) {
931-
DIMemoryUse &InstInfo = Uses[UseID];
931+
DIMemoryUse &Use = Uses[UseID];
932932

933933
// Determine the liveness state of the element that we care about.
934-
auto Liveness = getLivenessAtInst(InstInfo.Inst, InstInfo.FirstElement,
935-
InstInfo.NumElements);
934+
auto Liveness = getLivenessAtInst(Use.Inst, Use.FirstElement,
935+
Use.NumElements);
936936

937937
// Check to see if the stored location is either fully uninitialized or fully
938938
// initialized.
939939
bool isFullyInitialized = true;
940940
bool isFullyUninitialized = true;
941-
for (unsigned i = InstInfo.FirstElement, e = i+InstInfo.NumElements;
941+
for (unsigned i = Use.FirstElement, e = i+Use.NumElements;
942942
i != e;++i) {
943943
auto DI = Liveness.get(i);
944944
if (DI != DIKind::Yes)
@@ -948,41 +948,41 @@ void LifetimeChecker::handleStoreUse(unsigned UseID) {
948948
}
949949

950950
if (TheMemory.isNonRootClassSelf()) {
951-
if (getSelfInitializedAtInst(InstInfo.Inst) != DIKind::Yes) {
952-
auto SelfLiveness = getLivenessAtInst(InstInfo.Inst,
951+
if (getSelfInitializedAtInst(Use.Inst) != DIKind::Yes) {
952+
auto SelfLiveness = getLivenessAtInst(Use.Inst,
953953
0, TheMemory.NumElements);
954954
if (SelfLiveness.isAllYes()) {
955-
emitSelfConsumedDiagnostic(InstInfo.Inst);
955+
emitSelfConsumedDiagnostic(Use.Inst);
956956
return;
957957
}
958958
}
959959
}
960960

961961
// If this is a partial store into a struct and the whole struct hasn't been
962962
// initialized, diagnose this as an error.
963-
if (InstInfo.Kind == DIUseKind::PartialStore && !isFullyInitialized) {
964-
assert(InstInfo.NumElements == 1 && "partial stores are intra-element");
965-
diagnoseInitError(InstInfo, diag::struct_not_fully_initialized);
963+
if (Use.Kind == DIUseKind::PartialStore && !isFullyInitialized) {
964+
assert(Use.NumElements == 1 && "partial stores are intra-element");
965+
diagnoseInitError(Use, diag::struct_not_fully_initialized);
966966
return;
967967
}
968968

969969
// If this is a store to a 'let' property in an initializer, then we only
970970
// allow the assignment if the property was completely uninitialized.
971971
// Overwrites are not permitted.
972-
if (InstInfo.Kind == DIUseKind::PartialStore || !isFullyUninitialized) {
973-
for (unsigned i = InstInfo.FirstElement, e = i+InstInfo.NumElements;
972+
if (Use.Kind == DIUseKind::PartialStore || !isFullyUninitialized) {
973+
for (unsigned i = Use.FirstElement, e = i+Use.NumElements;
974974
i != e; ++i) {
975975
if (Liveness.get(i) == DIKind::No || !TheMemory.isElementLetProperty(i))
976976
continue;
977977

978978
// Don't emit errors for unreachable code, or if we have already emitted
979979
// a diagnostic.
980-
if (!shouldEmitError(InstInfo.Inst))
980+
if (!shouldEmitError(Use.Inst))
981981
continue;
982982

983983
std::string PropertyName;
984984
auto *VD = TheMemory.getPathStringToElement(i, PropertyName);
985-
diagnose(Module, InstInfo.Inst->getLoc(),
985+
diagnose(Module, Use.Inst->getLoc(),
986986
diag::immutable_property_already_initialized, PropertyName);
987987

988988
if (auto *Var = dyn_cast<VarDecl>(VD)) {
@@ -998,31 +998,31 @@ void LifetimeChecker::handleStoreUse(unsigned UseID) {
998998
// If this is an initialization or a normal assignment, upgrade the store to
999999
// an initialization or assign in the uses list so that clients know about it.
10001000
if (isFullyUninitialized) {
1001-
InstInfo.Kind = DIUseKind::Initialization;
1001+
Use.Kind = DIUseKind::Initialization;
10021002
} else if (isFullyInitialized) {
1003-
InstInfo.Kind = DIUseKind::Assign;
1003+
Use.Kind = DIUseKind::Assign;
10041004
} else {
10051005
// If it is initialized on some paths, but not others, then we have an
10061006
// inconsistent initialization, which needs dynamic control logic in the
10071007
// general case.
10081008

10091009
// This is classified as InitOrAssign (not PartialStore), so there are only
10101010
// a few instructions that could reach here.
1011-
assert(InstInfo.Kind == DIUseKind::InitOrAssign &&
1011+
assert(Use.Kind == DIUseKind::InitOrAssign &&
10121012
"should only have inconsistent InitOrAssign's here");
10131013

10141014
// If this access stores something of non-trivial type, then keep track of
10151015
// it for later. Once we've collected all of the conditional init/assigns,
10161016
// we can insert a single control variable for the memory object for the
10171017
// whole function.
1018-
if (!InstInfo.onlyTouchesTrivialElements(TheMemory))
1018+
if (!Use.onlyTouchesTrivialElements(TheMemory))
10191019
HasConditionalInitAssign = true;
10201020
return;
10211021
}
10221022

10231023
// Otherwise, we have a definite init or assign. Make sure the instruction
10241024
// itself is tagged properly.
1025-
updateInstructionForInitState(InstInfo);
1025+
updateInstructionForInitState(Use);
10261026
}
10271027

10281028
void LifetimeChecker::handleInOutUse(const DIMemoryUse &Use) {
@@ -1650,8 +1650,8 @@ void LifetimeChecker::handleLoadUseFailure(const DIMemoryUse &Use,
16501650

16511651
/// handleSelfInitUse - When processing a 'self' argument on a class, this is
16521652
/// a call to self.init or super.init.
1653-
void LifetimeChecker::handleSelfInitUse(DIMemoryUse &InstInfo) {
1654-
auto *Inst = InstInfo.Inst;
1653+
void LifetimeChecker::handleSelfInitUse(DIMemoryUse &Use) {
1654+
auto *Inst = Use.Inst;
16551655

16561656
assert(TheMemory.isAnyInitSelf());
16571657
assert(!TheMemory.isClassInitSelf() || TheMemory.isNonRootClassSelf());
@@ -1684,8 +1684,8 @@ void LifetimeChecker::handleSelfInitUse(DIMemoryUse &InstInfo) {
16841684
assert(TheMemory.NumElements == 1 && "delegating inits have a single elt");
16851685

16861686
// Lower Assign instructions if needed.
1687-
if (isa<AssignInst>(InstInfo.Inst))
1688-
updateInstructionForInitState(InstInfo);
1687+
if (isa<AssignInst>(Use.Inst))
1688+
updateInstructionForInitState(Use);
16891689
} else {
16901690
// super.init also requires that all ivars are initialized before the
16911691
// superclass initializer runs.
@@ -1694,10 +1694,10 @@ void LifetimeChecker::handleSelfInitUse(DIMemoryUse &InstInfo) {
16941694

16951695
// If the super.init call is implicit generated, produce a specific
16961696
// diagnostic.
1697-
bool isImplicit = InstInfo.Inst->getLoc().getSourceLoc().isInvalid();
1697+
bool isImplicit = Use.Inst->getLoc().getSourceLoc().isInvalid();
16981698
auto diag = isImplicit ? diag::ivar_not_initialized_at_implicit_superinit :
16991699
diag::ivar_not_initialized_at_superinit;
1700-
return diagnoseInitError(InstInfo, diag);
1700+
return diagnoseInitError(Use, diag);
17011701
}
17021702

17031703
// Otherwise everything is good!
@@ -1709,15 +1709,15 @@ void LifetimeChecker::handleSelfInitUse(DIMemoryUse &InstInfo) {
17091709
/// from being InitOrAssign to some concrete state, update it for that state.
17101710
/// This includes rewriting them from assign instructions into their composite
17111711
/// operations.
1712-
void LifetimeChecker::updateInstructionForInitState(DIMemoryUse &InstInfo) {
1713-
SILInstruction *Inst = InstInfo.Inst;
1712+
void LifetimeChecker::updateInstructionForInitState(DIMemoryUse &Use) {
1713+
SILInstruction *Inst = Use.Inst;
17141714

17151715
IsInitialization_t InitKind;
1716-
if (InstInfo.Kind == DIUseKind::Initialization ||
1717-
InstInfo.Kind == DIUseKind::SelfInit)
1716+
if (Use.Kind == DIUseKind::Initialization ||
1717+
Use.Kind == DIUseKind::SelfInit)
17181718
InitKind = IsInitialization;
17191719
else {
1720-
assert(InstInfo.Kind == DIUseKind::Assign);
1720+
assert(Use.Kind == DIUseKind::Assign);
17211721
InitKind = IsNotInitialization;
17221722
}
17231723

@@ -1751,8 +1751,8 @@ void LifetimeChecker::updateInstructionForInitState(DIMemoryUse &InstInfo) {
17511751
if (auto *AI = dyn_cast<AssignInst>(Inst)) {
17521752
// Remove this instruction from our data structures, since we will be
17531753
// removing it.
1754-
auto Kind = InstInfo.Kind;
1755-
InstInfo.Inst = nullptr;
1754+
auto Kind = Use.Kind;
1755+
Use.Inst = nullptr;
17561756
NonLoadUses.erase(Inst);
17571757

17581758
PartialInitializationKind PartialInitKind;
@@ -1767,8 +1767,8 @@ void LifetimeChecker::updateInstructionForInitState(DIMemoryUse &InstInfo) {
17671767
: PartialInitializationKind::IsNotInitialization);
17681768
}
17691769

1770-
unsigned FirstElement = InstInfo.FirstElement;
1771-
unsigned NumElements = InstInfo.NumElements;
1770+
unsigned FirstElement = Use.FirstElement;
1771+
unsigned NumElements = Use.NumElements;
17721772

17731773
SmallVector<SILInstruction*, 4> InsertedInsts;
17741774
SILBuilderWithScope B(Inst, &InsertedInsts);

0 commit comments

Comments
 (0)