Skip to content

[opt] Automatically skip known-no-op passes in pipelines#4036

Draft
copybara-service[bot] wants to merge 1 commit intomainfrom
test_879744536
Draft

[opt] Automatically skip known-no-op passes in pipelines#4036
copybara-service[bot] wants to merge 1 commit intomainfrom
test_879744536

Conversation

@copybara-service
Copy link
Copy Markdown

[opt] Automatically skip known-no-op passes in pipelines

If a pass is invoked twice on the same IR, and made no changes the first time, then we know it should make no changes the second time. Rather than rerunning the pass and any associated analyses, we can skip this entirely.

To support this, we add the GetInvocationSignature method to PassBase, so passes can declare a unique signature including any options that affect how the pass runs. Any pass that does not declare an invocation signature will run every time.

Certain passes are idempotent, meaning that if they're invoked twice in sequence, the second invocation will always be a no-op. We add the IsIdempotent method to let these passes opt into this stronger behavior.

If a pass is invoked twice on the same IR, and made no changes the first time, then we know it should make no changes the second time. Rather than rerunning the pass and any associated analyses, we can skip this entirely.

To support this, we add the `GetInvocationSignature` method to `PassBase`, so passes can declare a unique signature including any options that affect how the pass runs. Any pass that does not declare an invocation signature will run every time.

Certain passes are idempotent, meaning that if they're invoked twice in sequence, the second invocation will *always* be a no-op. We add the `IsIdempotent` method to let these passes opt into this stronger behavior.

PiperOrigin-RevId: 879744536
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant