[llvm-dev] Memory scope proposal

Sanjoy Das via llvm-dev llvm-dev at lists.llvm.org
Tue Aug 30 18:56:08 PDT 2016


Hi,

Sanjoy Das wrote:
 > I understand why a straightforward metadata scheme won't work here,
 > but have you considered an alternate scheme that works in the
 > following way:
 >
 > - We add a MD node called !nosynch that lists a set of "domains" a
 > certain memory operation does *not* synchronize with.
 >
 > - Memory operations with !nosynch synchronize with memory operations
 > without any !nosynch metadata (so dropping !nosynch is safe).

I missed a spot here ^, !nosynch metadata will also have to have a
sub-node for the kind of synch-domain *it* is in.  The synchs-with
relation is then:

bool SynchsWith(MemOp A, MemOp B) {
   MD_A = A.getMD(MD_nosynch);
   MD_B = B.getMD(MD_nosynch);
   if (!MD_A || !MD_B)
     return true;
   return MD_B.nosync_list.contains(MD_A.id) || 
MD_A.nosync_list.contains(MD_B.id);
}

I'm still not a 100% convinced that the above works, but I think there
are advantages to expressing synch scopes as metadata.  For instance,
the optimizer already "knows" what to do with the metadata on loads it
speculates.

-- Sanjoy


More information about the llvm-dev mailing list