35
35
#include " swift/SIL/DebugUtils.h"
36
36
#include " swift/SIL/Dominance.h"
37
37
#include " swift/SIL/DynamicCasts.h"
38
+ #include " swift/SIL/InstructionUtils.h"
38
39
#include " swift/SIL/MemAccessUtils.h"
39
40
#include " swift/SIL/OwnershipLiveness.h"
40
41
#include " swift/SIL/OwnershipUtils.h"
@@ -572,6 +573,11 @@ void verifyKeyPathComponent(SILModule &M,
572
573
// / open_existential_addr. We should expand it as needed.
573
574
struct ImmutableAddressUseVerifier {
574
575
SmallVector<Operand *, 32 > worklist;
576
+ bool ignoreDestroys;
577
+ bool defaultIsMutating;
578
+
579
+ ImmutableAddressUseVerifier (bool ignoreDestroys = false , bool defaultIsMutating = false )
580
+ : ignoreDestroys(ignoreDestroys), defaultIsMutating(defaultIsMutating) {}
575
581
576
582
bool isConsumingOrMutatingArgumentConvention (SILArgumentConvention conv) {
577
583
switch (conv) {
@@ -704,10 +710,9 @@ struct ImmutableAddressUseVerifier {
704
710
}
705
711
}
706
712
707
- // Otherwise this is a builtin that we are not expecting to see, so bail
708
- // and assert.
709
- llvm::errs () << " Unhandled, unexpected builtin instruction: " << *inst;
710
- llvm_unreachable (" invoking standard assertion failure" );
713
+ // Otherwise this is a builtin that we are not expecting to see.
714
+ if (defaultIsMutating)
715
+ return true ;
711
716
break ;
712
717
}
713
718
case SILInstructionKind::MarkDependenceInst:
@@ -775,7 +780,9 @@ struct ImmutableAddressUseVerifier {
775
780
else
776
781
break ;
777
782
case SILInstructionKind::DestroyAddrInst:
778
- return true ;
783
+ if (!ignoreDestroys)
784
+ return true ;
785
+ break ;
779
786
case SILInstructionKind::UpcastInst:
780
787
case SILInstructionKind::UncheckedAddrCastInst: {
781
788
if (isAddrCastToNonConsuming (cast<SingleValueInstruction>(inst))) {
@@ -842,9 +849,7 @@ struct ImmutableAddressUseVerifier {
842
849
}
843
850
break ;
844
851
}
845
- llvm::errs () << " Unhandled, unexpected instruction: " << *inst;
846
- llvm_unreachable (" invoking standard assertion failure" );
847
- break ;
852
+ return true ;
848
853
}
849
854
case SILInstructionKind::TuplePackElementAddrInst: {
850
855
if (&cast<TuplePackElementAddrInst>(inst)->getOperandRef (
@@ -866,8 +871,8 @@ struct ImmutableAddressUseVerifier {
866
871
return false ;
867
872
}
868
873
default :
869
- llvm::errs () << " Unhandled, unexpected instruction: " << *inst;
870
- llvm_unreachable ( " invoking standard assertion failure " ) ;
874
+ if (defaultIsMutating)
875
+ return true ;
871
876
break ;
872
877
}
873
878
}
@@ -7386,6 +7391,11 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
7386
7391
#undef require
7387
7392
#undef requireObjectType
7388
7393
7394
+ bool swift::isIndirectArgumentMutated (SILFunctionArgument *arg, bool ignoreDestroys,
7395
+ bool defaultIsMutating) {
7396
+ return ImmutableAddressUseVerifier (ignoreDestroys, defaultIsMutating).isMutatingOrConsuming (arg);
7397
+ }
7398
+
7389
7399
// ===----------------------------------------------------------------------===//
7390
7400
// Out of Line Verifier Run Functions
7391
7401
// ===----------------------------------------------------------------------===//
0 commit comments