From dcec2ac4f353c3813f45392dbd0b4d3c5ee66e06 Mon Sep 17 00:00:00 2001 From: Alexey Bataev Date: Tue, 5 Nov 2019 15:33:18 -0500 Subject: [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. --- clang/lib/CodeGen/CGOpenMPRuntime.cpp | 38 +---------------------------------- 1 file changed, 1 insertion(+), 37 deletions(-) (limited to 'clang/lib/CodeGen/CGOpenMPRuntime.cpp') 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 checkContextEvaluateKnownConstInt(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 { -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()) { -- cgit v1.2.3