From 9d5411b8c1483aef35fe908b9cbe17e8d91082e0 Mon Sep 17 00:00:00 2001 From: Alexey Bataev Date: Fri, 9 Mar 2018 15:20:30 +0000 Subject: [PATCH] [OPENMP] Fix the address of the original variable in task reductions. If initialization of the task reductions requires pointer to original variable, which is stored in the threadprivate storage, we used the address of this pointer instead. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@327136 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGOpenMPRuntime.cpp | 3 +++ test/OpenMP/taskloop_reduction_codegen.cpp | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/CodeGen/CGOpenMPRuntime.cpp b/lib/CodeGen/CGOpenMPRuntime.cpp index f9dab90f39..708f0abd08 100644 --- a/lib/CodeGen/CGOpenMPRuntime.cpp +++ b/lib/CodeGen/CGOpenMPRuntime.cpp @@ -5422,6 +5422,9 @@ static llvm::Value *emitReduceInitFunction(CodeGenModule &CGM, CGM.getOpenMPRuntime().getAddrOfArtificialThreadPrivate( CGF, CGM.getContext().VoidPtrTy, generateUniqueName(CGM, "reduction", RCG.getRefExpr(N))); + SharedAddr = CGF.EmitLoadOfPointer( + SharedAddr, + CGM.getContext().VoidPtrTy.castAs()->getTypePtr()); SharedLVal = CGF.MakeAddrLValue(SharedAddr, CGM.getContext().VoidPtrTy); } else { SharedLVal = CGF.MakeNaturalAlignAddrLValue( diff --git a/test/OpenMP/taskloop_reduction_codegen.cpp b/test/OpenMP/taskloop_reduction_codegen.cpp index 2623d932c7..fe261d4e06 100644 --- a/test/OpenMP/taskloop_reduction_codegen.cpp +++ b/test/OpenMP/taskloop_reduction_codegen.cpp @@ -164,7 +164,9 @@ sum = 0.0; // CHECK: define internal void @[[RED_INIT2]](i8*) // CHECK: call i8* @__kmpc_threadprivate_cached( -// CHECK: call i8* @__kmpc_threadprivate_cached( +// CHECK: [[ORIG_PTR_ADDR:%.+]] = call i8* @__kmpc_threadprivate_cached( +// CHECK: [[ORIG_PTR_REF:%.+]] = bitcast i8* [[ORIG_PTR_ADDR]] to i8** +// CHECK: load i8*, i8** [[ORIG_PTR_REF]], // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64( // CHECK: ret void -- 2.40.0