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/CGExpr.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'clang/lib/CodeGen/CGExpr.cpp') diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp index f6cb3e304b7..b38afc9b37a 100644 --- a/clang/lib/CodeGen/CGExpr.cpp +++ b/clang/lib/CodeGen/CGExpr.cpp @@ -1942,11 +1942,17 @@ LValue CodeGenFunction::EmitDeclRefLValue(const DeclRefExpr *E) { if (auto *FD = LambdaCaptureFields.lookup(VD)) return EmitCapturedFieldLValue(*this, FD, CXXABIThisValue); else if (CapturedStmtInfo) { - if (auto *V = LocalDeclMap.lookup(VD)) + if (auto *V = LocalDeclMap.lookup(VD)) { + if (VD->getType()->isReferenceType()) { + llvm::LoadInst *LI = Builder.CreateLoad(V); + LI->setAlignment(Alignment.getQuantity()); + V = LI; + return MakeNaturalAlignAddrLValue(V, T); + } return MakeAddrLValue(V, T, Alignment); - else - return EmitCapturedFieldLValue(*this, CapturedStmtInfo->lookup(VD), - CapturedStmtInfo->getContextValue()); + } + return EmitCapturedFieldLValue(*this, CapturedStmtInfo->lookup(VD), + CapturedStmtInfo->getContextValue()); } assert(isa(CurCodeDecl)); return MakeAddrLValue(GetAddrOfBlockDecl(VD, VD->hasAttr()), -- cgit v1.2.3