rust/compiler/rustc_session/src
Jana Dönszelmann 69b11c64eb
Rollup merge of #142809 - KMJ-007:ad-type-analysis-flag, r=ZuseZ4
Add PrintTAFn flag for targeted type analysis printing

## 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
- Added `PrintTAFn=<function_name>` option to `-Z autodiff`
- Usage: `-Z autodiff=Enable,PrintTAFn=my_function_name`

### Implementation Details
- **Rust side**: Added `PrintTAFn(String)` variant to `AutoDiff` enum
- **Parser**: Updated `parse_autodiff` to handle `PrintTAFn=<function_name>` syntax with proper error handling
- **FFI**: Added `set_print_type_fun` function to interface with Enzyme's `FunctionToAnalyze` command line option
- **Documentation**: Updated help text and documentation for the new flag

### Files Modified
- `compiler/rustc_session/src/config.rs`: Added `PrintTAFn(String)` variant
- `compiler/rustc_session/src/options.rs`: Updated parser and help text (now shows `PrintTAFn` in the list)
- `compiler/rustc_codegen_llvm/src/llvm/enzyme_ffi.rs`: Added FFI function and static variable
- `compiler/rustc_codegen_llvm/src/back/lto.rs`: Added handling for new flag
- `src/doc/rustc-dev-guide/src/autodiff/flags.md`: Updated documentation
- `src/doc/unstable-book/src/compiler-flags/autodiff.md`: Updated documentation

## Testing
The flag can be tested with:
```bash
rustc +enzyme -Z autodiff=Enable,PrintTAFn=square test.rs
```

This will print type analysis information only for the function named "square" instead of all functions.

## Error Handling
The parser includes proper error handling:
- Missing argument: `PrintTAFn` without `=<function_name>` will show an error
- Unknown options: Invalid autodiff options will be reported

r? ```@ZuseZ4```
2025-06-25 22:14:55 +02:00
..
config Implement the internal feature cfg_target_has_reliable_f16_f128 2025-04-27 19:58:44 +00:00
code_stats.rs Document why CodeStats::type_sizes is public 2025-04-21 17:36:36 +02:00
config.rs Rollup merge of #142809 - KMJ-007:ad-type-analysis-flag, r=ZuseZ4 2025-06-25 22:14:55 +02:00
cstore.rs Initial support for dynamically linked crates 2025-05-04 22:03:15 +03:00
errors.rs move -Ctarget-feature handling into shared code 2025-06-19 09:44:01 +09:00
filesearch.rs rustc_session: Add a structure for keeping both explicit and default sysroots 2025-06-24 16:00:04 +03:00
lib.rs move -Ctarget-feature handling into shared code 2025-06-19 09:44:01 +09:00
options.rs Rollup merge of #142809 - KMJ-007:ad-type-analysis-flag, r=ZuseZ4 2025-06-25 22:14:55 +02:00
output.rs Initial support for dynamically linked crates 2025-05-04 22:03:15 +03:00
parse.rs Extract SilentEmitter 2025-06-19 13:05:01 -05:00
search_paths.rs Greatly simplify lifetime captures in edition 2024 2025-02-22 22:24:52 +00:00
session.rs rustc_session: Add a structure for keeping both explicit and default sysroots 2025-06-24 16:00:04 +03:00
utils.rs session: Cleanup CanonicalizedPath::new 2025-04-26 18:42:15 +03:00