Changeset View
Changeset View
Standalone View
Standalone View
clang/lib/CodeGen/CGStmtOpenMP.cpp
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
Show First 20 Lines • Show All 4,105 Lines • ▼ Show 20 Lines | for (auto *IInit : C->private_copies()) { | ||||
++IRef; | ++IRef; | ||||
++IElemInitRef; | ++IElemInitRef; | ||||
} | } | ||||
} | } | ||||
OMPPrivateScope TargetScope(*this); | OMPPrivateScope TargetScope(*this); | ||||
VarDecl *BPVD = nullptr; | VarDecl *BPVD = nullptr; | ||||
VarDecl *PVD = nullptr; | VarDecl *PVD = nullptr; | ||||
VarDecl *SVD = nullptr; | VarDecl *SVD = nullptr; | ||||
VarDecl *MVD = nullptr; | |||||
if (InputInfo.NumberOfTargetItems > 0) { | if (InputInfo.NumberOfTargetItems > 0) { | ||||
auto *CD = CapturedDecl::Create( | auto *CD = CapturedDecl::Create( | ||||
getContext(), getContext().getTranslationUnitDecl(), /*NumParams=*/0); | getContext(), getContext().getTranslationUnitDecl(), /*NumParams=*/0); | ||||
llvm::APInt ArrSize(/*numBits=*/32, InputInfo.NumberOfTargetItems); | llvm::APInt ArrSize(/*numBits=*/32, InputInfo.NumberOfTargetItems); | ||||
QualType BaseAndPointersType = getContext().getConstantArrayType( | QualType BaseAndPointerAndMapperType = getContext().getConstantArrayType( | ||||
getContext().VoidPtrTy, ArrSize, nullptr, ArrayType::Normal, | getContext().VoidPtrTy, ArrSize, nullptr, ArrayType::Normal, | ||||
/*IndexTypeQuals=*/0); | /*IndexTypeQuals=*/0); | ||||
BPVD = createImplicitFirstprivateForType( | BPVD = createImplicitFirstprivateForType( | ||||
getContext(), Data, BaseAndPointersType, CD, S.getBeginLoc()); | getContext(), Data, BaseAndPointerAndMapperType, CD, S.getBeginLoc()); | ||||
PVD = createImplicitFirstprivateForType( | PVD = createImplicitFirstprivateForType( | ||||
getContext(), Data, BaseAndPointersType, CD, S.getBeginLoc()); | getContext(), Data, BaseAndPointerAndMapperType, CD, S.getBeginLoc()); | ||||
QualType SizesType = getContext().getConstantArrayType( | QualType SizesType = getContext().getConstantArrayType( | ||||
getContext().getIntTypeForBitwidth(/*DestWidth=*/64, /*Signed=*/1), | getContext().getIntTypeForBitwidth(/*DestWidth=*/64, /*Signed=*/1), | ||||
ArrSize, nullptr, ArrayType::Normal, | ArrSize, nullptr, ArrayType::Normal, | ||||
/*IndexTypeQuals=*/0); | /*IndexTypeQuals=*/0); | ||||
SVD = createImplicitFirstprivateForType(getContext(), Data, SizesType, CD, | SVD = createImplicitFirstprivateForType(getContext(), Data, SizesType, CD, | ||||
S.getBeginLoc()); | S.getBeginLoc()); | ||||
MVD = createImplicitFirstprivateForType( | |||||
getContext(), Data, BaseAndPointerAndMapperType, CD, S.getBeginLoc()); | |||||
TargetScope.addPrivate( | TargetScope.addPrivate( | ||||
BPVD, [&InputInfo]() { return InputInfo.BasePointersArray; }); | BPVD, [&InputInfo]() { return InputInfo.BasePointersArray; }); | ||||
TargetScope.addPrivate(PVD, | TargetScope.addPrivate(PVD, | ||||
[&InputInfo]() { return InputInfo.PointersArray; }); | [&InputInfo]() { return InputInfo.PointersArray; }); | ||||
TargetScope.addPrivate(SVD, | TargetScope.addPrivate(SVD, | ||||
[&InputInfo]() { return InputInfo.SizesArray; }); | [&InputInfo]() { return InputInfo.SizesArray; }); | ||||
TargetScope.addPrivate(MVD, | |||||
[&InputInfo]() { return InputInfo.MappersArray; }); | |||||
} | } | ||||
(void)TargetScope.Privatize(); | (void)TargetScope.Privatize(); | ||||
// Build list of dependences. | // Build list of dependences. | ||||
for (const auto *C : S.getClausesOfKind<OMPDependClause>()) { | for (const auto *C : S.getClausesOfKind<OMPDependClause>()) { | ||||
OMPTaskDataTy::DependData &DD = | OMPTaskDataTy::DependData &DD = | ||||
Data.Dependences.emplace_back(C->getDependencyKind(), C->getModifier()); | Data.Dependences.emplace_back(C->getDependencyKind(), C->getModifier()); | ||||
DD.DepExprs.append(C->varlist_begin(), C->varlist_end()); | DD.DepExprs.append(C->varlist_begin(), C->varlist_end()); | ||||
} | } | ||||
auto &&CodeGen = [&Data, &S, CS, &BodyGen, BPVD, PVD, SVD, | auto &&CodeGen = [&Data, &S, CS, &BodyGen, BPVD, PVD, SVD, MVD, | ||||
&InputInfo](CodeGenFunction &CGF, PrePostActionTy &Action) { | &InputInfo](CodeGenFunction &CGF, PrePostActionTy &Action) { | ||||
// Set proper addresses for generated private copies. | // Set proper addresses for generated private copies. | ||||
OMPPrivateScope Scope(CGF); | OMPPrivateScope Scope(CGF); | ||||
if (!Data.FirstprivateVars.empty()) { | if (!Data.FirstprivateVars.empty()) { | ||||
llvm::FunctionType *CopyFnTy = llvm::FunctionType::get( | llvm::FunctionType *CopyFnTy = llvm::FunctionType::get( | ||||
CGF.Builder.getVoidTy(), {CGF.Builder.getInt8PtrTy()}, true); | CGF.Builder.getVoidTy(), {CGF.Builder.getInt8PtrTy()}, true); | ||||
enum { PrivatesParam = 2, CopyFnParam = 3 }; | enum { PrivatesParam = 2, CopyFnParam = 3 }; | ||||
llvm::Value *CopyFn = CGF.Builder.CreateLoad( | llvm::Value *CopyFn = CGF.Builder.CreateLoad( | ||||
Show All 24 Lines | auto &&CodeGen = [&Data, &S, CS, &BodyGen, BPVD, PVD, SVD, MVD, | ||||
(void)Scope.Privatize(); | (void)Scope.Privatize(); | ||||
if (InputInfo.NumberOfTargetItems > 0) { | if (InputInfo.NumberOfTargetItems > 0) { | ||||
InputInfo.BasePointersArray = CGF.Builder.CreateConstArrayGEP( | InputInfo.BasePointersArray = CGF.Builder.CreateConstArrayGEP( | ||||
CGF.GetAddrOfLocalVar(BPVD), /*Index=*/0); | CGF.GetAddrOfLocalVar(BPVD), /*Index=*/0); | ||||
InputInfo.PointersArray = CGF.Builder.CreateConstArrayGEP( | InputInfo.PointersArray = CGF.Builder.CreateConstArrayGEP( | ||||
CGF.GetAddrOfLocalVar(PVD), /*Index=*/0); | CGF.GetAddrOfLocalVar(PVD), /*Index=*/0); | ||||
InputInfo.SizesArray = CGF.Builder.CreateConstArrayGEP( | InputInfo.SizesArray = CGF.Builder.CreateConstArrayGEP( | ||||
CGF.GetAddrOfLocalVar(SVD), /*Index=*/0); | CGF.GetAddrOfLocalVar(SVD), /*Index=*/0); | ||||
InputInfo.MappersArray = CGF.Builder.CreateConstArrayGEP( | |||||
CGF.GetAddrOfLocalVar(MVD), /*Index=*/0); | |||||
} | } | ||||
Action.Enter(CGF); | Action.Enter(CGF); | ||||
OMPLexicalScope LexScope(CGF, S, OMPD_task, /*EmitPreInitStmt=*/false); | OMPLexicalScope LexScope(CGF, S, OMPD_task, /*EmitPreInitStmt=*/false); | ||||
BodyGen(CGF); | BodyGen(CGF); | ||||
}; | }; | ||||
llvm::Function *OutlinedFn = CGM.getOpenMPRuntime().emitTaskOutlinedFunction( | llvm::Function *OutlinedFn = CGM.getOpenMPRuntime().emitTaskOutlinedFunction( | ||||
S, *I, *PartId, *TaskT, S.getDirectiveKind(), CodeGen, /*Tied=*/true, | S, *I, *PartId, *TaskT, S.getDirectiveKind(), CodeGen, /*Tied=*/true, | ||||
▲ Show 20 Lines • Show All 2,443 Lines • Show Last 20 Lines |