FuelLabs / sway

🌴 Empowering everyone to build reliable and efficient smart contracts.

Home Page:https://fuellabs.github.io/sway

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Check for usages of incomplete referred symbols in IR optimizations

ironcev opened this issue · comments

#5923 introduces in memory_utils an explicit ReferredSymbols enum that provides the information if symbols reachable from a certain value are deterministically completely identifiable, means all of the referred symbols can be identified, or if there might be symbols that are reachable from the value, but that cannot be confirmed based on the level of the analysis we currently have in IR.

Introduction of this distinction immediately pointed out to the parts of IR optimizations that currently do not check if there might be referred symbols beside those returned via e.g. escape analysis.

#5923 puts ReferredSymbols to use in DCE optimization, but otherwise not. Other optimizations, and the escape analysis are provided via "ignorant" ReferredSymbols::any() method that unsafely ignores potentially non-identified referred symbols.

The goal of this issue is:

  • to track the usages of ReferredSymbols::any() and on the case by case basis decide what to do in case of incompletely identified referred symbols.
  • decide how the similar information will be provided from the escape analysis (which internally uses ReferredSymbols) to the clients of the EscapedSymbols. The proposal is here to make EscapedSymbols and enum in the same way as the ReferredSymbols.
  • check for the attempts of identifying escaped symbols that do note use the memory_utils::compute_escaped_symbols.
  • remove collecting raw pointer and reference locals when collecting referred symbols. They are just intermediates and should not be collected as referred symbols.

The relevant parts of the code are marked with TODO comment and linked to this issue.