Skip to content

Commit 3bcf41e

Browse files
committed
Revert "Ban address phis in non-OSSA as well"
This reverts commit 923c62c.
1 parent aec29cc commit 3bcf41e

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

lib/SIL/Verifier/SILVerifier.cpp

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -985,6 +985,24 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
985985
return InstNumbers[a] < InstNumbers[b];
986986
}
987987

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+
9881006
void visitSILPhiArgument(SILPhiArgument *arg) {
9891007
// Verify that the `isPhiArgument` property is sound:
9901008
// - Phi arguments come from branches.
@@ -1008,7 +1026,7 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
10081026
"All phi argument inputs must be from branches.");
10091027
}
10101028
}
1011-
if (arg->isPhi()) {
1029+
if (arg->isPhi() && prohibitAddressPhis()) {
10121030
// As a property of well-formed SIL, we disallow address-type
10131031
// phis. Supporting them would prevent reliably reasoning about the
10141032
// underlying storage of memory access. This reasoning is important for

0 commit comments

Comments
 (0)