r313805 - [OPENMP] Support for re-declarations when checking captured variables.
Alexey Bataev via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 20 13:11:32 PDT 2017
Author: abataev
Date: Wed Sep 20 13:11:31 2017
New Revision: 313805
URL: http://llvm.org/viewvc/llvm-project?rev=313805&view=rev
Log:
[OPENMP] Support for re-declarations when checking captured variables.
Need to check for variables re-declarations when checking that the
variable was already captured in the captured region.
Modified:
cfe/trunk/lib/AST/Stmt.cpp
cfe/trunk/test/OpenMP/target_codegen.cpp
Modified: cfe/trunk/lib/AST/Stmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Stmt.cpp?rev=313805&r1=313804&r2=313805&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Stmt.cpp (original)
+++ cfe/trunk/lib/AST/Stmt.cpp Wed Sep 20 13:11:31 2017
@@ -1114,11 +1114,7 @@ bool CapturedStmt::capturesVariable(cons
for (const auto &I : captures()) {
if (!I.capturesVariable() && !I.capturesVariableByCopy())
continue;
-
- // This does not handle variable redeclarations. This should be
- // extended to capture variables with redeclarations, for example
- // a thread-private variable in OpenMP.
- if (I.getCapturedVar() == Var)
+ if (I.getCapturedVar()->getCanonicalDecl() == Var->getCanonicalDecl())
return true;
}
Modified: cfe/trunk/test/OpenMP/target_codegen.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_codegen.cpp?rev=313805&r1=313804&r2=313805&view=diff
==============================================================================
--- cfe/trunk/test/OpenMP/target_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/target_codegen.cpp Wed Sep 20 13:11:31 2017
@@ -79,6 +79,9 @@ struct TT{
ty Y;
};
+int global;
+extern int global;
+
// CHECK: define {{.*}}[[FOO:@.+]](
int foo(int n) {
int a = 0;
@@ -109,7 +112,7 @@ int foo(int n) {
// CHECK: call void [[HVT1:@.+]](i[[SZ]] {{[^,]+}})
#pragma omp target if(0)
{
- a += 1;
+ global += 1;
}
// CHECK-DAG: [[RET:%.+]] = call i32 @__tgt_target(i32 -1, i8* @{{[^,]+}}, i32 1, i8** [[BP:%[^,]+]], i8** [[P:%[^,]+]], i[[SZ]]* getelementptr inbounds ([1 x i[[SZ]]], [1 x i[[SZ]]]* [[SIZET2]], i32 0, i32 0), i32* getelementptr inbounds ([1 x i32], [1 x i32]* [[MAPT2]], i32 0, i32 0))
More information about the cfe-commits
mailing list