From 37c4b0f98ccccf6fc84847544789c15e1cdaeecf Mon Sep 17 00:00:00 2001 From: Dmitry Polukhin Date: Fri, 1 Apr 2016 09:52:30 +0000 Subject: [PATCH] [OPENMP] Avoid useless recursive calls in getDSA if it is called in a loop, NFC git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@265123 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaOpenMP.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/Sema/SemaOpenMP.cpp b/lib/Sema/SemaOpenMP.cpp index bb0a9caa7a..6458eee56c 100644 --- a/lib/Sema/SemaOpenMP.cpp +++ b/lib/Sema/SemaOpenMP.cpp @@ -141,7 +141,7 @@ private: typedef SmallVector::reverse_iterator reverse_iterator; - DSAVarData getDSA(StackTy::reverse_iterator Iter, ValueDecl *D); + DSAVarData getDSA(StackTy::reverse_iterator& Iter, ValueDecl *D); /// \brief Checks if the variable is a local for OpenMP region. bool isOpenMPLocal(VarDecl *D, StackTy::reverse_iterator Iter); @@ -396,7 +396,7 @@ static ValueDecl *getCanonicalDecl(ValueDecl *D) { return D; } -DSAStackTy::DSAVarData DSAStackTy::getDSA(StackTy::reverse_iterator Iter, +DSAStackTy::DSAVarData DSAStackTy::getDSA(StackTy::reverse_iterator& Iter, ValueDecl *D) { D = getCanonicalDecl(D); auto *VD = dyn_cast(D); @@ -505,7 +505,7 @@ DSAStackTy::DSAVarData DSAStackTy::getDSA(StackTy::reverse_iterator Iter, // For constructs other than task, if no default clause is present, these // variables inherit their data-sharing attributes from the enclosing // context. - return getDSA(std::next(Iter), D); + return getDSA(++Iter, D); } Expr *DSAStackTy::addUniqueAligned(ValueDecl *D, Expr *NewDE) { @@ -722,7 +722,7 @@ DSAStackTy::DSAVarData DSAStackTy::hasDSA(ValueDecl *D, ClausesPredicate CPred, bool FromParent) { D = getCanonicalDecl(D); auto StartI = std::next(Stack.rbegin()); - auto EndI = std::prev(Stack.rend()); + auto EndI = Stack.rend(); if (FromParent && StartI != EndI) { StartI = std::next(StartI); } @@ -742,7 +742,7 @@ DSAStackTy::hasInnermostDSA(ValueDecl *D, ClausesPredicate CPred, DirectivesPredicate DPred, bool FromParent) { D = getCanonicalDecl(D); auto StartI = std::next(Stack.rbegin()); - auto EndI = std::prev(Stack.rend()); + auto EndI = Stack.rend(); if (FromParent && StartI != EndI) { StartI = std::next(StartI); } -- 2.40.0