-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[CIR][OpenACC] Implement 'routine' lowering + seq clause #170207
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
25f2213
[CIR][OpenACC] Implement 'routine' lowering + seq clause
erichkeane 7f465e4
undo over-clang-formatting
erichkeane 993f340
add back reverted declaration
erichkeane 916741e
Add create overload to RoutineOp to 'set nothing'
erichkeane b309dbc
Fix build of tests by making them tolerant of the 'no-inline' markup
erichkeane File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,6 +12,7 @@ | |
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "clang/Sema/SemaOpenACC.h" | ||
| #include "clang/AST/ASTConsumer.h" | ||
| #include "clang/AST/DeclOpenACC.h" | ||
| #include "clang/AST/StmtOpenACC.h" | ||
| #include "clang/Basic/DiagnosticSema.h" | ||
|
|
@@ -2457,7 +2458,8 @@ OpenACCRoutineDecl *SemaOpenACC::CheckRoutineDecl( | |
| ArrayRef<const OpenACCClause *> Clauses, SourceLocation EndLoc) { | ||
| assert(LParenLoc.isValid()); | ||
|
|
||
| if (FunctionDecl *FD = getFunctionFromRoutineName(FuncRef)) { | ||
| FunctionDecl *FD = nullptr; | ||
| if ((FD = getFunctionFromRoutineName(FuncRef))) { | ||
| // OpenACC 3.3 2.15: | ||
| // In C and C++, function static variables are not supported in functions to | ||
| // which a routine directive applies. | ||
|
|
@@ -2509,11 +2511,9 @@ OpenACCRoutineDecl *SemaOpenACC::CheckRoutineDecl( | |
| {DirLoc, BindLoc}); | ||
| FD->addAttr(RAA); | ||
| // In case we are referencing not the 'latest' version, make sure we add | ||
| // the attribute to all declarations. | ||
| while (FD != FD->getMostRecentDecl()) { | ||
| FD = FD->getMostRecentDecl(); | ||
| FD->addAttr(RAA); | ||
| } | ||
| // the attribute to all declarations after the 'found' one. | ||
| for (auto *CurFD : FD->redecls()) | ||
|
Collaborator
Author
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. I have no idea what sort of nonsense I was trying at before. But this should do what I ACTUALLY meant to do. |
||
| CurFD->addAttr(RAA->clone(getASTContext())); | ||
| } | ||
|
|
||
| LastRoutineDecl = OpenACCRoutineDecl::Create( | ||
|
|
@@ -2522,9 +2522,20 @@ OpenACCRoutineDecl *SemaOpenACC::CheckRoutineDecl( | |
| LastRoutineDecl->setAccess(AS_public); | ||
| getCurContext()->addDecl(LastRoutineDecl); | ||
|
|
||
| if (FD) { | ||
| // Add this attribute to the list of annotations so that codegen can visit | ||
| // it later. FD doesn't necessarily exist, but that case should be | ||
| // diagnosed. | ||
| RoutineRefList.emplace_back(FD, LastRoutineDecl); | ||
| } | ||
| return LastRoutineDecl; | ||
| } | ||
|
|
||
| void SemaOpenACC::ActOnEndOfTranslationUnit(TranslationUnitDecl *TU) { | ||
| for (auto [FD, RoutineDecl] : RoutineRefList) | ||
| SemaRef.Consumer.HandleOpenACCRoutineReference(FD, RoutineDecl); | ||
| } | ||
|
|
||
| DeclGroupRef SemaOpenACC::ActOnEndRoutineDeclDirective( | ||
| SourceLocation StartLoc, SourceLocation DirLoc, SourceLocation LParenLoc, | ||
| Expr *ReferencedFunc, SourceLocation RParenLoc, | ||
|
|
||
6 changes: 0 additions & 6 deletions
6
clang/test/CIR/CodeGenOpenACC/openacc-not-implemented-global.cpp
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| // RUN: %clang_cc1 -fopenacc -Wno-openacc-self-if-potential-conflict -emit-cir -fclangir %s -o - | FileCheck %s | ||
|
|
||
| namespace { | ||
| #pragma acc routine seq | ||
| void NSFunc1(){} | ||
| #pragma acc routine seq | ||
| auto Lambda1 = [](){}; | ||
|
|
||
| auto Lambda2 = [](){}; | ||
| } // namespace | ||
|
|
||
| #pragma acc routine(NSFunc1) seq | ||
| #pragma acc routine(Lambda2) seq | ||
| void force_emit() { | ||
| NSFunc1(); | ||
| Lambda1(); | ||
| Lambda2(); | ||
| } | ||
|
|
||
| // CHECK: cir.func{{.*}} @[[F1_NAME:[^\(]*]]({{.*}}){{.*}} attributes {acc.routine_info = #acc.routine_info<[@[[F1_R_NAME:.*]], @[[F1_R2_NAME:.*]]]>} | ||
| // CHECK: cir.func {{.*}}lambda{{.*}} @[[L1_NAME:[^\(]*]]({{.*}}){{.*}} attributes {acc.routine_info = #acc.routine_info<[@[[L1_R_NAME:.*]]]>} | ||
| // CHECK: cir.func {{.*}}lambda{{.*}} @[[L2_NAME:[^\(]*]]({{.*}}){{.*}} attributes {acc.routine_info = #acc.routine_info<[@[[L2_R_NAME:.*]]]>} | ||
| // | ||
| // CHECK: acc.routine @[[F1_R_NAME]] func(@[[F1_NAME]]) seq | ||
| // CHECK: acc.routine @[[L1_R_NAME]] func(@[[L1_NAME]]) seq | ||
| // CHECK: acc.routine @[[F1_R2_NAME]] func(@[[F1_NAME]]) seq | ||
| // CHECK: acc.routine @[[L2_R_NAME]] func(@[[L2_NAME]]) seq |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| // RUN: %clang_cc1 -fopenacc -Wno-openacc-self-if-potential-conflict -emit-cir -fclangir %s -o - | FileCheck %s | ||
|
|
||
| #pragma acc routine seq | ||
| auto Lambda1 = [](){}; | ||
|
|
||
| auto Lambda2 = [](){}; | ||
| #pragma acc routine(Lambda2) seq | ||
| #pragma acc routine(Lambda2) seq | ||
|
|
||
| #pragma acc routine seq | ||
| int GlobalFunc1(); | ||
|
|
||
| int GlobalFunc2(); | ||
| #pragma acc routine(GlobalFunc2) seq | ||
| #pragma acc routine(GlobalFunc1) seq | ||
|
|
||
| void force_emit() { | ||
| Lambda1(); | ||
| Lambda2(); | ||
| GlobalFunc1(); | ||
| GlobalFunc2(); | ||
| } | ||
|
|
||
| // CHECK: cir.func {{.*}}lambda{{.*}} @[[L1_NAME:[^\(]*]]({{.*}}){{.*}} attributes {acc.routine_info = #acc.routine_info<[@[[L1_R_NAME:.*]]]>} | ||
| // CHECK: cir.func {{.*}}lambda{{.*}} @[[L2_NAME:[^\(]*]]({{.*}}){{.*}} attributes {acc.routine_info = #acc.routine_info<[@[[L2_R_NAME:.*]], @[[L2_R2_NAME:.*]]]>} | ||
| // | ||
| // CHECK: cir.func{{.*}} @[[G1_NAME:[^\(]*]]({{.*}}){{.*}} attributes {acc.routine_info = #acc.routine_info<[@[[G1_R_NAME:.*]], @[[G1_R2_NAME:.*]]]>} | ||
| // CHECK: cir.func{{.*}} @[[G2_NAME:[^\(]*]]({{.*}}){{.*}} attributes {acc.routine_info = #acc.routine_info<[@[[G2_R_NAME:.*]]]>} | ||
|
|
||
| // CHECK: acc.routine @[[L1_R_NAME]] func(@[[L1_NAME]]) seq | ||
| // CHECK: acc.routine @[[G1_R_NAME]] func(@[[G1_NAME]]) seq | ||
| // CHECK: acc.routine @[[L2_R_NAME]] func(@[[L2_NAME]]) seq | ||
| // CHECK: acc.routine @[[L2_R2_NAME]] func(@[[L2_NAME]]) seq | ||
| // CHECK: acc.routine @[[G2_R_NAME]] func(@[[G2_NAME]]) seq | ||
| // CHECK: acc.routine @[[G1_R2_NAME]] func(@[[G1_NAME]]) seq |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| // RUN: %clang_cc1 -fopenacc -Wno-openacc-self-if-potential-conflict -emit-cir -fclangir %s -o - | FileCheck %s | ||
|
|
||
| #pragma acc routine seq | ||
| void GlobalFunc4(); | ||
| #pragma acc routine(GlobalFunc4) seq | ||
|
|
||
| #pragma acc routine seq | ||
| #pragma acc routine seq | ||
| void GlobalFunc5(); | ||
| #pragma acc routine(GlobalFunc5) seq | ||
| #pragma acc routine(GlobalFunc5) seq | ||
|
|
||
| void GlobalFunc6(); | ||
| void GlobalFunc6(); | ||
| #pragma acc routine(GlobalFunc6) seq | ||
| void GlobalFunc6(){} | ||
|
|
||
| void GlobalFunc7(){} | ||
| #pragma acc routine(GlobalFunc7) seq | ||
|
|
||
| void force_emit() { | ||
| GlobalFunc4(); | ||
| GlobalFunc5(); | ||
| GlobalFunc6(); | ||
| GlobalFunc7(); | ||
| } | ||
|
|
||
| // CHECK: cir.func{{.*}} @[[G6_NAME:[^\(]*]]({{.*}}){{.*}} attributes {acc.routine_info = #acc.routine_info<[@[[G6_R_NAME:.*]]]>} | ||
| // CHECK: cir.func{{.*}} @[[G7_NAME:[^\(]*]]({{.*}}){{.*}} attributes {acc.routine_info = #acc.routine_info<[@[[G7_R_NAME:.*]]]>} | ||
|
|
||
| // CHECK: cir.func{{.*}} @[[G4_NAME:[^\(]*]]({{.*}}){{.*}} attributes {acc.routine_info = #acc.routine_info<[@[[G4_R_NAME:.*]], @[[G4_R2_NAME:.*]]]>} | ||
| // CHECK: cir.func{{.*}} @[[G5_NAME:[^\(]*]]({{.*}}){{.*}} attributes {acc.routine_info = #acc.routine_info<[@[[G5_R_NAME:.*]], @[[G5_R1_NAME:.*]], @[[G5_R2_NAME:.*]], @[[G5_R3_NAME:.*]]]>} | ||
|
|
||
| // CHECK: acc.routine @[[G4_R_NAME]] func(@[[G4_NAME]]) seq | ||
| // CHECK: acc.routine @[[G5_R_NAME]] func(@[[G5_NAME]]) seq | ||
| // CHECK: acc.routine @[[G5_R1_NAME]] func(@[[G5_NAME]]) seq | ||
| // | ||
| // CHECK: acc.routine @[[G4_R2_NAME]] func(@[[G4_NAME]]) seq | ||
| // | ||
| // CHECK: acc.routine @[[G5_R2_NAME]] func(@[[G5_NAME]]) seq | ||
| // CHECK: acc.routine @[[G5_R3_NAME]] func(@[[G5_NAME]]) seq | ||
| // | ||
| // CHECK: acc.routine @[[G6_R_NAME]] func(@[[G6_NAME]]) seq | ||
| // CHECK: acc.routine @[[G7_R_NAME]] func(@[[G7_NAME]]) seq |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
You're welcome to add it! :) Seems useful to me.
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.
Perhaps I'll do so! I'll have to see what infra is around to do that.