summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/CodeGen/CGOpenMPRuntime.cpp38
-rw-r--r--clang/lib/Parse/ParseOpenMP.cpp7
-rw-r--r--clang/lib/Sema/SemaOpenMP.cpp6
3 files changed, 5 insertions, 46 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>()) {
diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp
index 816e8882510..e59b83dd999 100644
--- a/clang/lib/Parse/ParseOpenMP.cpp
+++ b/clang/lib/Parse/ParseOpenMP.cpp
@@ -800,13 +800,8 @@ static ExprResult parseContextScore(Parser &P) {
SmallString<16> Buffer;
StringRef SelectorName =
P.getPreprocessor().getSpelling(P.getCurToken(), Buffer);
- OMPDeclareVariantAttr::ScoreType ScoreKind =
- OMPDeclareVariantAttr::ScoreUnknown;
- (void)OMPDeclareVariantAttr::ConvertStrToScoreType(SelectorName, ScoreKind);
- if (ScoreKind == OMPDeclareVariantAttr::ScoreUnknown)
+ if (!SelectorName.equals("score"))
return ScoreExpr;
- assert(ScoreKind == OMPDeclareVariantAttr::ScoreSpecified &&
- "Expected \"score\" clause.");
(void)P.ConsumeToken();
SourceLocation RLoc;
ScoreExpr = P.ParseOpenMPParensExpr(SelectorName, RLoc);
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 9055eff872a..7ed582f8446 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -5197,9 +5197,7 @@ void Sema::ActOnOpenMPDeclareVariantDirective(
Data.Ctx == OMPDeclareVariantAttr::CtxUnknown)
return;
Expr *Score = nullptr;
- OMPDeclareVariantAttr::ScoreType ST = OMPDeclareVariantAttr::ScoreUnknown;
if (Data.CtxScore.isUsable()) {
- ST = OMPDeclareVariantAttr::ScoreSpecified;
Score = Data.CtxScore.get();
if (!Score->isTypeDependent() && !Score->isValueDependent() &&
!Score->isInstantiationDependent() &&
@@ -5209,9 +5207,11 @@ void Sema::ActOnOpenMPDeclareVariantDirective(
if (ICE.isInvalid())
return;
}
+ } else {
+ Score = ActOnIntegerConstant(SourceLocation(), 0).get();
}
auto *NewAttr = OMPDeclareVariantAttr::CreateImplicit(
- Context, VariantRef, Score, Data.CtxSet, ST, Data.Ctx,
+ Context, VariantRef, Score, Data.CtxSet, Data.Ctx,
Data.ImplVendors.begin(), Data.ImplVendors.size(), SR);
FD->addAttr(NewAttr);
}
OpenPOWER on IntegriCloud