From 9ff45682cfed861054950460a8f3c4f5712e9300 Mon Sep 17 00:00:00 2001 From: William Moses Date: Sun, 15 Sep 2024 01:37:50 -0500 Subject: [PATCH] Fix diffuse rooting (#1829) * add comment * fix --- src/rules/customrules.jl | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/rules/customrules.jl b/src/rules/customrules.jl index 9628623987..005557c65a 100644 --- a/src/rules/customrules.jl +++ b/src/rules/customrules.jl @@ -1141,6 +1141,22 @@ end if is_constant_value(gutils, orig) && is_constant_inst(gutils, orig) && !has_aug_fwd_rule(orig, gutils) return (false, true) end + non_rooting_use = false + fop = called_operand(orig)::LLVM.Function + for (i, v) in enumerate(operands(orig)[1:end-1]) + if v == val + if !any(a->kind(a) == kind(StringAttribute("enzymejl_returnRoots")), collect(parameter_attributes(fop, i))) + non_rooting_use = true + break + end + end + end + + # If the operand is just rooting, we don't need it and should override defaults + if !non_rooting_use + return (false, false) + end + # don't use default and always require the arg return (true, false) end