From 559196a437c886d395b2edcf9242496395c8b614 Mon Sep 17 00:00:00 2001 From: Manuel Drehwald Date: Sat, 4 Oct 2025 23:52:33 -0400 Subject: [PATCH 1/2] update libEnzyme file name, and add missing strict-aliasing flag --- src/autodiff/debugging.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/autodiff/debugging.md b/src/autodiff/debugging.md index bd46a66fa..a66d775d9 100644 --- a/src/autodiff/debugging.md +++ b/src/autodiff/debugging.md @@ -16,7 +16,7 @@ Before generating the llvm-ir, keep in mind two techniques that can help ensure ## 1) Generate an llvm-ir reproducer ```sh -rustflags="-z autodiff=enable,printmodbefore" cargo +enzyme build --release &> out.ll +RUSTFLAGS="-Z autodiff=Enable,PrintModbefore" cargo +enzyme build --release &> out.ll ``` This also captures a few warnings and info messages above and below your module. open out.ll and remove every line above `; moduleid = `. Now look at the end of the file and remove everything that's not part of llvm-ir, i.e. remove errors and warnings. The last line of your llvm-ir should now start with `! = `, i.e. `!40831 = !{i32 0, i32 1037508, i32 1037538, i32 1037559}` or `!43760 = !dilocation(line: 297, column: 5, scope: !43746)`. @@ -25,10 +25,10 @@ The actual numbers will depend on your code. ## 2) Check your llvm-ir reproducer -To confirm that your previous step worked, we will use llvm's `opt` tool. find your path to the opt binary, with a path similar to `/rust/build//build/bin/opt`. also find `llvmenzyme-19.` path, similar to `/rust/build/target-tripple/enzyme/build/enzyme/llvmenzyme-19`. Please keep in mind that llvm frequently updates it's llvm backend, so the version number might be higher (20, 21, ...). Once you have both, run the following command: +To confirm that your previous step worked, we will use llvm's `opt` tool. find your path to the opt binary, with a path similar to `/rust/build//build/bin/opt`. also find `llvmenzyme-19.` path, similar to `/rust/build/target-triple/enzyme/build/enzyme/llvmenzyme-19`. Please keep in mind that llvm frequently updates it's llvm backend, so the version number might be higher (20, 21, ...). Once you have both, run the following command: ```sh - out.ll -load-pass-plugin=/path/to/llvmenzyme-19.so -passes="enzyme" -s + out.ll -load-pass-plugin=/path/to/build//stage1/lib/libEnzyme-21.so -passes="enzyme" -enzyme-strict-aliasing=0 -s ``` If the previous step succeeded, you are going to see the same error that you saw when compiling your rust code with cargo. From 11feea01b383caea613f1f0e70477d1f3eff45eb Mon Sep 17 00:00:00 2001 From: Manuel Drehwald Date: Sun, 5 Oct 2025 01:38:29 -0400 Subject: [PATCH 2/2] Add potential instability warning --- src/autodiff/debugging.md | 1 + 1 file changed, 1 insertion(+) diff --git a/src/autodiff/debugging.md b/src/autodiff/debugging.md index a66d775d9..97893535c 100644 --- a/src/autodiff/debugging.md +++ b/src/autodiff/debugging.md @@ -30,6 +30,7 @@ To confirm that your previous step worked, we will use llvm's `opt` tool. find y ```sh out.ll -load-pass-plugin=/path/to/build//stage1/lib/libEnzyme-21.so -passes="enzyme" -enzyme-strict-aliasing=0 -s ``` +This command might fail for future versions or on your system, in which case you should replace libEnzyme-21.so with LLVMEnzyme-21.so. Look at the Enzyme docs for instructions on how to build it. You might need to also adjust how to build your LLVM version. If the previous step succeeded, you are going to see the same error that you saw when compiling your rust code with cargo.