From caacd53dde6ea46d03abf272aa996957433ce31d Mon Sep 17 00:00:00 2001 From: Alexey Bataev Date: Fri, 4 Sep 2015 11:26:21 +0000 Subject: [OPENMP] Fix for http://llvm.org/PR24674: assertion failed and and abort trap Fix processing of shared variables with reference types in OpenMP constructs. Previously, if the variable was not marked in one of the private clauses, the reference to this variable was emitted incorrectly and caused an assertion later. llvm-svn: 246846 --- clang/lib/CodeGen/CGStmtOpenMP.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'clang/lib/CodeGen/CGStmtOpenMP.cpp') diff --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp b/clang/lib/CodeGen/CGStmtOpenMP.cpp index b5e7db53508..0e87c3844ba 100644 --- a/clang/lib/CodeGen/CGStmtOpenMP.cpp +++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp @@ -383,6 +383,12 @@ void CodeGenFunction::EmitOMPLastprivateClauseFinal( auto *OriginalAddr = GetAddrOfLocalVar(DestVD); // Get the address of the private variable. auto *PrivateAddr = GetAddrOfLocalVar(PrivateVD); + if (PrivateVD->getType()->isReferenceType()) + PrivateAddr = + EmitLoadOfLValue(MakeNaturalAlignAddrLValue( + PrivateAddr, PrivateVD->getType()), + (*IRef)->getExprLoc()) + .getScalarVal(); EmitOMPCopy(*this, Type, OriginalAddr, PrivateAddr, DestVD, SrcVD, AssignOp); } -- cgit v1.2.3