This commit is contained in:
Nilstrieb 2022-07-22 14:19:24 +00:00
parent df08ff65e1
commit be75277094
5 changed files with 11 additions and 11 deletions

View file

@ -51,7 +51,7 @@ reveals the solution: (severely shortened to only show the relevant parts)</p
<pre tabindex="0"><code class="language-llvmir" data-lang="llvmir">define void @takes_box_and_ptr_to_it(i8* noalias %0, i8* %ptr) {
</code></pre><p>See the little attribute on the first parameter called <code>noalias</code>? That’s what’s doing the magic here.
<code>noalias</code> is an LLVM attribute on pointers that allows for various optimizations. If there are two pointers,
and at least one of them is <code>noalias</code>, there are some restrictions around the two:</p>
and at least one of them is <code>noalias</code>, there are some restrictions around the two. Approximately:</p>
<ul>
<li>If one of them writes, they must not point to the same value (alias each other)</li>
<li>If neither of them writes, they can alias just fine.
@ -66,7 +66,7 @@ belong to the arcane circles of the select few who were aware of it. So lots of
RAII pointer” (a pointer that allocates the value in the constructor, and deallocates it in the destructor on drop) for all
pointers are concerned.</p>
<h1 id="stacked-borrows-and-miri">Stacked Borrows and Miri</h1>
<p><a href="https://github.com/rust-lang/miri">Miri</a> is an interpreter for Rust code with the goal of finding undefinde behaviour.
<p><a href="https://github.com/rust-lang/miri">Miri</a> is an interpreter for Rust code with the goal of finding undefined behaviour.
Undefined behaviour, UB for short, is behaviour of a program upon which no restrictions are imposed. If UB is executed,
<em>anything</em> can happen, including segmentation faults, silent memory corruption, leakage of private keys or exactly
what you intended to happen. Examples of UB include use-after-free, out of bounds reads or data races.</p>