@@ -15,17 +15,33 @@ is harder to minimize, please consider using [icemelter](https://github.com/lang
15
15
If after a compilation failure you are greeted by a large amount of LLVM-IR code,
16
16
then our Enzyme backend likely failed to compile your code.
17
17
These cases are harder to debug, so your help is highly appreciated.
18
+ Please also keep in mind, that release builds are usually much more likely to work at the moment.
18
19
19
20
The final goal here is to reproduce your bug in the Enzyme [ compiler explorer] ( https://enzyme.mit.edu/explorer/ ) ,
20
21
in order to create a bug report in the [ Enzyme core] ( https://github.com/EnzymeAD/Enzyme/issues ) repository.
21
22
22
- Few lines of Rust code will expand into much larger LLVM-IR.
23
- It is therefore important to reduce a Rust reproducer as
24
- far as possible, before trying to minimize the generated LLVM-IR.
25
- While manual minimization can not always be avoided, here are
26
- some tools, that might help. Once you have a minimal Rust example (strongly preferable without using other crates),
27
- then please create an issue.
23
+ We have an environment variable called ` ENZYME_OPT ` to help with this. It will print the whole LLVM-IR module,
24
+ along with dummy functions called ` enzyme_opt_dbg_helper_<i> ` . A potential workflow on Linux could look like:
28
25
26
+ ` cargo clean && ENZYME_OPT=1 cargo +enzyme build &> out.ll `
27
+ This also captures a few warnings and info messages above and below your module.
28
+ Open out.ll and remove every line above ` ; ModuleID = <SomeHash> ` and every line below the last DILocation,
29
+ e.g. below ` !43760 = !DILocation(line: 297, column: 5, scope: !43746) ` . The actual numbers will depend on your code.
30
+
31
+ ` llvm-extract -S --func=f --recursive --rfunc="enzyme_opt_helper_*" out.ll -o mwe.ll `
32
+ Please also adjust the name passed with the ` --func ` flag if your function isn't called ` f ` . Either look up the correct
33
+ llvm-ir name for your function in out.ll, or use the ` #[no_mangle] ` attribute on the function which you differentiate, in which case
34
+ you can pass the original Rust function name to this flag.
35
+
36
+ Afterwards, you should be able to copy and paste your mwe example into our [ compiler explorer] ( https://enzyme.mit.edu/explorer/ ) and
37
+ hopefully reproduce the same Enzyme error, which you got when you tried to compile your original Rust code.
38
+ Please select ` LLVM IR ` as a language and ` opt 17 ` as your compiler and replace the LLVM-IR example with your final mwe.ll content.
39
+
40
+ You will quickly note that even small Rust function can generate large llvm-ir reproducer. Please try to get your llvm-ir function below
41
+ 100 lines, by reducing the Rust function to be differentiated as far as possible. This will significantly speed up the bug fixing process.
42
+ Please also try to post both, the compiler-explorer link with your llvm-ir reproducer, as well as a self-contained Rust reproducer.
43
+
44
+ There are a few solutions to help you with minimizing the Rust reproducer.
29
45
This is probably the most simple automated approach:
30
46
[ cargo-minimize] ( https://github.com/Nilstrieb/cargo-minimize )
31
47
@@ -41,7 +57,7 @@ Potentially also
41
57
To support you while debugging, we have added support for various environment variables,
42
58
which allow changing the behaviour of Enzyme, without recompiling rustc.
43
59
If you change your environment variables, you may need to run ` cargo clean ` to see the new behaviour.
44
- We currently support:
60
+ We currently support the following debug variables :
45
61
``` bash
46
62
export ENZYME_PRINT_TA=1
47
63
export ENZYME_PRINT_AA=1
@@ -51,6 +67,7 @@ export ENZYME_PRINT_MOD_BEFORE=1
51
67
export ENZYME_PRINT_MOD_AFTER_ENZYME=1
52
68
export ENZYME_PRINT_MOD_AFTER_OPTS=1
53
69
export ENZYME_LOOSE_TYPES=1
70
+ export ENZYME_OPT=1
54
71
```
55
72
56
73
For performance experiments and benchmarking we also support
0 commit comments