@@ -985,6 +985,24 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
985
985
return InstNumbers[a] < InstNumbers[b];
986
986
}
987
987
988
+ // FIXME: For sanity, address-type phis should be prohibited at all SIL
989
+ // stages. However, the optimizer currently breaks the invariant in three
990
+ // places:
991
+ // 1. Normal Simplify CFG during conditional branch simplification
992
+ // (sneaky jump threading).
993
+ // 2. Simplify CFG via Jump Threading.
994
+ // 3. Loop Rotation.
995
+ //
996
+ // BasicBlockCloner::canCloneInstruction and sinkAddressProjections is
997
+ // designed to avoid this issue, we just need to make sure all passes use it
998
+ // correctly.
999
+ //
1000
+ // Minimally, we must prevent address-type phis as long as access markers are
1001
+ // preserved. A goal is to preserve access markers in OSSA.
1002
+ bool prohibitAddressPhis () {
1003
+ return F.hasOwnership ();
1004
+ }
1005
+
988
1006
void visitSILPhiArgument (SILPhiArgument *arg) {
989
1007
// Verify that the `isPhiArgument` property is sound:
990
1008
// - Phi arguments come from branches.
@@ -1008,7 +1026,7 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
1008
1026
" All phi argument inputs must be from branches." );
1009
1027
}
1010
1028
}
1011
- if (arg->isPhi ()) {
1029
+ if (arg->isPhi () && prohibitAddressPhis () ) {
1012
1030
// As a property of well-formed SIL, we disallow address-type
1013
1031
// phis. Supporting them would prevent reliably reasoning about the
1014
1032
// underlying storage of memory access. This reasoning is important for
0 commit comments