Skip to content

Commit

Permalink
Fix mem2reg on input fn arg (#1442)
Browse files Browse the repository at this point in the history
  • Loading branch information
wsmoses authored Sep 19, 2023
1 parent 3870f89 commit e8e4188
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
3 changes: 3 additions & 0 deletions enzyme/Enzyme/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2318,6 +2318,9 @@ Function *GetFunctionFromValue(Value *fn) {
continue;
}

if (isa<LoadInst>(cur))
continue;

if (!cur->mayWriteToMemory() && cur->getType()->isVoidTy())
continue;

Expand Down
18 changes: 18 additions & 0 deletions enzyme/test/Enzyme/ReverseMode/mem2regfn.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
; RUN: if [ %llvmver -lt 16 ]; then %opt < %s %loadEnzyme -enzyme-preopt=false -enzyme -S | FileCheck %s; fi
; RUN: %opt < %s %newLoadEnzyme -enzyme-preopt=false -passes="enzyme" -S | FileCheck %s

define double @_Z3food(double %0) {
ret double %0
}

define i32 @main() {
%a5 = alloca i8*, align 8
store i8* bitcast (double (double)* @_Z3food to i8*), i8** %a5, align 8
%a17 = load i8*, i8** %a5, align 8
%q = call double (...) @__enzyme_autodiff(i8* %a17, metadata !"enzyme_dup", double 1.0, double 1.0)
ret i32 0
}

declare double @__enzyme_autodiff(...)

; CHECK: define internal void @diffe_Z3food

0 comments on commit e8e4188

Please sign in to comment.