Refactor configurable constants in IR.
- Dominant language
- Rust
- Stars
- 61.4k
- Forks
- 5.4k
- Avg merge
- 3h 33m
- Merged PRs (30d)
- 4
Description
Currently the configurable constants are treated as regular consts in IR, and are post processed to find their address in the data section during ASMgen. While implementing the `constdemotion` pass in #4336 I accidentally, but very easily, corrupted their use by copying their values to the stack when they required demotion.
This broke the ASMgen post processing as it appeared that they were no longer used, and were essentially DCE'd.
Configurable constants should instead be treated as volatile memory regions rather than constants. They _must_ always be backed by memory and _must_ never be copied or combined as constant optimisers are wont to do.
They should have an instruction like `get_cfg`, which behaves much like `get_local` in that it represents a typed memory region and always returns a `Pointer`. #4336 had to add some hacks to mimic this behaviour, of making a constant value actually have a pointer type.
Placing them in a global memory manager as proposed by #4351 makes the most sense. But refactoring them out of being `Value`s is non-trivial, as they are used by the `const_eval` module in `sway-core` as such quite extensively.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.