From 735326d50d0463290fdc18b786ab1566d8ce8064 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20=C5=9Aliwak?= Date: Tue, 11 Jul 2023 14:05:04 +0200 Subject: [PATCH] Properly document FullInliner's prerequisites --- docs/internals/optimizer.rst | 7 ++++++- libyul/optimiser/FullInliner.h | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/docs/internals/optimizer.rst b/docs/internals/optimizer.rst index da72eed4e..ab37872ff 100644 --- a/docs/internals/optimizer.rst +++ b/docs/internals/optimizer.rst @@ -1192,7 +1192,7 @@ This component can only be used on sources with unique names. FullInliner ^^^^^^^^^^^ -The Full Inliner replaces certain calls of certain functions +The FullInliner replaces certain calls of certain functions by the function's body. This is not very helpful in most cases, because it just increases the code size but does not have a benefit. Furthermore, code is usually very expensive and we would often rather have shorter @@ -1216,6 +1216,11 @@ we can run the optimizer on this specialized function. If it results in heavy gains, the specialized function is kept, otherwise the original function is used instead. +FunctionHoister and ExpressionSplitter are recommended as prerequisites since they make the step +more efficient, but are not required for correctness. +In particular, function calls with other function calls as arguments are not inlined, but running +ExpressionSplitter beforehand ensures that there are no such calls in the input. + Cleanup ------- diff --git a/libyul/optimiser/FullInliner.h b/libyul/optimiser/FullInliner.h index 3001453cb..931315305 100644 --- a/libyul/optimiser/FullInliner.h +++ b/libyul/optimiser/FullInliner.h @@ -44,10 +44,10 @@ class NameCollector; * Optimiser component that modifies an AST in place, inlining functions. * Expressions are expected to be split, i.e. the component will only inline * function calls that are at the root of the expression and that only contains - * variables as arguments. More specifically, it will inline + * variables or literals as arguments. More specifically, it will inline * - let x1, ..., xn := f(a1, ..., am) * - x1, ..., xn := f(a1, ..., am) - * f(a1, ..., am) + * - f(a1, ..., am) * * The transform changes code of the form *