Skip to content

Add -Zautodiff_post_passes flag to limit which llvm passes to run after enzyme to make autodiff tests more robust#156777

Open
sgasho wants to merge 2 commits into
rust-lang:mainfrom
sgasho:test-fix-codegen-llvm-autodiff-2
Open

Add -Zautodiff_post_passes flag to limit which llvm passes to run after enzyme to make autodiff tests more robust#156777
sgasho wants to merge 2 commits into
rust-lang:mainfrom
sgasho:test-fix-codegen-llvm-autodiff-2

Conversation

@sgasho

@sgasho sgasho commented May 20, 2026

Copy link
Copy Markdown
Contributor
  • Add -Zautodiff_post_passes flag to limit which llvm passes to run after enzyme to make autodiff tests more robust
  • Change some llvm ir check in codegen_llvm/autodiff tests

r? @ZuseZ4

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 20, 2026
@rust-cloud-vms rust-cloud-vms Bot force-pushed the test-fix-codegen-llvm-autodiff-2 branch from 64371d7 to 0da69f6 Compare June 12, 2026 14:47
@sgasho

sgasho commented Jun 12, 2026

Copy link
Copy Markdown
Contributor Author

I tested this PR still works after enzyme submodule update: #157716

@ZuseZ4

ZuseZ4 commented Jun 15, 2026

Copy link
Copy Markdown
Member

I think I've seen some of these changes before, so my concern is that either we continue to make the tests increasingly weaker, or we'll keep swapping back and forth between different outputs.
In the past, I added the noPostOpt flag, which made it a little better, but since the output still changed, we should find a more robust solution before putting it in CI.
Can you have a look at the -C passes=val -- a list of extra LLVM passes to run (space separated) flag, as well as some of the enzyme tests which run extra opts after enzyme?
https://github.com/EnzymeAD/Enzyme/blob/c96508349d9f121957292308c646b4a1fd53c507/enzyme/test/Enzyme/ReverseMode/add.ll#L2

We probably want to remove -Zautodiff=NoPostopt and replace it with -Zautodiff=Passes=... or something like that.
There is a -Zoffload=Host=path flag, which is also nested as an example.
The idea is that not setting the flag would result in the current behavior (full O3 after Enzyme), setting it to "" would be equal to the current NoPostOpt flag (which can then be removed) and by setting anything else we can specify the actual passes to run, similar to Enzyme.

@rustbot rustbot added the A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. label Jun 20, 2026
@sgasho sgasho changed the title Fix LLVM IR expectations for the autodiff abi_handling tests Add -Zautodiff_post_passes flag to limit which llvm passes to run after enzyme to make autodiff tests more robust Jun 20, 2026
@sgasho sgasho force-pushed the test-fix-codegen-llvm-autodiff-2 branch from 04bcb8e to 08f1ff1 Compare June 20, 2026 11:43
@sgasho

sgasho commented Jun 20, 2026

Copy link
Copy Markdown
Contributor Author

Thanks!
I added the autodiff_post_passes flag. I thought it would be convenient to pass LLVM passes in the same format LLVM expects, comma separated. If we add a nested option like -Zautodiff=Passes=..., we would need special parsing or escaping, since -Zautodiff options are also separated by commas.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants