Add documentation about the UB of the stack2reg optimization

This commit is contained in:
bjorn3 2020-01-04 11:31:56 +01:00
parent 196008bee3
commit 87d6953719

View File

@ -1,3 +1,14 @@
//! This optimization replaces stack accesses with SSA variables and removes dead stores when possible.
//!
//! # Undefined behaviour
//!
//! This optimization is based on the assumption that stack slots which don't have their address
//! leaked through `stack_addr` are only accessed using `stack_load` and `stack_store` in the
//! function which has the stack slots. This optimization also assumes that stack slot accesses
//! are never out of bounds. If these assumptions are not correct, then this optimization may remove
//! `stack_store` instruction incorrectly, or incorrectly use a previously stored value as the value
//! being loaded by a `stack_load`.
use std::collections::{BTreeMap, HashSet};
use std::ops::Not;