forked from OSchip/llvm-project
[OPENMP]Remove const firstprivate allocation as a variable in a constant space.
Current implementation is not compatible with asynchronous target regions, need to remove it. Differential Revision: https://reviews.llvm.org/D105375
This commit is contained in:
parent
6412a13539
commit
b3c80dd894
|
@ -8224,10 +8224,6 @@ private:
|
|||
// 'private ptr' and 'map to' flag. Return the right flags if the captured
|
||||
// declaration is known as first-private in this handler.
|
||||
if (FirstPrivateDecls.count(Cap.getCapturedVar())) {
|
||||
if (Cap.getCapturedVar()->getType().isConstant(CGF.getContext()) &&
|
||||
Cap.getCaptureKind() == CapturedStmt::VCK_ByRef)
|
||||
return MappableExprsHandler::OMP_MAP_ALWAYS |
|
||||
MappableExprsHandler::OMP_MAP_TO;
|
||||
if (Cap.getCapturedVar()->getType()->isAnyPointerType())
|
||||
return MappableExprsHandler::OMP_MAP_TO |
|
||||
MappableExprsHandler::OMP_MAP_PTR_AND_OBJ;
|
||||
|
@ -9163,20 +9159,6 @@ public:
|
|||
CombinedInfo.Types.push_back(getMapModifiersForPrivateClauses(CI));
|
||||
const VarDecl *VD = CI.getCapturedVar();
|
||||
auto I = FirstPrivateDecls.find(VD);
|
||||
if (I != FirstPrivateDecls.end() &&
|
||||
VD->getType().isConstant(CGF.getContext())) {
|
||||
llvm::Constant *Addr =
|
||||
CGF.CGM.getOpenMPRuntime().registerTargetFirstprivateCopy(CGF, VD);
|
||||
// Copy the value of the original variable to the new global copy.
|
||||
CGF.Builder.CreateMemCpy(
|
||||
CGF.MakeNaturalAlignAddrLValue(Addr, ElementType).getAddress(CGF),
|
||||
Address(CV, CGF.getContext().getTypeAlignInChars(ElementType)),
|
||||
CombinedInfo.Sizes.back(), /*IsVolatile=*/false);
|
||||
// Use new global variable as the base pointers.
|
||||
CombinedInfo.Exprs.push_back(VD->getCanonicalDecl());
|
||||
CombinedInfo.BasePointers.push_back(Addr);
|
||||
CombinedInfo.Pointers.push_back(Addr);
|
||||
} else {
|
||||
CombinedInfo.Exprs.push_back(VD->getCanonicalDecl());
|
||||
CombinedInfo.BasePointers.push_back(CV);
|
||||
if (I != FirstPrivateDecls.end() && ElementType->isAnyPointerType()) {
|
||||
|
@ -9187,7 +9169,6 @@ public:
|
|||
} else {
|
||||
CombinedInfo.Pointers.push_back(CV);
|
||||
}
|
||||
}
|
||||
if (I != FirstPrivateDecls.end())
|
||||
IsImplicit = I->getSecond();
|
||||
}
|
||||
|
@ -10579,45 +10560,6 @@ bool CGOpenMPRuntime::emitTargetGlobalVariable(GlobalDecl GD) {
|
|||
return false;
|
||||
}
|
||||
|
||||
llvm::Constant *
|
||||
CGOpenMPRuntime::registerTargetFirstprivateCopy(CodeGenFunction &CGF,
|
||||
const VarDecl *VD) {
|
||||
assert(VD->getType().isConstant(CGM.getContext()) &&
|
||||
"Expected constant variable.");
|
||||
StringRef VarName;
|
||||
llvm::Constant *Addr;
|
||||
llvm::GlobalValue::LinkageTypes Linkage;
|
||||
QualType Ty = VD->getType();
|
||||
SmallString<128> Buffer;
|
||||
{
|
||||
unsigned DeviceID;
|
||||
unsigned FileID;
|
||||
unsigned Line;
|
||||
getTargetEntryUniqueInfo(CGM.getContext(), VD->getLocation(), DeviceID,
|
||||
FileID, Line);
|
||||
llvm::raw_svector_ostream OS(Buffer);
|
||||
OS << "__omp_offloading_firstprivate_" << llvm::format("_%x", DeviceID)
|
||||
<< llvm::format("_%x_", FileID);
|
||||
if (CGM.getLangOpts().CPlusPlus) {
|
||||
CGM.getCXXABI().getMangleContext().mangleTypeName(VD->getType(), OS);
|
||||
OS << "_";
|
||||
}
|
||||
OS << VD->getName() << "_l" << Line;
|
||||
VarName = OS.str();
|
||||
}
|
||||
Linkage = llvm::GlobalValue::InternalLinkage;
|
||||
Addr =
|
||||
getOrCreateInternalVariable(CGM.getTypes().ConvertTypeForMem(Ty), VarName,
|
||||
getDefaultFirstprivateAddressSpace());
|
||||
cast<llvm::GlobalValue>(Addr)->setLinkage(Linkage);
|
||||
CharUnits VarSize = CGM.getContext().getTypeSizeInChars(Ty);
|
||||
CGM.addCompilerUsedGlobal(cast<llvm::GlobalValue>(Addr));
|
||||
OffloadEntriesInfoManager.registerDeviceGlobalVarEntryInfo(
|
||||
VarName, Addr, VarSize,
|
||||
OffloadEntriesInfoManagerTy::OMPTargetGlobalVarEntryTo, Linkage);
|
||||
return Addr;
|
||||
}
|
||||
|
||||
void CGOpenMPRuntime::registerTargetGlobalVariable(const VarDecl *VD,
|
||||
llvm::Constant *Addr) {
|
||||
if (CGM.getLangOpts().OMPTargetTriples.empty() &&
|
||||
|
|
|
@ -862,10 +862,6 @@ private:
|
|||
llvm::Function *TaskFunction, QualType SharedsTy,
|
||||
Address Shareds, const OMPTaskDataTy &Data);
|
||||
|
||||
/// Returns default address space for the constant firstprivates, 0 by
|
||||
/// default.
|
||||
virtual unsigned getDefaultFirstprivateAddressSpace() const { return 0; }
|
||||
|
||||
/// Emit code that pushes the trip count of loops associated with constructs
|
||||
/// 'target teams distribute' and 'teams distribute parallel for'.
|
||||
/// \param SizeEmitter Emits the int64 value for the number of iterations of
|
||||
|
@ -1591,11 +1587,6 @@ public:
|
|||
virtual void registerTargetGlobalVariable(const VarDecl *VD,
|
||||
llvm::Constant *Addr);
|
||||
|
||||
/// Registers provided target firstprivate variable as global on the
|
||||
/// target.
|
||||
llvm::Constant *registerTargetFirstprivateCopy(CodeGenFunction &CGF,
|
||||
const VarDecl *VD);
|
||||
|
||||
/// Emit the global \a GD if it is meaningful for the target. Returns
|
||||
/// if it was emitted successfully.
|
||||
/// \param GD Global to scan.
|
||||
|
|
|
@ -3646,10 +3646,6 @@ CGOpenMPRuntimeGPU::translateParameter(const FieldDecl *FD,
|
|||
if (Attr->getCaptureKind() == OMPC_map) {
|
||||
PointeeTy = CGM.getContext().getAddrSpaceQualType(PointeeTy,
|
||||
LangAS::opencl_global);
|
||||
} else if (Attr->getCaptureKind() == OMPC_firstprivate &&
|
||||
PointeeTy.isConstant(CGM.getContext())) {
|
||||
PointeeTy = CGM.getContext().getAddrSpaceQualType(PointeeTy,
|
||||
LangAS::opencl_generic);
|
||||
}
|
||||
}
|
||||
ArgType = CGM.getContext().getPointerType(PointeeTy);
|
||||
|
@ -4084,10 +4080,6 @@ void CGOpenMPRuntimeGPU::adjustTargetSpecificDataForLambdas(
|
|||
}
|
||||
}
|
||||
|
||||
unsigned CGOpenMPRuntimeGPU::getDefaultFirstprivateAddressSpace() const {
|
||||
return CGM.getContext().getTargetAddressSpace(LangAS::cuda_constant);
|
||||
}
|
||||
|
||||
bool CGOpenMPRuntimeGPU::hasAllocateAttributeForGlobalVar(const VarDecl *VD,
|
||||
LangAS &AS) {
|
||||
if (!VD || !VD->hasAttr<OMPAllocateDeclAttr>())
|
||||
|
|
|
@ -399,10 +399,6 @@ public:
|
|||
/// supports unified addressing
|
||||
void processRequiresDirective(const OMPRequiresDecl *D) override;
|
||||
|
||||
/// Returns default address space for the constant firstprivates, __constant__
|
||||
/// address space by default.
|
||||
unsigned getDefaultFirstprivateAddressSpace() const override;
|
||||
|
||||
/// Checks if the variable has associated OMPAllocateDeclAttr attribute with
|
||||
/// the predefined allocator and translates it into the corresponding address
|
||||
/// space.
|
||||
|
|
|
@ -786,9 +786,6 @@ bool CodeGenFunction::EmitOMPFirstprivateClause(const OMPExecutableDirective &D,
|
|||
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>()) {
|
||||
|
@ -821,17 +818,6 @@ bool CodeGenFunction::EmitOMPFirstprivateClause(const OMPExecutableDirective &D,
|
|||
++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>())) {
|
||||
(void)CGM.getOpenMPRuntime().registerTargetFirstprivateCopy(*this,
|
||||
OrigVD);
|
||||
++IRef;
|
||||
++InitsRef;
|
||||
continue;
|
||||
}
|
||||
FirstprivateIsLastprivate =
|
||||
FirstprivateIsLastprivate || ThisFirstprivateIsLastprivate;
|
||||
if (EmittedAsFirstprivate.insert(OrigVD->getCanonicalDecl()).second) {
|
||||
|
|
|
@ -18,9 +18,6 @@ struct TT {
|
|||
// TCHECK-DAG: [[TT:%.+]] = type { i64, i8 }
|
||||
// TCHECK-DAG: [[S1:%.+]] = type { double }
|
||||
|
||||
// TCHECK: @__omp_offloading_firstprivate__{{.+}}_e_l30 = internal addrspace(4) global [[TTII]] zeroinitializer
|
||||
// TCHECK: @__omp_offloading_firstprivate__{{.+}}_ZTSK2TTIiiE_t_l143 = internal addrspace(4) global [[TTII]] zeroinitializer
|
||||
// TCHECK: @__omp_offloading_firstprivate__{{.+}}_ZTSK2TTIccE_t_l143 = internal addrspace(4) global [[TTIC]] zeroinitializer
|
||||
int foo(int n, double *ptr) {
|
||||
int a = 0;
|
||||
short aa = 0;
|
||||
|
@ -37,11 +34,9 @@ int foo(int n, double *ptr) {
|
|||
}
|
||||
|
||||
// TCHECK: define {{.*}}void @__omp_offloading_{{.+}}([10 x float] addrspace(1)* noalias [[B_IN:%.+]], i{{[0-9]+}} [[A_IN:%.+]], [[TTII]]* noalias [[E_IN:%.+]])
|
||||
// TCHECK-NOT: alloca [[TTII]],
|
||||
// TCHECK: [[A_ADDR:%.+]] = alloca i{{[0-9]+}},
|
||||
// TCHECK-NOT: alloca [[TTII]],
|
||||
// TCHECK-NOT: alloca i{{[0-9]+}},
|
||||
// TCHECK-64: call void @llvm.dbg.declare(metadata [10 x float] addrspace(1)** %{{.+}}, metadata !{{[0-9]+}}, metadata !DIExpression())
|
||||
// TCHECK: alloca [[TTII]],
|
||||
// TCHECK: alloca i{{[0-9]+}},
|
||||
// TCHECK: store i{{[0-9]+}} [[A_IN]], i{{[0-9]+}}* [[A_ADDR]],
|
||||
// TCHECK: ret void
|
||||
|
||||
|
|
|
@ -55,12 +55,11 @@ int ga = 5;
|
|||
// TCHECK-DAG: [[TTII:%.+]] = type { i32, i32 }
|
||||
// TCHECK-DAG: [[S1:%.+]] = type { double }
|
||||
|
||||
// CHECK-DAG: [[FP_E:@__omp_offloading_firstprivate_.+_e_l79]] = internal global [[TTII]] zeroinitializer
|
||||
// CHECK-DAG: [[SIZET:@.+]] = private unnamed_addr constant [3 x i{{32|64}}] [i[[SZ:32|64]] 4, i{{64|32}} {{8|4}}, i[[SZ:32|64]] 4]
|
||||
// CHECK-DAG: [[MAPT:@.+]] = private unnamed_addr constant [3 x i64] [i64 288, i64 49, i64 288]
|
||||
// CHECK-DAG: [[MAPT2:@.+]] = private unnamed_addr constant [9 x i64] [i64 288, i64 161, i64 800, i64 161, i64 161, i64 800, i64 800, i64 161, i64 161]
|
||||
// CHECK-DAG: [[SIZET3:@.+]] = private unnamed_addr constant [2 x i{{32|64}}] [i{{32|64}} 0, i{{32|64}} 8]
|
||||
// CHECK-DAG: [[MAPT3:@.+]] = private unnamed_addr constant [2 x i64] [i64 32, i64 37]
|
||||
// CHECK-DAG: [[MAPT3:@.+]] = private unnamed_addr constant [2 x i64] [i64 32, i64 161]
|
||||
// CHECK-DAG: [[MAPT4:@.+]] = private unnamed_addr constant [5 x i64] [i64 547, i64 288, i64 800, i64 800, i64 161]
|
||||
// CHECK-DAG: [[SIZET5:@.+]] = private unnamed_addr constant [3 x i{{32|64}}] [i[[SZ]] 4, i[[SZ]] 1, i[[SZ]] 40]
|
||||
// CHECK-DAG: [[MAPT5:@.+]] = private unnamed_addr constant [3 x i64] [i64 288, i64 288, i64 161]
|
||||
|
@ -92,6 +91,7 @@ int foo(int n, double *ptr) {
|
|||
// CHECK: [[SSTACK:%.+]] = alloca i8*,
|
||||
// CHECK: [[C:%.+]] = alloca [5 x [10 x double]],
|
||||
// CHECK: [[D:%.+]] = alloca [[TT]],
|
||||
// CHECK: [[FP_E:%.+]] = alloca [[TTII]],
|
||||
// CHECK: [[P:%.+]] = alloca i32*, align 64
|
||||
// CHECK: [[ACAST:%.+]] = alloca i{{[0-9]+}},
|
||||
// CHECK: [[BASE_PTR_ARR:%.+]] = alloca [3 x i8*],
|
||||
|
@ -347,8 +347,6 @@ int foo(int n, double *ptr) {
|
|||
}
|
||||
// CHECK: [[PTR_ADDR_REF:%.+]] = load double*, double** [[PTR_ADDR]],
|
||||
|
||||
// CHECK: [[E_BC:%.+]] = bitcast [[TTII]]* [[E:%.+]] to i8*
|
||||
// CHECK: call void @llvm.memcpy.p0i8.p0i8.i{{64|32}}(i8* {{.*}} bitcast ([[TTII]]* [[FP_E]] to i8*), i8* {{.*}} [[E_BC]], i{{64|32}} 8, i1 false)
|
||||
// CHECK: [[BASE_PTR_GEP3_0:%.+]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[BASE_PTR_ARR3]], i{{[0-9]+}} 0, i{{[0-9]+}} 0
|
||||
// CHECK: [[BCAST_TOPTR:%.+]] = bitcast i8** [[BASE_PTR_GEP3_0]] to double**
|
||||
// CHECK: store double* [[PTR_ADDR_REF]], double** [[BCAST_TOPTR]],
|
||||
|
@ -367,9 +365,8 @@ int foo(int n, double *ptr) {
|
|||
// CHECK: {{.+}} = call i32 @__tgt_target_mapper(%struct.ident_t* @{{.+}}, i64 -1, {{.+}}, i32 2, i8** [[BASE_PTR_GEP_ARG3]], i8** [[PTR_GEP_ARG3]], i[[SZ]]* getelementptr inbounds ([2 x i[[SZ]]], [2 x i[[SZ]]]* [[SIZET3]], i32 0, i32 0), i64* getelementptr inbounds ([2 x i64], [2 x i64]* [[MAPT3]], i32 0, i32 0), i8** null, i8** null)
|
||||
|
||||
// TCHECK: define weak void @__omp_offloading_{{.+}}(double* [[PTR_IN:%.+]], [[TTII]]* nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) [[E:%.+]])
|
||||
// TCHECK-NOT: alloca [[TTII]],
|
||||
// TCHECK: [[PTR_ADDR:%.+]] = alloca double*,
|
||||
// TCHECK-NOT: alloca [[TTII]],
|
||||
// TCHECK: alloca [[TTII]],
|
||||
// TCHECK-NOT: alloca double*,
|
||||
// TCHECK: store double* [[PTR_IN]], double** [[PTR_ADDR]],
|
||||
// TCHECK-NOT: store double* %
|
||||
|
|
Loading…
Reference in New Issue