diff options
author | Alexey Bataev <a.bataev@hotmail.com> | 2015-09-15 12:52:43 +0000 |
---|---|---|
committer | Alexey Bataev <a.bataev@hotmail.com> | 2015-09-15 12:52:43 +0000 |
commit | 25e5b4465494ff106fec9b5623e9d74e6b242e79 (patch) | |
tree | b9e0e6b8773322f22b9c385b4e1c4783a5f95717 /clang/lib/Serialization | |
parent | 7d4038dc5a0a6095324d3f1462fc4402a8a6eac3 (diff) | |
download | bcm5719-llvm-25e5b4465494ff106fec9b5623e9d74e6b242e79.tar.gz bcm5719-llvm-25e5b4465494ff106fec9b5623e9d74e6b242e79.zip |
[OPENMP] Emit __kmpc_cancel_barrier() and code for 'cancellation point' only if 'cancel' is found.
Patch improves codegen for OpenMP constructs. If the OpenMP region does not have internal 'cancel' construct, a call to 'void __kmpc_barrier()' runtime function is generated for all implicit/explicit barriers. If the region has inner 'cancel' directive, then
```
if (__kmpc_cancel_barrier())
exit from outer construct;
```
code is generated.
Also, the code for 'canellation point' directive is not generated if parent directive does not have 'cancel' directive.
llvm-svn: 247681
Diffstat (limited to 'clang/lib/Serialization')
-rw-r--r-- | clang/lib/Serialization/ASTReaderStmt.cpp | 7 | ||||
-rw-r--r-- | clang/lib/Serialization/ASTWriterStmt.cpp | 7 |
2 files changed, 14 insertions, 0 deletions
diff --git a/clang/lib/Serialization/ASTReaderStmt.cpp b/clang/lib/Serialization/ASTReaderStmt.cpp index 9446db842f3..4501dd82b17 100644 --- a/clang/lib/Serialization/ASTReaderStmt.cpp +++ b/clang/lib/Serialization/ASTReaderStmt.cpp @@ -2167,6 +2167,7 @@ void ASTStmtReader::VisitOMPParallelDirective(OMPParallelDirective *D) { // The NumClauses field was read in ReadStmtFromStream. ++Idx; VisitOMPExecutableDirective(D); + D->setHasCancel(Record[Idx++]); } void ASTStmtReader::VisitOMPSimdDirective(OMPSimdDirective *D) { @@ -2175,6 +2176,7 @@ void ASTStmtReader::VisitOMPSimdDirective(OMPSimdDirective *D) { void ASTStmtReader::VisitOMPForDirective(OMPForDirective *D) { VisitOMPLoopDirective(D); + D->setHasCancel(Record[Idx++]); } void ASTStmtReader::VisitOMPForSimdDirective(OMPForSimdDirective *D) { @@ -2186,11 +2188,13 @@ void ASTStmtReader::VisitOMPSectionsDirective(OMPSectionsDirective *D) { // The NumClauses field was read in ReadStmtFromStream. ++Idx; VisitOMPExecutableDirective(D); + D->setHasCancel(Record[Idx++]); } void ASTStmtReader::VisitOMPSectionDirective(OMPSectionDirective *D) { VisitStmt(D); VisitOMPExecutableDirective(D); + D->setHasCancel(Record[Idx++]); } void ASTStmtReader::VisitOMPSingleDirective(OMPSingleDirective *D) { @@ -2213,6 +2217,7 @@ void ASTStmtReader::VisitOMPCriticalDirective(OMPCriticalDirective *D) { void ASTStmtReader::VisitOMPParallelForDirective(OMPParallelForDirective *D) { VisitOMPLoopDirective(D); + D->setHasCancel(Record[Idx++]); } void ASTStmtReader::VisitOMPParallelForSimdDirective( @@ -2226,6 +2231,7 @@ void ASTStmtReader::VisitOMPParallelSectionsDirective( // The NumClauses field was read in ReadStmtFromStream. ++Idx; VisitOMPExecutableDirective(D); + D->setHasCancel(Record[Idx++]); } void ASTStmtReader::VisitOMPTaskDirective(OMPTaskDirective *D) { @@ -2233,6 +2239,7 @@ void ASTStmtReader::VisitOMPTaskDirective(OMPTaskDirective *D) { // The NumClauses field was read in ReadStmtFromStream. ++Idx; VisitOMPExecutableDirective(D); + D->setHasCancel(Record[Idx++]); } void ASTStmtReader::VisitOMPTaskyieldDirective(OMPTaskyieldDirective *D) { diff --git a/clang/lib/Serialization/ASTWriterStmt.cpp b/clang/lib/Serialization/ASTWriterStmt.cpp index 7db73f5a53b..be1c69bf08b 100644 --- a/clang/lib/Serialization/ASTWriterStmt.cpp +++ b/clang/lib/Serialization/ASTWriterStmt.cpp @@ -2003,6 +2003,7 @@ void ASTStmtWriter::VisitOMPParallelDirective(OMPParallelDirective *D) { VisitStmt(D); Record.push_back(D->getNumClauses()); VisitOMPExecutableDirective(D); + Record.push_back(D->hasCancel() ? 1 : 0); Code = serialization::STMT_OMP_PARALLEL_DIRECTIVE; } @@ -2013,6 +2014,7 @@ void ASTStmtWriter::VisitOMPSimdDirective(OMPSimdDirective *D) { void ASTStmtWriter::VisitOMPForDirective(OMPForDirective *D) { VisitOMPLoopDirective(D); + Record.push_back(D->hasCancel() ? 1 : 0); Code = serialization::STMT_OMP_FOR_DIRECTIVE; } @@ -2025,12 +2027,14 @@ void ASTStmtWriter::VisitOMPSectionsDirective(OMPSectionsDirective *D) { VisitStmt(D); Record.push_back(D->getNumClauses()); VisitOMPExecutableDirective(D); + Record.push_back(D->hasCancel() ? 1 : 0); Code = serialization::STMT_OMP_SECTIONS_DIRECTIVE; } void ASTStmtWriter::VisitOMPSectionDirective(OMPSectionDirective *D) { VisitStmt(D); VisitOMPExecutableDirective(D); + Record.push_back(D->hasCancel() ? 1 : 0); Code = serialization::STMT_OMP_SECTION_DIRECTIVE; } @@ -2056,6 +2060,7 @@ void ASTStmtWriter::VisitOMPCriticalDirective(OMPCriticalDirective *D) { void ASTStmtWriter::VisitOMPParallelForDirective(OMPParallelForDirective *D) { VisitOMPLoopDirective(D); + Record.push_back(D->hasCancel() ? 1 : 0); Code = serialization::STMT_OMP_PARALLEL_FOR_DIRECTIVE; } @@ -2070,6 +2075,7 @@ void ASTStmtWriter::VisitOMPParallelSectionsDirective( VisitStmt(D); Record.push_back(D->getNumClauses()); VisitOMPExecutableDirective(D); + Record.push_back(D->hasCancel() ? 1 : 0); Code = serialization::STMT_OMP_PARALLEL_SECTIONS_DIRECTIVE; } @@ -2077,6 +2083,7 @@ void ASTStmtWriter::VisitOMPTaskDirective(OMPTaskDirective *D) { VisitStmt(D); Record.push_back(D->getNumClauses()); VisitOMPExecutableDirective(D); + Record.push_back(D->hasCancel() ? 1 : 0); Code = serialization::STMT_OMP_TASK_DIRECTIVE; } |