Commit 08ae2b71 authored by Hans Wennborg's avatar Hans Wennborg
Browse files

Merging r243277, r243280, r243285, and r243289

------------------------------------------------------------------------
r243277 | sfantao | 2015-07-27 09:38:06 -0700 (Mon, 27 Jul 2015) | 4 lines

[OpenMP] Add capture for threadprivate variables used in copyin clause
if TLS is enabled in OpenMP code generation. 
------------------------------------------------------------------------

------------------------------------------------------------------------
r243280 | sfantao | 2015-07-27 09:59:45 -0700 (Mon, 27 Jul 2015) | 4 lines

[OpenMP] Add TLS requirement for the copyin clause codegen test. This is an
attempt to fix regressions triggered by r243277.
------------------------------------------------------------------------

------------------------------------------------------------------------
r243285 | sfantao | 2015-07-27 10:30:41 -0700 (Mon, 27 Jul 2015) | 2 lines

[OpenMP] Fix copyin clause codegen regression caused by r243277. 
------------------------------------------------------------------------

------------------------------------------------------------------------
r243289 | sfantao | 2015-07-27 10:49:18 -0700 (Mon, 27 Jul 2015) | 3 lines

[OpenMP] Fix copyin codegen test regression in order used in compare
instruction. 
------------------------------------------------------------------------

llvm-svn: 243443
parent 649bfe3d
Loading
Loading
Loading
Loading
+16 −4
Original line number Diff line number Diff line
@@ -227,10 +227,22 @@ bool CodeGenFunction::EmitOMPCopyinClause(const OMPExecutableDirective &D) {
      auto *VD = cast<VarDecl>(cast<DeclRefExpr>(*IRef)->getDecl());
      QualType Type = VD->getType();
      if (CopiedVars.insert(VD->getCanonicalDecl()).second) {
        // Get the address of the master variable.
        auto *MasterAddr = VD->isStaticLocal()
                               ? CGM.getStaticLocalDeclAddress(VD)

        // Get the address of the master variable. If we are emitting code with
        // TLS support, the address is passed from the master as field in the
        // captured declaration.
        llvm::Value *MasterAddr;
        if (getLangOpts().OpenMPUseTLS &&
            getContext().getTargetInfo().isTLSSupported()) {
          assert(CapturedStmtInfo->lookup(VD) &&
                 "Copyin threadprivates should have been captured!");
          DeclRefExpr DRE(const_cast<VarDecl *>(VD), true, (*IRef)->getType(),
                          VK_LValue, (*IRef)->getExprLoc());
          MasterAddr = EmitLValue(&DRE).getAddress();
        } else {
          MasterAddr = VD->isStaticLocal() ? CGM.getStaticLocalDeclAddress(VD)
                                           : CGM.GetAddrOfGlobal(VD);
        }
        // Get the address of the threadprivate variable.
        auto *PrivateAddr = EmitLValue(*IRef).getAddress();
        if (CopiedVars.size() == 1) {
+14 −3
Original line number Diff line number Diff line
@@ -120,6 +120,7 @@ private:
  /// from current directive.
  OpenMPClauseKind ClauseKindMode;
  Sema &SemaRef;
  bool ForceCapturing;

  typedef SmallVector<SharingMapTy, 8>::reverse_iterator reverse_iterator;

@@ -130,11 +131,15 @@ private:

public:
  explicit DSAStackTy(Sema &S)
      : Stack(1), ClauseKindMode(OMPC_unknown), SemaRef(S) {}
      : Stack(1), ClauseKindMode(OMPC_unknown), SemaRef(S),
        ForceCapturing(false) {}

  bool isClauseParsingMode() const { return ClauseKindMode != OMPC_unknown; }
  void setClauseParsingMode(OpenMPClauseKind K) { ClauseKindMode = K; }

  bool isForceVarCapturing() const { return ForceCapturing; }
  void setForceVarCapturing(bool V) { ForceCapturing = V; }

  void push(OpenMPDirectiveKind DKind, const DeclarationNameInfo &DirName,
            Scope *CurScope, SourceLocation Loc) {
    Stack.push_back(SharingMapTy(DKind, DirName, CurScope, Loc));
@@ -655,7 +660,8 @@ bool Sema::IsOpenMPCapturedVar(VarDecl *VD) {
  if (DSAStack->getCurrentDirective() != OMPD_unknown) {
    if (DSAStack->isLoopControlVariable(VD) ||
        (VD->hasLocalStorage() &&
         isParallelOrTaskRegion(DSAStack->getCurrentDirective())))
         isParallelOrTaskRegion(DSAStack->getCurrentDirective())) ||
        DSAStack->isForceVarCapturing())
      return true;
    auto DVarPrivate = DSAStack->getTopDSA(VD, DSAStack->isClauseParsingMode());
    if (DVarPrivate.CKind != OMPC_unknown && isOpenMPPrivate(DVarPrivate.CKind))
@@ -1350,13 +1356,18 @@ StmtResult Sema::ActOnOpenMPRegionEnd(StmtResult S,
  // This is required for proper codegen.
  for (auto *Clause : Clauses) {
    if (isOpenMPPrivate(Clause->getClauseKind()) ||
        Clause->getClauseKind() == OMPC_copyprivate) {
        Clause->getClauseKind() == OMPC_copyprivate ||
        (getLangOpts().OpenMPUseTLS &&
         getASTContext().getTargetInfo().isTLSSupported() &&
         Clause->getClauseKind() == OMPC_copyin)) {
      DSAStack->setForceVarCapturing(Clause->getClauseKind() == OMPC_copyin);
      // Mark all variables in private list clauses as used in inner region.
      for (auto *VarRef : Clause->children()) {
        if (auto *E = cast_or_null<Expr>(VarRef)) {
          MarkDeclarationsReferencedInExpr(E);
        }
      }
      DSAStack->setForceVarCapturing(/*V=*/false);
    } else if (isParallelOrTaskRegion(DSAStack->getCurrentDirective()) &&
               Clause->getClauseKind() == OMPC_schedule) {
      // Mark all variables in private list clauses as used in inner region.
+257 −2

File changed.

Preview size limit exceeded, changes collapsed.