diff options
author | Alexey Bataev <a.bataev@hotmail.com> | 2017-09-22 16:56:13 +0000 |
---|---|---|
committer | Alexey Bataev <a.bataev@hotmail.com> | 2017-09-22 16:56:13 +0000 |
commit | b7f18c3297df93b1245893b97b549e369f4e8f9c (patch) | |
tree | b7f832ddc8dbc6a03c912bb7cd47c0477ed96012 | |
parent | 09273239d1e17e1079a07238ecc384ec5479c06f (diff) | |
download | bcm5719-llvm-b7f18c3297df93b1245893b97b549e369f4e8f9c.tar.gz bcm5719-llvm-b7f18c3297df93b1245893b97b549e369f4e8f9c.zip |
[OPENMP] Handle re-declaration of captured variables in CodeGen.
If the captured variable has re-declaration we may end up with the
situation where the captured variable is the re-declaration while the
referenced variable is the canonical declaration (or vice versa). In
this case we may generate wrong code. Patch fixes this situation.
llvm-svn: 313995
-rw-r--r-- | clang/lib/CodeGen/CodeGenFunction.h | 6 | ||||
-rw-r--r-- | clang/test/OpenMP/target_codegen.cpp | 2 |
2 files changed, 4 insertions, 4 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h index 33bf74b5d39..7dca3805973 100644 --- a/clang/lib/CodeGen/CodeGenFunction.h +++ b/clang/lib/CodeGen/CodeGenFunction.h @@ -263,9 +263,9 @@ public: if (I->capturesThis()) CXXThisFieldDecl = *Field; else if (I->capturesVariable()) - CaptureFields[I->getCapturedVar()] = *Field; + CaptureFields[I->getCapturedVar()->getCanonicalDecl()] = *Field; else if (I->capturesVariableByCopy()) - CaptureFields[I->getCapturedVar()] = *Field; + CaptureFields[I->getCapturedVar()->getCanonicalDecl()] = *Field; } } @@ -279,7 +279,7 @@ public: /// \brief Lookup the captured field decl for a variable. virtual const FieldDecl *lookup(const VarDecl *VD) const { - return CaptureFields.lookup(VD); + return CaptureFields.lookup(VD->getCanonicalDecl()); } bool isCXXThisExprCaptured() const { return getThisFieldDecl() != nullptr; } diff --git a/clang/test/OpenMP/target_codegen.cpp b/clang/test/OpenMP/target_codegen.cpp index 9d68dd4a1e5..21c82d1cadb 100644 --- a/clang/test/OpenMP/target_codegen.cpp +++ b/clang/test/OpenMP/target_codegen.cpp @@ -110,7 +110,7 @@ int foo(int n) { // CHECK: [[RET2:%.+]] = load i32, i32* [[RHV]], align 4 // CHECK-NEXT: [[ERROR:%.+]] = icmp ne i32 [[RET2]], 0 // CHECK: call void [[HVT1:@.+]](i[[SZ]] {{[^,]+}}) - #pragma omp target if(0) + #pragma omp target if(0) firstprivate(global) { global += 1; } |