Could freeze
intrinsic in rustc
be implemented like this?
- insert a call to an extern function LLVM knows nothing about, say
rustFreeze(p)
wherep
is a pointer/ref - LLVM will now assume that memory could have been written through
p
- add an extra hand-crafted LLVM pass suitably late in the chain to remove all calls to
rustFreeze
This will not be a true freeze
because MADV_FREE
and friends can still cause the result of reading uninitialized memory to be unpredictable, LLVM undef
style. However at least LLVM will not compile the code to NOP or make any other nasty assumptions?