diff options
author | Alexey Bataev <a.bataev@hotmail.com> | 2016-04-27 11:38:05 +0000 |
---|---|---|
committer | Alexey Bataev <a.bataev@hotmail.com> | 2016-04-27 11:38:05 +0000 |
commit | 8fbae8cf093c10ad3848ab9858faa2464197f8ef (patch) | |
tree | 39c05d0785002bcda968acfcaf5cecceacfec742 /clang/lib/CodeGen | |
parent | de0bbe6d1cf2f9273c54b3b35c1f07ea61ca079f (diff) | |
download | bcm5719-llvm-8fbae8cf093c10ad3848ab9858faa2464197f8ef.tar.gz bcm5719-llvm-8fbae8cf093c10ad3848ab9858faa2464197f8ef.zip |
[OPENMP] Fix crash on initialization of classes with no init clause in
declare reductions.
If reduction clause is applied to instance of class with user-defined
reduction operation without initialization clause, it may cause a crash.
Patch fixes this issue.
llvm-svn: 267695
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r-- | clang/lib/CodeGen/CGStmtOpenMP.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp b/clang/lib/CodeGen/CGStmtOpenMP.cpp index 5bcf0fa4187..78e8c691e00 100644 --- a/clang/lib/CodeGen/CGStmtOpenMP.cpp +++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp @@ -481,7 +481,7 @@ static void EmitOMPAggregateInit(CodeGenFunction &CGF, Address DestAddr, // Emit copy. { CodeGenFunction::RunCleanupsScope InitScope(CGF); - if (DRD) { + if (DRD && (DRD->getInitializer() || !Init)) { emitInitWithReductionInitializer(CGF, DRD, Init, DestElementCurrent, SrcElementCurrent, ElementTy); } else @@ -993,7 +993,7 @@ void CodeGenFunction::EmitOMPReductionClauseInit( // Emit private VarDecl with reduction init. AutoVarEmission Emission = EmitAutoVarAlloca(*PrivateVD); auto Addr = Emission.getAllocatedAddress(); - if (DRD) { + if (DRD && (DRD->getInitializer() || !PrivateVD->hasInit())) { emitInitWithReductionInitializer(*this, DRD, *IRed, Addr, ASELValue.getAddress(), ASELValue.getType()); @@ -1075,7 +1075,7 @@ void CodeGenFunction::EmitOMPReductionClauseInit( // Emit private VarDecl with reduction init. AutoVarEmission Emission = EmitAutoVarAlloca(*PrivateVD); auto Addr = Emission.getAllocatedAddress(); - if (DRD) { + if (DRD && (DRD->getInitializer() || !PrivateVD->hasInit())) { emitInitWithReductionInitializer(*this, DRD, *IRed, Addr, OriginalAddr, PrivateVD->getType()); |