From 0eb32b3f60be40cf80e3d9f0f6b4a06180da88f8 Mon Sep 17 00:00:00 2001 From: Daniel Kirchner Date: Wed, 16 Sep 2020 10:47:13 +0200 Subject: [PATCH] Rephrase documentation of memoryguard --- docs/yul.rst | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/docs/yul.rst b/docs/yul.rst index 0e30a9082..cbffd9e5c 100644 --- a/docs/yul.rst +++ b/docs/yul.rst @@ -956,16 +956,22 @@ memoryguard ^^^^^^^^^^^ This function is available in the EVM dialect with objects. The caller of -``let ptr := memoryguard(size)`` promises that they only use memory in either -the range ``[0, size)`` or the unbounded range above ``ptr``. The Yul optimizer -promises to only use the memory range ``[size, ptr)`` for its purposes. -If the optimizer does not need to reserve any memory, it holds that ``ptr := size``. +``let ptr := memoryguard(size)`` (where ``size`` has to be a literal number) +promises that they only use memory in either the range ``[0, size)`` or the +unbounded range above ``ptr``. + +Since the presence of a ``memoryguard`` call indicates that all memory access +adheres to this restriction, it allows the optimizer to perform additional +optimization steps, for example the stack limit evader, which attempts to move +stack variables that would otherwise be unreachable to memory. + +The Yul optimizer promises to only use the memory range ``[size, ptr)`` for its purposes. +If the optimizer does not need to reserve any memory, it holds that ``ptr == size``. ``memoryguard`` can be called multiple times, but needs to have the same literal as argument within one Yul subobject. If at least one ``memoryguard`` call is found in a subobject, -the Yul optimiser will try to perform experimental steps like the stack limit evader, -which attempts to move stack variables that would otherwise be unreachable -to memory. +the additional optimiser steps will be run on it. + .. _yul-object: