[PATCH] D16749: [OpenMP] Map clause codegeneration.

Samuel Antao via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 17 14:18:36 PDT 2016


sfantao added a comment.

Hi Alexey,

I am afraid I don't understand  what you are trying to accomplish with this. I was unable to compile your patch as is, I think what you intended is something like this:

  // If we are mapping a field of 'this' we attempt to generate a
  // OMPCapturedExprDecl for it. The logic above, already ensures that if we
  // map a member expression its base is 'this'.
  Expr *VarsExpr = RE->IgnoreParens();
  if (isa<MemberExpr>(BE)) {
    DeclRefExpr *Ref;
    VarsExpr = Ref = buildCapture(*this, D, BE, /*WithInit=*/true);
    if (!IsOpenMPCapturedDecl(D))
      ExprCaptures.push_back(Ref->getDecl());
  }

However, I am not sure how this helps in this case. The map clause will have expressions that refer to the dummy declaration, but the region captured arguments are unchanged, so we still get 'this' and the content of the map clause has to relate to that.

Say we have some user code like this:

  struct S {
    int A;
    foo() { ++ A; }
    bar() {
      #pragma target map(A)
      {
        ++A;
        foo()
      }
  }

The kernel argument is going to be `this` regardless the map clause. The map clause only makes sure that a section of `this` is copied and not everything, so I rather not separate the field from the rest (for the same reason we do not separate the array declaration from a subscript or section). `this` still has to be passed to foo().

Is it your goal to pass arguments to the outlined region individually? I don't think your code was trying to do that, am I wrong? Even if we manage to change the captures so that fields are passed individually, `this` would have to be rematerialized inside `bar()`.

Am I missing something?

Thanks!
Samuel


http://reviews.llvm.org/D16749





More information about the cfe-commits mailing list