Context:
I'm currently investigating some issues differentiating MLIR-generated LLVMIR with Enzyme. Our pipeline roughly consists of *Dialects -> LLVMDialect -> LLVMIR -> O2 -> Enzyme. While investigating, I decided to disable inlining of all function definitions (using the noinline attribute) during O2 in order to better trace what is happening where. However, this resulted in a new compilation error from Enzyme.
Issue:
pp: %_replacementA = phi ptr of %3 = tail call ptr @_mlir_memref_to_llvm_alloc() #0
Assertion failed: (pp->getNumUses() == 0), function eraseFictiousPHIs, file GradientUtils.cpp, line 8242.
I believe this error stems from Enzyme replacing allocation calls in the example IR with placeholder PHI instructions, but failing to delete them afterwards because of remaining uses of instruction result. I don't have a good understanding of the surrounding mechanism in Enzyme however.
Reproducer:
I've used the llvm-reduce tool to generate a minimal example of the failure (ran both before and after the O2 pass), so it's possible the IR doesn't make much "sense" anymore, but hopefully it still demonstrates the problem in the same way. The original was much longer but I can provide that too if necessary.
Context: I'm currently investigating some issues differentiating MLIR-generated LLVMIR with Enzyme. Our pipeline roughly consists of
*Dialects -> LLVMDialect -> LLVMIR -> O2 -> Enzyme
. While investigating, I decided to disable inlining of all function definitions (using thenoinline
attribute) during O2 in order to better trace what is happening where. However, this resulted in a new compilation error from Enzyme.Issue:
I believe this error stems from Enzyme replacing allocation calls in the example IR with placeholder PHI instructions, but failing to delete them afterwards because of remaining uses of instruction result. I don't have a good understanding of the surrounding mechanism in Enzyme however.
Reproducer: I've used the
llvm-reduce
tool to generate a minimal example of the failure (ran both before and after the O2 pass), so it's possible the IR doesn't make much "sense" anymore, but hopefully it still demonstrates the problem in the same way. The original was much longer but I can provide that too if necessary.Versions: llvm=3a8316216807d64a586b971f51695e23883331f7 enzyme=v0.0.130