[llvm-dev] invariant.load metadata semantics

Sanjoy Das via llvm-dev llvm-dev at lists.llvm.org
Mon Aug 29 16:27:26 PDT 2016


Hi Justin,

Justin Lebar wrote:
 >  > Yes, if you define "same pointer" as "pointers with the same bitwise
 > representation".
 >
 > Yes, this is the definition I was interested in, under the assumption
 > that it's the definition LLVM uses. But it sounds like you've augmented
 > LLVM so that bitwise-identical pointer values are not considered equal
 > if they come from different allocations.

I may be misunderstanding you, but what you said above sounds
misleading.  It isn't that we do some extra magic at the equality
level, the magic we do is at the _allocation_ level.  The right mental
picture is that we have a malloc that (magically) never runs out of
memory, and our programs cannot explicitly call free or realloc on
memory (so every allocation _is_, in fact, distinct).  This is not
specific to GC'ed environments -- you could do the same thing in C++
too, by adding (say) a programmer-level invariant (don't check in code
that calls delete on class X, all instances of X live forever etc.).

As an "optimization"[0] on top of that (this is the magic bit) we
figure out which allocations are unnecessary from the program's point
of view, and throw them away.

Did that make sense?

-- Sanjoy

[0]: I'm being somewhat flippant here, this "optimization" is
   basically the whole of the GC. :)


More information about the llvm-dev mailing list