Skip to content

Revert "Ban address phis in non-OSSA as well" #61018

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 9, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion lib/SIL/Verifier/SILVerifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -985,6 +985,24 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
return InstNumbers[a] < InstNumbers[b];
}

// FIXME: For sanity, address-type phis should be prohibited at all SIL
// stages. However, the optimizer currently breaks the invariant in three
// places:
// 1. Normal Simplify CFG during conditional branch simplification
// (sneaky jump threading).
// 2. Simplify CFG via Jump Threading.
// 3. Loop Rotation.
//
// BasicBlockCloner::canCloneInstruction and sinkAddressProjections is
// designed to avoid this issue, we just need to make sure all passes use it
// correctly.
//
// Minimally, we must prevent address-type phis as long as access markers are
// preserved. A goal is to preserve access markers in OSSA.
bool prohibitAddressPhis() {
return F.hasOwnership();
}

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