-
Notifications
You must be signed in to change notification settings - Fork 13.3k
[Clang] [OpenMP] Support NOWAIT with optional argument #128742
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
fa3dd14
0235029
83efa58
06060ee
84d2eb7
7683f02
6c87483
f2de356
2185111
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -305,6 +305,16 @@ OMPClause::child_range OMPIfClause::used_children() { | |
return child_range(&Condition, &Condition + 1); | ||
} | ||
|
||
/*OMPClause::child_range OMPNowaitClause::used_children() { | ||
return child_range(&Condition, &Condition + 1); | ||
}*/ | ||
OMPClause::child_range OMPNowaitClause::used_children() { | ||
if (Condition) | ||
return child_range(&Condition, &Condition + 1); | ||
Stmt *Null = nullptr; | ||
return child_range(&Null, &Null); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. isn't this returning pointer to temporary? I'm unfamiliar with |
||
} | ||
|
||
OMPClause::child_range OMPGrainsizeClause::used_children() { | ||
if (Stmt **C = getAddrOfExprAsWritten(getPreInitStmt())) | ||
return child_range(C, C + 1); | ||
|
@@ -1995,8 +2005,13 @@ void OMPClausePrinter::VisitOMPOrderedClause(OMPOrderedClause *Node) { | |
} | ||
} | ||
|
||
void OMPClausePrinter::VisitOMPNowaitClause(OMPNowaitClause *) { | ||
void OMPClausePrinter::VisitOMPNowaitClause(OMPNowaitClause *Node) { | ||
OS << "nowait"; | ||
if (auto *Cond = Node->getCondition()) { | ||
OS << "("; | ||
Cond->printPretty(OS, nullptr, Policy, 0); | ||
OS << ")"; | ||
} | ||
} | ||
|
||
void OMPClausePrinter::VisitOMPUntiedClause(OMPUntiedClause *) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15446,6 +15446,9 @@ OMPClause *SemaOpenMP::ActOnOpenMPSingleExprClause(OpenMPClauseKind Kind, | |
case OMPC_ordered: | ||
Res = ActOnOpenMPOrderedClause(StartLoc, EndLoc, LParenLoc, Expr); | ||
break; | ||
case OMPC_nowait: | ||
Res = ActOnOpenMPNowaitClause(StartLoc, EndLoc, LParenLoc, Expr); | ||
break; | ||
case OMPC_priority: | ||
Res = ActOnOpenMPPriorityClause(Expr, StartLoc, LParenLoc, EndLoc); | ||
break; | ||
|
@@ -15500,7 +15503,6 @@ OMPClause *SemaOpenMP::ActOnOpenMPSingleExprClause(OpenMPClauseKind Kind, | |
case OMPC_aligned: | ||
case OMPC_copyin: | ||
case OMPC_copyprivate: | ||
case OMPC_nowait: | ||
case OMPC_untied: | ||
case OMPC_mergeable: | ||
case OMPC_threadprivate: | ||
|
@@ -16959,9 +16961,32 @@ OMPClause *SemaOpenMP::ActOnOpenMPClause(OpenMPClauseKind Kind, | |
} | ||
|
||
OMPClause *SemaOpenMP::ActOnOpenMPNowaitClause(SourceLocation StartLoc, | ||
SourceLocation EndLoc) { | ||
SourceLocation EndLoc, | ||
SourceLocation LParenLoc, | ||
Expr *Condition) { | ||
Expr *ValExpr = Condition; | ||
if (Condition && LParenLoc.isValid()) { | ||
if (!Condition->isValueDependent() && !Condition->isTypeDependent() && | ||
!Condition->isInstantiationDependent() && | ||
!Condition->containsUnexpandedParameterPack()) { | ||
ExprResult Val = SemaRef.CheckBooleanCondition(StartLoc, Condition); | ||
if (Val.isInvalid()) | ||
return nullptr; | ||
Comment on lines
+16972
to
+16974
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this the error case? Is a Diag issued in |
||
|
||
QualType T = ValExpr->getType(); | ||
if (T->isFloatingType()) { | ||
SemaRef.Diag(ValExpr->getExprLoc(), diag::err_omp_clause_floating_type_arg) | ||
<< getOpenMPClauseName(OMPC_nowait); | ||
} | ||
|
||
ValExpr = Val.get(); | ||
} | ||
} else { | ||
ValExpr = nullptr; | ||
} | ||
DSAStack->setNowaitRegion(); | ||
return new (getASTContext()) OMPNowaitClause(StartLoc, EndLoc); | ||
return new (getASTContext()) | ||
OMPNowaitClause(ValExpr, StartLoc, LParenLoc, EndLoc); | ||
} | ||
|
||
OMPClause *SemaOpenMP::ActOnOpenMPUntiedClause(SourceLocation StartLoc, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Check no warnings/errors | ||
// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=60 -fsyntax-only -verify %s | ||
// expected-no-diagnostics | ||
|
||
// Check AST and unparsing | ||
// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=60 -ast-dump %s | FileCheck %s --check-prefix=DUMP | ||
// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=60 -ast-print %s | FileCheck %s --check-prefix=PRINT | ||
|
||
// Check same results after serialization round-trip | ||
// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=60 -emit-pch -o %t %s | ||
// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=60 -include-pch %t -ast-dump-all %s | FileCheck %s --check-prefix=DUMP | ||
// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=60 -include-pch %t -ast-print %s | FileCheck %s --check-prefix=PRINT | ||
|
||
#ifndef HEADER | ||
#define HEADER | ||
|
||
void nowait() { | ||
int A=1; | ||
|
||
// DUMP: OMPTargetDirective | ||
// DUMP-NEXT: OMPNowaitClause | ||
// DUMP-NEXT: <<<NULL>>> | ||
// PRINT: #pragma omp target nowait | ||
#pragma omp target nowait | ||
{ | ||
} | ||
|
||
// DUMP: OMPTargetDirective | ||
// DUMP-NEXT: OMPNowaitClause | ||
// DUMP-NEXT: XXBoolLiteralExpr {{.*}} 'bool' false | ||
// PRINT: #pragma omp target nowait(false) | ||
#pragma omp target nowait(false) | ||
{ | ||
} | ||
|
||
// DUMP: OMPTargetDirective | ||
// DUMP-NEXT: OMPNowaitClause | ||
// DUMP-NEXT: XXBoolLiteralExpr {{.*}} 'bool' true | ||
// PRINT: #pragma omp target nowait(true) | ||
#pragma omp target nowait(true) | ||
{ | ||
} | ||
|
||
// DUMP: OMPTargetDirective | ||
// DUMP-NEXT: OMPNowaitClause | ||
// DUMP-NEXT: BinaryOperator {{.*}} 'bool' '>' | ||
// DUMP-NEXT: ImplicitCastExpr {{.*}} 'int' <LValueToRValue> | ||
// DUMP-NEXT: DeclRefExpr {{.*}} 'int' lvalue Var {{.*}} 'A' 'int' | ||
// DUMP-NEXT: IntegerLiteral {{.*}} 'int' 5 | ||
// PRINT: #pragma omp target nowait(A > 5) | ||
#pragma omp target nowait(A>5) | ||
{ | ||
} | ||
|
||
} | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.