alexcrichton transferred Issue #589:
What if we added
heap_load
andheap_store
instructions, which would roughly be legalized intoheap_addr
+load
andheap_addr
+store
. That way, frontends could produce Cranelift IR without themselves dealing with plainload
andstore
, which would eliminate the possibility of misusing them and facing undefined behavior.The next step would be to add a wasm-like indirect call instruction, possibly named
table_call
. This would be more complex because we don't yet have a builtin way to legalize this that includes signature checking, but it's doable.Then, it's plausible to imagine defining an IR subset which is completely safe, yet still reasonably complete. We could then clearly document unsafe constructs like
load
andstore
as such, possibly with an optional verifier pass that could enforce that no unsafe constructs are present, and make it easy for people to generate IR without having to worry about undefined behavior.
Last updated: Dec 23 2024 at 13:07 UTC