diff options
author | Alexey Bataev <a.bataev@hotmail.com> | 2019-11-05 15:33:18 -0500 |
---|---|---|
committer | Alexey Bataev <a.bataev@hotmail.com> | 2019-11-05 15:59:22 -0500 |
commit | dcec2ac4f353c3813f45392dbd0b4d3c5ee66e06 (patch) | |
tree | 61c9ea33edbb83d74d255f172574f82d38a3c1b4 /clang/lib/CodeGen/CGOpenMPRuntime.cpp | |
parent | a078c77d72082bf6a06486849735cdeaab1374bc (diff) | |
download | bcm5719-llvm-dcec2ac4f353c3813f45392dbd0b4d3c5ee66e06.tar.gz bcm5719-llvm-dcec2ac4f353c3813f45392dbd0b4d3c5ee66e06.zip |
[OPENMP50]Simplify processing of context selector scores.
If the context selector score was not specified, its value must be set
to 0. Simplify the processing of unspecified scores + save memory in
attribute representation.
Diffstat (limited to 'clang/lib/CodeGen/CGOpenMPRuntime.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGOpenMPRuntime.cpp | 38 |
1 files changed, 1 insertions, 37 deletions
diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp index 514457d9e4a..b48c52dbc1e 100644 --- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp +++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp @@ -11044,41 +11044,11 @@ bool checkContext<OMPDeclareVariantAttr::CtxSetImplementation, } static bool greaterCtxScore(ASTContext &Ctx, const Expr *LHS, const Expr *RHS) { - // If both scores are unknown, choose the very first one. - if (!LHS && !RHS) - return true; - // If only one is known, return this one. - if (LHS && !RHS) - return true; - if (!LHS && RHS) - return false; llvm::APSInt LHSVal = LHS->EvaluateKnownConstInt(Ctx); llvm::APSInt RHSVal = RHS->EvaluateKnownConstInt(Ctx); return llvm::APSInt::compareValues(LHSVal, RHSVal) >= 0; } -namespace { -/// Comparator for the priority queue for context selector. -class OMPDeclareVariantAttrComparer - : public std::greater<const OMPDeclareVariantAttr *> { -private: - ASTContext &Ctx; - -public: - OMPDeclareVariantAttrComparer(ASTContext &Ctx) : Ctx(Ctx) {} - bool operator()(const OMPDeclareVariantAttr *LHS, - const OMPDeclareVariantAttr *RHS) const { - const Expr *LHSExpr = nullptr; - const Expr *RHSExpr = nullptr; - if (LHS->getCtxScore() == OMPDeclareVariantAttr::ScoreSpecified) - LHSExpr = LHS->getScore(); - if (RHS->getCtxScore() == OMPDeclareVariantAttr::ScoreSpecified) - RHSExpr = RHS->getScore(); - return greaterCtxScore(Ctx, LHSExpr, RHSExpr); - } -}; -} // anonymous namespace - /// Finds the variant function that matches current context with its context /// selector. static const FunctionDecl *getDeclareVariantFunction(ASTContext &Ctx, @@ -11088,13 +11058,7 @@ static const FunctionDecl *getDeclareVariantFunction(ASTContext &Ctx, // Iterate through all DeclareVariant attributes and check context selectors. auto &&Comparer = [&Ctx](const OMPDeclareVariantAttr *LHS, const OMPDeclareVariantAttr *RHS) { - const Expr *LHSExpr = nullptr; - const Expr *RHSExpr = nullptr; - if (LHS->getCtxScore() == OMPDeclareVariantAttr::ScoreSpecified) - LHSExpr = LHS->getScore(); - if (RHS->getCtxScore() == OMPDeclareVariantAttr::ScoreSpecified) - RHSExpr = RHS->getScore(); - return greaterCtxScore(Ctx, LHSExpr, RHSExpr); + return greaterCtxScore(Ctx, LHS->getScore(), RHS->getScore()); }; const OMPDeclareVariantAttr *TopMostAttr = nullptr; for (const auto *A : FD->specific_attrs<OMPDeclareVariantAttr>()) { |