[llvm-dev] RFC: Strong GC References in LLVM

Andrew Trick via llvm-dev llvm-dev at lists.llvm.org
Tue Jul 12 17:19:07 PDT 2016


> On Jul 12, 2016, at 4:42 PM, Sanjoy Das <sanjoy at playingwithpointers.com> wrote:
> 
> Hi Andy,
> 
> Andrew Trick wrote:
> >
> > I don’t remember why this is important. I often don't know with
> > InstCombine whether something is needed to expose IR optimization or an
> > ISEL pattern (which should really be somehow denoted and only run in a
> > later pass).
> 
> But for the purposes of this discussion, only the legality (or lack
> thereof) of the above transform matters, not whether it is profitable
> or not.

Given that you will need to disable the transform for GCRefs, it’s interesting that if it’s only something that needs to run before ISEL then you’re not actually losing any optimization.

> 
> > If you can come up with an IR design for tracking your GCRef load
> > depedencies (usually on specific null and type checks), then that could
> 
> That sounds orthogonal to this proposal -- as a starting point we need
> a simple way to mark a GCRef load as control dependent on every
> condition executed since the start of the program.  Something like
> cast-to-dereferenceable can possibly be added once we start
> upstreaming analyses that prove that a GCRef load is safe to
> speculate, but that's for better performance not correctness.

I thought your frontend would know which conditions guard each field access.

> Having said that, I'll keep the "explicit control dependence" idea in
> mind -- maybe there is way to find "a simple way to mark a GCRef load
> as control dependent on every condition executed since the start of
> the program" that can be generalized to remember more precise control
> dependence later.

I only suggested it at this point because you mentioned how much work implementing optimizations on a gc_load intrinsic would be, and that time could otherwise be directed to a general LLVM improvement.

If it’s reasonable to prohibit speculation on normal loads where the loaded value happens to be a GCRef, then of course that’s easiest.

-Andy


More information about the llvm-dev mailing list