@@ -1227,7 +1227,7 @@ void UseState::initializeLiveness(
1227
1227
auto accessPathWithBase =
1228
1228
AccessPathWithBase::computeInScope (li->getOperand ());
1229
1229
if (auto *beginAccess =
1230
- dyn_cast <BeginAccessInst>(accessPathWithBase.base )) {
1230
+ dyn_cast_or_null <BeginAccessInst>(accessPathWithBase.base )) {
1231
1231
for (auto *endAccess : beginAccess->getEndAccesses ()) {
1232
1232
liveness.updateForUse (endAccess, livenessInstAndValue.second ,
1233
1233
false /* lifetime ending*/ );
@@ -1247,7 +1247,7 @@ void UseState::initializeLiveness(
1247
1247
auto accessPathWithBase =
1248
1248
AccessPathWithBase::computeInScope (lbi->getOperand ());
1249
1249
if (auto *beginAccess =
1250
- dyn_cast <BeginAccessInst>(accessPathWithBase.base )) {
1250
+ dyn_cast_or_null <BeginAccessInst>(accessPathWithBase.base )) {
1251
1251
for (auto *endAccess : beginAccess->getEndAccesses ()) {
1252
1252
liveness.updateForUse (endAccess, livenessInstAndValue.second ,
1253
1253
false /* lifetime ending*/ );
@@ -2003,7 +2003,7 @@ struct GatherUsesVisitor : public TransitiveAddressWalker<GatherUsesVisitor> {
2003
2003
// TODO: Make this a we don't understand error.
2004
2004
assert (accessPath.isValid () && " Invalid access path?!" );
2005
2005
2006
- auto *bai = dyn_cast <BeginAccessInst>(accessPathWithBase.base );
2006
+ auto *bai = dyn_cast_or_null <BeginAccessInst>(accessPathWithBase.base );
2007
2007
2008
2008
if (!bai) {
2009
2009
LLVM_DEBUG (llvm::dbgs ()
@@ -3333,7 +3333,7 @@ void MoveOnlyAddressCheckerPImpl::rewriteUses(
3333
3333
if (auto *li = dyn_cast<LoadInst>(copyInst.first )) {
3334
3334
// Convert this to its take form.
3335
3335
auto accessPath = AccessPathWithBase::computeInScope (li->getOperand ());
3336
- if (auto *access = dyn_cast <BeginAccessInst>(accessPath.base ))
3336
+ if (auto *access = dyn_cast_or_null <BeginAccessInst>(accessPath.base ))
3337
3337
access->setAccessKind (SILAccessKind::Modify);
3338
3338
li->setOwnershipQualifier (LoadOwnershipQualifier::Take);
3339
3339
changed = true ;
@@ -3343,7 +3343,7 @@ void MoveOnlyAddressCheckerPImpl::rewriteUses(
3343
3343
if (auto *copy = dyn_cast<CopyAddrInst>(copyInst.first )) {
3344
3344
// Convert this to its take form.
3345
3345
auto accessPath = AccessPathWithBase::computeInScope (copy->getSrc ());
3346
- if (auto *access = dyn_cast <BeginAccessInst>(accessPath.base ))
3346
+ if (auto *access = dyn_cast_or_null <BeginAccessInst>(accessPath.base ))
3347
3347
access->setAccessKind (SILAccessKind::Modify);
3348
3348
copy->setIsTakeOfSrc (IsTake);
3349
3349
continue ;
0 commit comments