Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions enzyme/Enzyme/Enzyme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1721,6 +1721,8 @@ class EnzymeBase {
CallInst *diffretc = cast<CallInst>(Builder.CreateCall(newFunc, args));
diffretc->setCallingConv(CallingConv);
diffretc->setDebugLoc(CI->getDebugLoc());
if (CI->hasFnAttr(Attribute::NoInline))
diffretc->addFnAttr(Attribute::NoInline);

for (auto &&[attr, ty] : byVal) {
diffretc->addParamAttr(
Expand Down Expand Up @@ -2554,6 +2556,9 @@ class EnzymeBase {
fn = B.CreatePointerCast(fn, getUnqual(FT));
}
auto Rep = B.CreateCall(FT, fn, Args);
Rep->setDebugLoc(CI->getDebugLoc());
if (CI->hasFnAttr(Attribute::NoInline))
Rep->addFnAttr(Attribute::NoInline);
Rep->addAttribute(AttributeList::FunctionIndex,
Attribute::get(Rep->getContext(), "enzyme_inactive"));
CI->replaceAllUsesWith(Rep);
Expand Down
6 changes: 5 additions & 1 deletion enzyme/test/Enzyme/ReverseMode/undefalloc.ll
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ entry:
; Function Attrs: noinline nounwind uwtable
define dso_local double @dsumsquare(double %x) #0 {
entry:
%call = call fast double @__enzyme_autodiff(i8* bitcast (double (double)* @f to i8*), double %x)
%call = call fast noinline double @__enzyme_autodiff(i8* bitcast (double (double)* @f to i8*), double %x)
ret double %call
}

Expand All @@ -24,3 +24,7 @@ attributes #0 = { noinline nounwind uwtable }
; CHECK-NEXT: entry:
; CHECK-NEXT: ret { double } zeroinitializer
; CHECK-NEXT: }
; CHECK-LABEL: define dso_local double @dsumsquare(double %x)
; CHECK: %[[call:.+]] = call fast noinline { double } @diffef(double %x, double 1.000000e+00)
; CHECK-NEXT: %[[ret:.+]] = extractvalue { double } %[[call]], 0
; CHECK-NEXT: ret double %[[ret]]