From 912ebd482b9847340d0db31d1d3c5b47f7e623ce Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 16 May 2026 23:37:15 +0000 Subject: [PATCH 1/2] Initial plan From ad79be7ba80740c81201c75d0c547aa36f2ede1a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 16 May 2026 23:39:44 +0000 Subject: [PATCH 2/2] Preserve noinline/debug info on lowered Enzyme calls Agent-Logs-Url: https://github.com/EnzymeAD/Enzyme/sessions/1cc6cbf7-94a6-48de-8348-912cce695620 Co-authored-by: wsmoses <1260124+wsmoses@users.noreply.github.com> --- enzyme/Enzyme/Enzyme.cpp | 5 +++++ enzyme/test/Enzyme/ReverseMode/undefalloc.ll | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/enzyme/Enzyme/Enzyme.cpp b/enzyme/Enzyme/Enzyme.cpp index 471d9b656a78..9fb5f43d0b39 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 4d5b537f33a5..0926059e3046 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]]