Skip to content

Commit ad877f0

Browse files
authored
Merge pull request #46 from EnzymeAD/more-env-config
add env to print mod after enzyme
2 parents 03f3cb0 + 03e5534 commit ad877f0

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,19 @@ cargo +enzyme test --examples
3535
```
3636

3737
## Enzyme Config
38-
To help with debugging, Enzyme can be configured using four environment variables.
38+
To help with debugging, Enzyme can be configured using environment variables.
3939
```bash
4040
export ENZYME_PRINT_TA=1
4141
export ENZYME_PRINT_AA=1
4242
export ENZYME_PRINT=1
4343
export ENZYME_PRINT_MOD=1
44+
export ENZYME_PRINT_MOD_AFTER=1
4445
```
4546
The first three will print TypeAnalysis, ActivityAnalysis and the llvm-ir on a function basis, respectively.
46-
The last variable can be used to print the whole module directly before Enzyme starts
47-
differentiating functions.
47+
The last two variables will print the whole module directly before and after Enzyme differented the functions.
4848

49-
We want to make sure that we have EnzymeStrictAliasing=0 all the time to make sure
50-
that Enzyme handles enums correctly. Other flags might be enabled for debug purpose.
49+
When experimenting with flags please make sure that EnzymeStrictAliasing=0
50+
is not changed, since it is required for Enzyme to handle enums correctly.
5151

5252

5353

compiler/rustc_codegen_llvm/src/back/write.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,6 @@ pub(crate) unsafe fn differentiate(
748748

749749
if std::env::var("ENZYME_PRINT_MOD").is_ok() {
750750
unsafe {LLVMDumpModule(llmod);}
751-
752751
}
753752
for item in diff_items {
754753
let res = enzyme_ad(llmod, llcx, item);
@@ -772,6 +771,9 @@ pub(crate) unsafe fn differentiate(
772771
break;
773772
}
774773
}
774+
if std::env::var("ENZYME_PRINT_MOD_AFTER").is_ok() {
775+
unsafe {LLVMDumpModule(llmod);}
776+
}
775777

776778
Ok(())
777779
}

0 commit comments

Comments
 (0)