<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p>Hi, thanks for the report, I'll take a look.<br>
    </p>
    <pre class="moz-signature" cols="72">-------------
Best regards,
Alexey Bataev</pre>
    <div class="moz-cite-prefix">06.03.2018 4:25, Raúl Peñacoba via
      cfe-dev пишет:<br>
    </div>
    <blockquote type="cite"
      cite="mid:%3C8c87489c-07b9-25bc-0b3b-66d9d295bf8f@bsc.es%3E">Hi,
      <br>
      <br>
      I've noticed that clang does not work properly when using task
      reductions with non-constant arrays and/or classes with omp_orig
      constructor initializers.
      <br>
      <br>
      As reduction initialize/combine/finalize functions only receive
      references to whatever should be initialized, combined..., clang
      generates some additional storages to save the size of the
      reduction array and a pointer to the omp_orig. That storages are
      generated through __kmpc_thread_private_cached() calls in both
      reduction functions and outline task function.
      <br>
      <br>
      The problem is that the storage used in outline task function does
      not match the storage in reduction functions. This happens in
      programs that have a task reduction or a taskloop reduction with
      the in_reduction clause.
      <br>
      <br>
      To solve this i made an ugly patch that reuses the SourceLocation
      of CodeGenFunction::EmitOMPTaskgroupDirective() in
      CodeGenFunction::EmitOMPTaskBasedDirective() to match the storages
      and make it work. Anyway, i suppose that there is a better way to
      fix this.
      <br>
      <br>
      Index: CGStmtOpenMP.cpp
      <br>
===================================================================
      <br>
      --- CGStmtOpenMP.cpp    (revision 326685)
      <br>
      +++ CGStmtOpenMP.cpp    (working copy)
      <br>
      @@ -2713,6 +2713,8 @@
      <br>
                                        emitEmptyBoundParameters);
      <br>
       }
      <br>
      <br>
      +static SourceLocation reductionLoc;
      <br>
      +
      <br>
       void CodeGenFunction::EmitOMPTaskBasedDirective(
      <br>
           const OMPExecutableDirective &S, const
      OpenMPDirectiveKind CapturedRegion,
      <br>
           const RegionCodeGenTy &BodyGen, const TaskGenTy
      &TaskGen,
      <br>
      @@ -2952,7 +2954,7 @@
      <br>
               // FIXME: This must removed once the runtime library is
      fixed.
      <br>
               // Emit required threadprivate variables for
      <br>
               // initilizer/combiner/finalizer.
      <br>
      -        CGF.CGM.getOpenMPRuntime().emitTaskReductionFixups(CGF,
      S.getLocStart(),
      <br>
      +        CGF.CGM.getOpenMPRuntime().emitTaskReductionFixups(CGF,
      reductionLoc,
      <br>
      RedCG, Cnt);
      <br>
             }
      <br>
           }
      <br>
      @@ -3180,8 +3182,9 @@
      <br>
                 std::advance(IRHS, 1);
      <br>
               }
      <br>
             }
      <br>
      +      reductionLoc = S.getLocStart();
      <br>
             llvm::Value *ReductionDesc =
      <br>
      -          CGF.CGM.getOpenMPRuntime().emitTaskReductionInit(CGF,
      S.getLocStart(),
      <br>
      +          CGF.CGM.getOpenMPRuntime().emitTaskReductionInit(CGF,
      reductionLoc,
      <br>
      LHSs, RHSs, Data);
      <br>
             const auto *VD =
      cast<VarDecl>(cast<DeclRefExpr>(E)->getDecl());
      <br>
             CGF.EmitVarDecl(*VD);
      <br>
      <br>
      Regards,
      <br>
      <br>
      Raúl
      <br>
      <br>
      <br>
      <a class="moz-txt-link-freetext" href="http://bsc.es/disclaimer">http://bsc.es/disclaimer</a>
      <br>
      <br>
    </blockquote>
    <br>
  </body>
</html>