diff options
| author | Yong He <yonghe@outlook.com> | 2023-09-21 16:02:04 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-09-21 16:02:04 -0700 |
| commit | e31a9671d70c97c89f081d4f30ec0792050fd35c (patch) | |
| tree | c78f70540a171164a833445a90ac37da51cd0c0b /source/slang/slang-ir-inline.cpp | |
| parent | 5b2eb06816521cc0fcfe03258452560bd200002d (diff) | |
Revert inlining change in #3217. (#3229)
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-ir-inline.cpp')
| -rw-r--r-- | source/slang/slang-ir-inline.cpp | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/source/slang/slang-ir-inline.cpp b/source/slang/slang-ir-inline.cpp index 1d308c507..8412a1912 100644 --- a/source/slang/slang-ir-inline.cpp +++ b/source/slang/slang-ir-inline.cpp @@ -839,6 +839,8 @@ struct PreAutoDiffForceInliningPass : InliningPassBase : Super(module) {} + Dictionary<IRInst*, bool> m_funcCanInline; + bool shouldInline(CallSiteInfo const& info) { if (info.callee->findDecoration<IRUnsafeForceInlineEarlyDecoration>() || @@ -862,7 +864,31 @@ struct PreAutoDiffForceInliningPass : InliningPassBase break; } } - return (hasForceInline && !hasUserDefinedDerivative); + if (!hasForceInline || hasUserDefinedDerivative) + { + return false; + } + if (auto result = m_funcCanInline.tryGetValue(info.callee)) + return *result; + bool canInline = true; + for (auto block : info.callee->getBlocks()) + { + for (auto inst : block->getChildren()) + { + switch (inst->getOp()) + { + case kIROp_ForwardDifferentiate: + case kIROp_BackwardDifferentiate: + case kIROp_BackwardDifferentiatePrimal: + case kIROp_BackwardDifferentiatePropagate: + canInline = false; + goto end; + } + } + } + end:; + m_funcCanInline[info.callee] = canInline; + return canInline; } }; |
