summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexey Bataev <a.bataev@hotmail.com>2016-11-15 21:24:19 +0000
committerAlexey Bataev <a.bataev@hotmail.com>2016-11-15 21:24:19 +0000
commit4d6150a42e245d796fa216ed13a64e4ad5dbd599 (patch)
tree633e4dd912428d41deda607fb870bbd3ffe47c81
parente3bdc860bcf4db35fe6556b35cb1dca7a1baa0b5 (diff)
Merging r287025:
------------------------------------------------------------------------ r287025 | abataev | 2016-11-15 20:57:18 +0000 (Tue, 15 Nov 2016) | 3 lines [OPENMP] Fix stack use after delete, NFC. Fixed possible use of stack variable after deletion. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_39@287033 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/CodeGen/CGStmtOpenMP.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/lib/CodeGen/CGStmtOpenMP.cpp b/lib/CodeGen/CGStmtOpenMP.cpp
index 46f0006774..8937685fdc 100644
--- a/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/lib/CodeGen/CGStmtOpenMP.cpp
@@ -2187,6 +2187,7 @@ void CodeGenFunction::EmitSections(const OMPExecutableDirective &S) {
bool HasLastprivates = false;
auto &&CodeGen = [&S, Stmt, CS, &HasLastprivates](CodeGenFunction &CGF,
PrePostActionTy &) {
+ OMPCancelStackRAII CancelRegion(CGF);
auto &C = CGF.CGM.getContext();
auto KmpInt32Ty = C.getIntTypeForBitwidth(/*DestWidth=*/32, /*Signed=*/1);
// Emit helper vars inits.
@@ -2282,11 +2283,11 @@ void CodeGenFunction::EmitSections(const OMPExecutableDirective &S) {
[](CodeGenFunction &) {});
// Tell the runtime we are done.
SourceLocation ELoc = S.getLocEnd();
- auto &&CodeGen = [ELoc](CodeGenFunction &CGF) {
+ auto &&FinalCodeGen = [ELoc](CodeGenFunction &CGF) {
CGF.CGM.getOpenMPRuntime().emitForStaticFinish(CGF, ELoc);
};
- CodeGen(CGF);
- CGF.OMPCancelStack.back().CodeGen = CodeGen;
+ FinalCodeGen(CGF);
+ CGF.OMPCancelStack.back().CodeGen = FinalCodeGen;
CGF.EmitOMPReductionClauseFinal(S);
// Emit post-update of the reduction variables if IsLastIter != 0.
emitPostUpdateForReductionClause(
@@ -2324,7 +2325,6 @@ void CodeGenFunction::EmitSections(const OMPExecutableDirective &S) {
void CodeGenFunction::EmitOMPSectionsDirective(const OMPSectionsDirective &S) {
{
OMPLexicalScope Scope(*this, S, /*AsInlined=*/true);
- OMPCancelStackRAII CancelRegion(*this);
EmitSections(S);
}
// Emit an implicit barrier at the end.
@@ -2433,7 +2433,6 @@ void CodeGenFunction::EmitOMPParallelSectionsDirective(
// Emit directive as a combined directive that consists of two implicit
// directives: 'parallel' with 'sections' directive.
auto &&CodeGen = [&S](CodeGenFunction &CGF, PrePostActionTy &) {
- OMPCancelStackRAII CancelRegion(CGF);
CGF.EmitSections(S);
};
emitCommonOMPParallelDirective(*this, S, OMPD_sections, CodeGen);