diff --git a/enzyme/Enzyme/Enzyme.cpp b/enzyme/Enzyme/Enzyme.cpp index 471d9b656a7..9fb5f43d0b3 100644 --- a/enzyme/Enzyme/Enzyme.cpp +++ b/enzyme/Enzyme/Enzyme.cpp @@ -1721,6 +1721,8 @@ class EnzymeBase { CallInst *diffretc = cast(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( @@ -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); diff --git a/enzyme/test/Enzyme/ReverseMode/undefalloc.ll b/enzyme/test/Enzyme/ReverseMode/undefalloc.ll index 4d5b537f33a..0926059e304 100644 --- a/enzyme/test/Enzyme/ReverseMode/undefalloc.ll +++ b/enzyme/test/Enzyme/ReverseMode/undefalloc.ll @@ -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 } @@ -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]]