aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenFunction.h
diff options
context:
space:
mode:
authorAlexey Bataev <a.bataev@hotmail.com>2016-11-15 09:11:50 +0000
committerAlexey Bataev <a.bataev@hotmail.com>2016-11-15 09:11:50 +0000
commit473a3e7fed16ec27db398047d29082ce6cf9d318 (patch)
tree584f7d4a848be53a40d21bc09af776deb47b4517 /clang/lib/CodeGen/CodeGenFunction.h
parent53315a7b98dd97f9ead880ecf84906b01e8958d2 (diff)
downloadllvm-473a3e7fed16ec27db398047d29082ce6cf9d318.zip
llvm-473a3e7fed16ec27db398047d29082ce6cf9d318.tar.gz
llvm-473a3e7fed16ec27db398047d29082ce6cf9d318.tar.bz2
[OPENMP] Fixed codegen for 'omp cancel' construct.
If 'omp cancel' construct is used in a worksharing construct it may cause hanging of the software in case if reduction clause is used. Patch fixes this problem by avoiding extra reduction processing for branches that were canceled. llvm-svn: 286944
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.h')
-rw-r--r--clang/lib/CodeGen/CodeGenFunction.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h
index e5ca9bc..6e97452 100644
--- a/clang/lib/CodeGen/CodeGenFunction.h
+++ b/clang/lib/CodeGen/CodeGenFunction.h
@@ -982,6 +982,35 @@ private:
};
SmallVector<BreakContinue, 8> BreakContinueStack;
+ /// Data for exit block for proper support of OpenMP cancellation constructs.
+ struct OMPCancel {
+ JumpDest ExitBlock;
+ llvm::function_ref<void(CodeGenFunction &CGF)> CodeGen;
+ OMPCancel() : CodeGen([](CodeGenFunction &CGF) {}) {}
+ };
+ SmallVector<OMPCancel, 8> OMPCancelStack;
+
+ /// Controls insertion of cancellation exit blocks in worksharing constructs.
+ class OMPCancelStackRAII {
+ CodeGenFunction &CGF;
+
+ public:
+ OMPCancelStackRAII(CodeGenFunction &CGF) : CGF(CGF) {
+ CGF.OMPCancelStack.push_back({});
+ }
+ ~OMPCancelStackRAII() {
+ if (CGF.HaveInsertPoint() &&
+ CGF.OMPCancelStack.back().ExitBlock.isValid()) {
+ auto CJD = CGF.getJumpDestInCurrentScope("cancel.cont");
+ CGF.EmitBranchThroughCleanup(CJD);
+ CGF.EmitBlock(CGF.OMPCancelStack.back().ExitBlock.getBlock());
+ CGF.OMPCancelStack.back().CodeGen(CGF);
+ CGF.EmitBranchThroughCleanup(CJD);
+ CGF.EmitBlock(CJD.getBlock());
+ }
+ }
+ };
+
CodeGenPGO PGO;
/// Calculate branch weights appropriate for PGO data