Add PrintTAFn flag for targeted type analysis printing #142809
+44
−5
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds a new
PrintTAFn
flag to the-Z autodiff
option that allows printing type analysis information for a specific function, rather than all functions.Changes
New Flag
PrintTAFn=<function_name>
option to-Z autodiff
-Z autodiff=Enable,PrintTAFn=my_function_name
Implementation Details
PrintTAFn(String)
variant toAutoDiff
enumparse_autodiff
to handlePrintTAFn=<function_name>
syntax with proper error handlingset_print_type_fun
function to interface with Enzyme'sFunctionToAnalyze
command line optionFiles Modified
compiler/rustc_session/src/config.rs
: AddedPrintTAFn(String)
variantcompiler/rustc_session/src/options.rs
: Updated parser and help text (now showsPrintTAFn
in the list)compiler/rustc_codegen_llvm/src/llvm/enzyme_ffi.rs
: Added FFI function and static variablecompiler/rustc_codegen_llvm/src/back/lto.rs
: Added handling for new flagsrc/doc/rustc-dev-guide/src/autodiff/flags.md
: Updated documentationsrc/doc/unstable-book/src/compiler-flags/autodiff.md
: Updated documentationTesting
The flag can be tested with:
This will print type analysis information only for the function named "square" instead of all functions.
Error Handling
The parser includes proper error handling:
PrintTAFn
without=<function_name>
will show an errorr? @ZuseZ4