void GradientUtils::computeMinCache(): Assertion `legalRecompute(V, Available2, nullptr)' failed
- Dominant language
- LLVM
- Stars
- 1.7k
- Forks
- 188
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 22
Description
https://tinyurl.com/256a253c
Thanks for the previous bugfix. It seems like the same function still has a related bug, since the same code now runs into this error:
```llvm
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
@enzyme_primal_return = external global ptr
@enzyme_dup = external global ptr
@enzyme_const = external global ptr
define hidden noundef "enzyme_type"="{[-1]:Float@double}" double @wrap(ptr noundef readonly captures(none) "enzyme_type"="{[-1]:Pointer, [-1,0]:Float@double}" %diag, ptr noundef writeonly captures(none) "enzyme_type"="{[-1]:Pointer, [-1,0]:Float@double}" %out) unnamed_addr #0 {
start:
%seed = load double, ptr %diag, align 8
br label %loop
loop: ; preds = %loop, %start
%i = phi i64 [ 0, %start ], [ %i.next, %loop ]
%gu = phi double [ %seed, %start ], [ %gu.next, %loop ]
%i.next = add nuw nsw i64 %i, 1
%p = getelementptr inbounds nuw double, ptr %diag, i64 %i
%v = load double, ptr %p, align 8
%cmp = fcmp ogt double %gu, %v
%vplus = fadd double %v, 0.000000e+00
%gu.next = select i1 %cmp, double %gu, double %vplus
%done = icmp eq i64 %i.next, 8
br i1 %done, label %exit, label %loop
exit: ; preds = %loop
%gu.final = phi double [ %gu.next, %loop ]
%isneg = fcmp ogt double %gu.final, 0.000000e+00
%sigma = select i1 %isneg, double 0.000000e+00, double %gu.final
%slot = getelementptr inbounds nuw i8, ptr %out, i64 56
store double %sigma, ptr %slot, align 8
ret double 0.000000e+00
}
define noundef double @entry(ptr noundef %diag, ptr noundef %ddiag, ptr noundef %out) unnamed_addr #1 {
%r = tail call double (...) @__enzyme_autodiff(ptr nonnull @wrap, ptr nonnull @enzyme_primal_return, ptr nonnull @enzyme_dup, ptr %diag, ptr %ddiag, ptr nonnull @enzyme_const, ptr %out)
ret double %r
}
declare double @__enzyme_autodiff(...) local_unnamed_addr
attributes #0 = { nofree norecurse nosync nounwind nonlazybind memory(argmem: readwrite) uwtable "probe-stack"="inline-asm" "target-cpu"="x86-64" }
attributes #1 = { nonlazybind uwtable "probe-stack"="inline-asm" "target-cpu"="x86-64" }
```
@wsmoses
Contributor guide
Research direction
Start with the reduced LLVM IR in the linked reproducer and trace GradientUtils::computeMinCache(), focusing on the failing legalRecompute(V, Available2, nullptr) assertion. Compare this case with the previous bugfix referenced in the report; done means the reproducer no longer aborts and the relevant regression coverage passes.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100