Skip to content

Commit ea72895

Browse files
committed
EscapeAnalysis: change the parameter of isNonWritableMemoryAddress from SILNode* to SILValue
A small cleanup, NFC.
1 parent ee599d8 commit ea72895

File tree

1 file changed

+22
-20
lines changed

1 file changed

+22
-20
lines changed

lib/SILOptimizer/Analysis/EscapeAnalysis.cpp

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -207,20 +207,20 @@ SILValue EscapeAnalysis::getPointerRoot(SILValue value) {
207207
return value;
208208
}
209209

210-
static bool isNonWritableMemoryAddress(SILNode *V) {
210+
static bool isNonWritableMemoryAddress(SILValue V) {
211211
switch (V->getKind()) {
212-
case SILNodeKind::FunctionRefInst:
213-
case SILNodeKind::DynamicFunctionRefInst:
214-
case SILNodeKind::PreviousDynamicFunctionRefInst:
215-
case SILNodeKind::WitnessMethodInst:
216-
case SILNodeKind::ClassMethodInst:
217-
case SILNodeKind::SuperMethodInst:
218-
case SILNodeKind::ObjCMethodInst:
219-
case SILNodeKind::ObjCSuperMethodInst:
220-
case SILNodeKind::StringLiteralInst:
221-
case SILNodeKind::ThinToThickFunctionInst:
222-
case SILNodeKind::ThinFunctionToPointerInst:
223-
case SILNodeKind::PointerToThinFunctionInst:
212+
case ValueKind::FunctionRefInst:
213+
case ValueKind::DynamicFunctionRefInst:
214+
case ValueKind::PreviousDynamicFunctionRefInst:
215+
case ValueKind::WitnessMethodInst:
216+
case ValueKind::ClassMethodInst:
217+
case ValueKind::SuperMethodInst:
218+
case ValueKind::ObjCMethodInst:
219+
case ValueKind::ObjCSuperMethodInst:
220+
case ValueKind::StringLiteralInst:
221+
case ValueKind::ThinToThickFunctionInst:
222+
case ValueKind::ThinFunctionToPointerInst:
223+
case ValueKind::PointerToThinFunctionInst:
224224
// These instructions return pointers to memory which can't be a
225225
// destination of a store.
226226
return true;
@@ -1622,8 +1622,10 @@ void EscapeAnalysis::ConnectionGraph::verify() const {
16221622
ReachableBlocks reachable(F);
16231623
reachable.visit([this](SILBasicBlock *bb) {
16241624
for (auto &i : *bb) {
1625-
if (isNonWritableMemoryAddress(&i))
1626-
continue;
1625+
if (auto *svi = dyn_cast<SingleValueInstruction>(&i)) {
1626+
if (isNonWritableMemoryAddress(svi))
1627+
continue;
1628+
}
16271629

16281630
if (auto ai = dyn_cast<ApplyInst>(&i)) {
16291631
if (EA->canOptimizeArrayUninitializedCall(ai).isValid())
@@ -2060,17 +2062,17 @@ void EscapeAnalysis::analyzeInstruction(SILInstruction *I,
20602062
if (auto *SVI = dyn_cast<SingleValueInstruction>(I)) {
20612063
if (getPointerBase(SVI))
20622064
return;
2065+
2066+
// Instructions which return the address of non-writable memory cannot have
2067+
// an effect on escaping.
2068+
if (isNonWritableMemoryAddress(SVI))
2069+
return;
20632070
}
20642071

20652072
// Incidental uses produce no values and have no effect on their operands.
20662073
if (isIncidentalUse(I))
20672074
return;
20682075

2069-
// Instructions which return the address of non-writable memory cannot have
2070-
// an effect on escaping.
2071-
if (isNonWritableMemoryAddress(I))
2072-
return;
2073-
20742076
switch (I->getKind()) {
20752077
case SILInstructionKind::AllocStackInst:
20762078
case SILInstructionKind::AllocRefInst:

0 commit comments

Comments
 (0)