Skip to content

Commit aa0d60a

Browse files
committed
TempRValueOptPass: some small cosmetic changes
1. WitnessMethodInst doesn't need to be handled as use because it's operand is a typedependent operand, which we exclude anyway when looking at the uses. 2. Replace a list of handled instructions with a default value in the switch. It's easy to forget to add an instruction here. So it's safer to have a default behavior.
1 parent ece5ab7 commit aa0d60a

File tree

1 file changed

+1
-11
lines changed

1 file changed

+1
-11
lines changed

lib/SILOptimizer/Transforms/CopyForwarding.cpp

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1714,12 +1714,10 @@ bool TempRValueOptPass::collectLoads(
17141714

17151715
case SILInstructionKind::LoadInst:
17161716
case SILInstructionKind::LoadBorrowInst:
1717-
case SILInstructionKind::WitnessMethodInst: {
17181717
// Loads are the end of the data flow chain. The users of the load can't
17191718
// access the temporary storage.
17201719
loadInsts.insert(user);
17211720
return true;
1722-
}
17231721

17241722
case SILInstructionKind::CopyAddrInst: {
17251723
// copy_addr which read from the temporary are like loads.
@@ -1834,17 +1832,9 @@ bool TempRValueOptPass::tryOptimizeCopyIntoTemp(CopyAddrInst *copyInst) {
18341832
use->set(copyInst->getSrc());
18351833
break;
18361834
}
1837-
case SILInstructionKind::StructElementAddrInst:
1838-
case SILInstructionKind::TupleElementAddrInst:
1839-
case SILInstructionKind::LoadInst:
1840-
case SILInstructionKind::LoadBorrowInst:
1841-
case SILInstructionKind::ApplyInst:
1842-
case SILInstructionKind::OpenExistentialAddrInst:
1835+
default:
18431836
use->set(copyInst->getSrc());
18441837
break;
1845-
1846-
default:
1847-
llvm_unreachable("unhandled instruction");
18481838
}
18491839
}
18501840
tempObj->eraseFromParent();

0 commit comments

Comments
 (0)