[LLVMdev] [RFC] Progress towards OpenMP support

Hal Finkel hfinkel at anl.gov
Thu Sep 13 14:06:38 PDT 2012

On Fri, 14 Sep 2012 02:09:17 +0530
Sanjoy Das <sanjoy at playingwithpointers.com> wrote:

> Hi Hal,
> > An alternative approach, which you seem to be proposing, is that the
> > parallelization reads the metadata up front (and then drops it
> > all). If a pass does not preserve that analysis, then it will be
> > invalidated, and the parallelization will be lost. This, indeed,
> > might be a better approach, but would at least require touching a
> > lot more code (if nothing else, we'd need to audit and then add the
> > analysis preservation calls to a lot of otherwise-unrelated code).
> I don't drop any metadata.

Yes, I'm saying that, using your approach, you *should* drop the
metadata. Essentially, once the parallelization information has been
moved from the metadata into the state held by the analysis pass, then
the original metadata should be dropped. This will prevent
stale and possibly-invalid metadata from being dumped from any later
stage in the pipeline.

Doing this should be easy: Create a module transformation pass to drop
the parallelization metadata. It should require and preserve the
parallelization analysis.

>  Let me put it this way: say we have a pass
> MakeConsistent which drops inconsistent MD nodes. We will also need
> some code in LLVM that parses the IR and converts it to a from that is
> more easily processed.  My proposal is to squash these two pieces of
> code (MakeConsistent and the "parser") into a single one.  The
> resulting code then doesn't need to mutate the metadata at all since
> it consumes the modified, normalized metadata as soon as it is
> "produced".  It could also make the MD consistent if it wanted to, but
> that would be redundant, since it is the only piece of code that
> directly reads the MD.

I understand; I'm just trying to make sure that at no stage do we end
up with inconsistent metadata (even if this is in debug dumps in
between passes).

Thanks again,

> https://github.com/sanjoy/llvm/blob/parallel-md/lib/Analysis/ParallelizationMetadata.cpp
> is basically an implementation of this "squashed" pass. It provides an
> interface to the MD and this interface normalizes the MD before
> exposing it.
> Thanks!

Hal Finkel
Postdoctoral Appointee
Leadership Computing Facility
Argonne National Laboratory

More information about the llvm-dev mailing list