This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rGf57d396dcab2: [OPENMP]Do no privatize const firstprivates in target regions. (authored by ABataev).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D105647/new/ https://reviews.llvm.org/D105647 Files: clang/lib/CodeGen/CGStmtOpenMP.cpp clang/test/OpenMP/nvptx_target_firstprivate_codegen.cpp clang/test/OpenMP/target_firstprivate_codegen.cpp Index: clang/test/OpenMP/target_firstprivate_codegen.cpp =================================================================== --- clang/test/OpenMP/target_firstprivate_codegen.cpp +++ clang/test/OpenMP/target_firstprivate_codegen.cpp @@ -366,7 +366,7 @@ // TCHECK: define weak void @__omp_offloading_{{.+}}(double* [[PTR_IN:%.+]], [[TTII]]* nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) [[E:%.+]]) // TCHECK: [[PTR_ADDR:%.+]] = alloca double*, - // TCHECK: alloca [[TTII]], + // TCHECK-NOT: alloca [[TTII]], // TCHECK-NOT: alloca double*, // TCHECK: store double* [[PTR_IN]], double** [[PTR_ADDR]], // TCHECK-NOT: store double* % Index: clang/test/OpenMP/nvptx_target_firstprivate_codegen.cpp =================================================================== --- clang/test/OpenMP/nvptx_target_firstprivate_codegen.cpp +++ clang/test/OpenMP/nvptx_target_firstprivate_codegen.cpp @@ -35,7 +35,7 @@ // TCHECK: define {{.*}}void @__omp_offloading_{{.+}}([10 x float] addrspace(1)* noalias [[B_IN:%.+]], i{{[0-9]+}} [[A_IN:%.+]], [[TTII]]* noalias [[E_IN:%.+]]) // TCHECK: [[A_ADDR:%.+]] = alloca i{{[0-9]+}}, - // TCHECK: alloca [[TTII]], + // TCHECK-NOT: alloca [[TTII]], // TCHECK: alloca i{{[0-9]+}}, // TCHECK: store i{{[0-9]+}} [[A_IN]], i{{[0-9]+}}* [[A_ADDR]], // TCHECK: ret void Index: clang/lib/CodeGen/CGStmtOpenMP.cpp =================================================================== --- clang/lib/CodeGen/CGStmtOpenMP.cpp +++ clang/lib/CodeGen/CGStmtOpenMP.cpp @@ -786,6 +786,9 @@ OMPPrivateScope &PrivateScope) { if (!HaveInsertPoint()) return false; + bool DeviceConstTarget = + getLangOpts().OpenMPIsDevice && + isOpenMPTargetExecutionDirective(D.getDirectiveKind()); bool FirstprivateIsLastprivate = false; llvm::DenseMap<const VarDecl *, OpenMPLastprivateModifier> Lastprivates; for (const auto *C : D.getClausesOfKind<OMPLastprivateClause>()) { @@ -818,6 +821,16 @@ ++InitsRef; continue; } + // Do not emit copy for firstprivate constant variables in target regions, + // captured by reference. + if (DeviceConstTarget && OrigVD->getType().isConstant(getContext()) && + FD && FD->getType()->isReferenceType() && + (!VD || !VD->hasAttr<OMPAllocateDeclAttr>())) { + EmittedAsFirstprivate.insert(OrigVD->getCanonicalDecl()); + ++IRef; + ++InitsRef; + continue; + } FirstprivateIsLastprivate = FirstprivateIsLastprivate || ThisFirstprivateIsLastprivate; if (EmittedAsFirstprivate.insert(OrigVD->getCanonicalDecl()).second) {
Index: clang/test/OpenMP/target_firstprivate_codegen.cpp =================================================================== --- clang/test/OpenMP/target_firstprivate_codegen.cpp +++ clang/test/OpenMP/target_firstprivate_codegen.cpp @@ -366,7 +366,7 @@ // TCHECK: define weak void @__omp_offloading_{{.+}}(double* [[PTR_IN:%.+]], [[TTII]]* nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) [[E:%.+]]) // TCHECK: [[PTR_ADDR:%.+]] = alloca double*, - // TCHECK: alloca [[TTII]], + // TCHECK-NOT: alloca [[TTII]], // TCHECK-NOT: alloca double*, // TCHECK: store double* [[PTR_IN]], double** [[PTR_ADDR]], // TCHECK-NOT: store double* % Index: clang/test/OpenMP/nvptx_target_firstprivate_codegen.cpp =================================================================== --- clang/test/OpenMP/nvptx_target_firstprivate_codegen.cpp +++ clang/test/OpenMP/nvptx_target_firstprivate_codegen.cpp @@ -35,7 +35,7 @@ // TCHECK: define {{.*}}void @__omp_offloading_{{.+}}([10 x float] addrspace(1)* noalias [[B_IN:%.+]], i{{[0-9]+}} [[A_IN:%.+]], [[TTII]]* noalias [[E_IN:%.+]]) // TCHECK: [[A_ADDR:%.+]] = alloca i{{[0-9]+}}, - // TCHECK: alloca [[TTII]], + // TCHECK-NOT: alloca [[TTII]], // TCHECK: alloca i{{[0-9]+}}, // TCHECK: store i{{[0-9]+}} [[A_IN]], i{{[0-9]+}}* [[A_ADDR]], // TCHECK: ret void Index: clang/lib/CodeGen/CGStmtOpenMP.cpp =================================================================== --- clang/lib/CodeGen/CGStmtOpenMP.cpp +++ clang/lib/CodeGen/CGStmtOpenMP.cpp @@ -786,6 +786,9 @@ OMPPrivateScope &PrivateScope) { if (!HaveInsertPoint()) return false; + bool DeviceConstTarget = + getLangOpts().OpenMPIsDevice && + isOpenMPTargetExecutionDirective(D.getDirectiveKind()); bool FirstprivateIsLastprivate = false; llvm::DenseMap<const VarDecl *, OpenMPLastprivateModifier> Lastprivates; for (const auto *C : D.getClausesOfKind<OMPLastprivateClause>()) { @@ -818,6 +821,16 @@ ++InitsRef; continue; } + // Do not emit copy for firstprivate constant variables in target regions, + // captured by reference. + if (DeviceConstTarget && OrigVD->getType().isConstant(getContext()) && + FD && FD->getType()->isReferenceType() && + (!VD || !VD->hasAttr<OMPAllocateDeclAttr>())) { + EmittedAsFirstprivate.insert(OrigVD->getCanonicalDecl()); + ++IRef; + ++InitsRef; + continue; + } FirstprivateIsLastprivate = FirstprivateIsLastprivate || ThisFirstprivateIsLastprivate; if (EmittedAsFirstprivate.insert(OrigVD->getCanonicalDecl()).second) {
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits