summaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGStmtOpenMP.cpp
diff options
context:
space:
mode:
authorAlexey Bataev <a.bataev@hotmail.com>2019-03-14 20:36:00 +0000
committerAlexey Bataev <a.bataev@hotmail.com>2019-03-14 20:36:00 +0000
commitbb8bb54e3357f85510e22cebf5cb21e89a57ffb1 (patch)
treeee5c0003594e38a19b84d4c7f46ddd78363e732b /lib/CodeGen/CGStmtOpenMP.cpp
parentd8fe413610338c120a5297733d8b8459d529431b (diff)
downloadclang-bb8bb54e3357f85510e22cebf5cb21e89a57ffb1.tar.gz
[OPENMP]Fix crash for the ordered(n) clause.
If the doacross lop construct is used and the loop counter is declare outside of the loop, the compiler might crash trying to get the address of the loop counter. Patch fixes this problem. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356198 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGStmtOpenMP.cpp')
-rw-r--r--lib/CodeGen/CGStmtOpenMP.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/CodeGen/CGStmtOpenMP.cpp b/lib/CodeGen/CGStmtOpenMP.cpp
index ed66c253be..107825bd93 100644
--- a/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/lib/CodeGen/CGStmtOpenMP.cpp
@@ -1529,8 +1529,9 @@ void CodeGenFunction::EmitOMPPrivateLoopCounters(
I < E; ++I) {
const auto *DRE = cast<DeclRefExpr>(C->getLoopCounter(I));
const auto *VD = cast<VarDecl>(DRE->getDecl());
- // Override only those variables that are really emitted already.
- if (LocalDeclMap.count(VD)) {
+ // Override only those variables that can be captured to avoid re-emission
+ // of the variables declared within the loops.
+ if (DRE->refersToEnclosingVariableOrCapture()) {
(void)LoopScope.addPrivate(VD, [this, DRE, VD]() {
return CreateMemTemp(DRE->getType(), VD->getName());
});